Skip to content

Commit

Permalink
Expose world file option in image settings dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 17, 2017
1 parent 953d2c4 commit 0f9aaf4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/app/layout/qgslayoutdesignerdialog.cpp
Expand Up @@ -1456,6 +1456,7 @@ void QgsLayoutDesignerDialog::exportToRaster()
imageDlg.setResolution( dpi );
imageDlg.setCropToContents( cropToContents );
imageDlg.setCropMargins( marginTop, marginRight, marginBottom, marginLeft );
imageDlg.setGenerateWorldFile( mLayout->customProperty( QStringLiteral( "exportWorldFile" ), false ).toBool() );

#if 0 //TODO
QgsAtlasComposition *atlasMap = &mComposition->atlasComposition();
Expand Down Expand Up @@ -1505,7 +1506,7 @@ void QgsLayoutDesignerDialog::exportToRaster()
{
settings.imageSize = QSize( imageDlg.imageWidth(), imageDlg.imageHeight() );
}
settings.generateWorldFile = mLayout->customProperty( QStringLiteral( "exportWorldFile" ), false ).toBool();
settings.generateWorldFile = imageDlg.generateWorldFile();

switch ( exporter.exportToImage( fileNExt.first, settings ) )
{
Expand Down
10 changes: 10 additions & 0 deletions src/app/layout/qgslayoutimageexportoptionsdialog.cpp
Expand Up @@ -95,6 +95,16 @@ bool QgsLayoutImageExportOptionsDialog::cropToContents() const
return mClipToContentGroupBox->isChecked();
}

void QgsLayoutImageExportOptionsDialog::setGenerateWorldFile( bool generate )
{
mGenerateWorldFile->setChecked( generate );
}

bool QgsLayoutImageExportOptionsDialog::generateWorldFile() const
{
return mGenerateWorldFile->isChecked();
}

void QgsLayoutImageExportOptionsDialog::getCropMargins( int &topMargin, int &rightMargin, int &bottomMargin, int &leftMargin ) const
{
topMargin = mTopMarginSpinBox->value();
Expand Down
12 changes: 12 additions & 0 deletions src/app/layout/qgslayoutimageexportoptionsdialog.h
Expand Up @@ -84,6 +84,18 @@ class QgsLayoutImageExportOptionsDialog: public QDialog, private Ui::QgsLayoutIm
*/
bool cropToContents() const;

/**
* Sets whether the generate world file option should be checked.
* \see generateWorldFile()
*/
void setGenerateWorldFile( bool generate );

/**
* Returns whether the generate world file option is checked in the dialog.
* \see setGenerateWorldFile()
*/
bool generateWorldFile() const;

/**
* Fetches the current crop to contents margin values, in pixels.
* \param topMargin destination for top margin
Expand Down
12 changes: 11 additions & 1 deletion src/ui/layout/qgslayoutimageexportoptions.ui
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>533</width>
<height>651</height>
<height>394</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -234,6 +234,16 @@
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mGenerateWorldFile">
<property name="toolTip">
<string>If checked, a separate world file which georeferences exported images will be created</string>
</property>
<property name="text">
<string>Generate world file</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down

0 comments on commit 0f9aaf4

Please sign in to comment.