28 : QDialog( parent, flags )
31 connect( mWidthSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsLayoutImageExportOptionsDialog::mWidthSpinBox_valueChanged );
32 connect( mHeightSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsLayoutImageExportOptionsDialog::mHeightSpinBox_valueChanged );
33 connect( mResolutionSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsLayoutImageExportOptionsDialog::mResolutionSpinBox_valueChanged );
35 connect( mClipToContentGroupBox, &QGroupBox::toggled,
this, &QgsLayoutImageExportOptionsDialog::clipToContentsToggled );
36 connect( mHelpButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutImageExportOptionsDialog::showHelp );
44 if ( mImageSize.isValid() )
46 mWidthSpinBox->blockSignals(
true );
47 mHeightSpinBox->blockSignals(
true );
48 if ( mClipToContentGroupBox->isChecked() )
50 mWidthSpinBox->setValue( 0 );
51 mHeightSpinBox->setValue( 0 );
55 mWidthSpinBox->setValue( mImageSize.width() *
resolution / 25.4 );
56 mHeightSpinBox->setValue( mImageSize.height() *
resolution / 25.4 );
58 mWidthSpinBox->blockSignals(
false );
59 mHeightSpinBox->blockSignals(
false );
65 return mResolutionSpinBox->value();
71 mWidthSpinBox->blockSignals(
true );
72 mHeightSpinBox->blockSignals(
true );
73 mWidthSpinBox->setValue( size.width() * mResolutionSpinBox->value() / 25.4 );
74 mHeightSpinBox->setValue( size.height() * mResolutionSpinBox->value() / 25.4 );
75 mWidthSpinBox->blockSignals(
false );
76 mHeightSpinBox->blockSignals(
false );
81 return mWidthSpinBox->value();
86 return mHeightSpinBox->value();
91 mClipToContentGroupBox->setChecked( crop );
96 return mClipToContentGroupBox->isChecked();
101 mGenerateWorldFile->setChecked( generate );
106 return mGenerateWorldFile->isChecked();
111 mAntialiasingCheckBox->setChecked( antialias );
116 return mAntialiasingCheckBox->isChecked();
121 topMargin = mTopMarginSpinBox->value();
122 rightMargin = mRightMarginSpinBox->value();
123 bottomMargin = mBottomMarginSpinBox->value();
124 leftMargin = mLeftMarginSpinBox->value();
129 mTopMarginSpinBox->setValue( topMargin );
130 mRightMarginSpinBox->setValue( rightMargin );
131 mBottomMarginSpinBox->setValue( bottomMargin );
132 mLeftMarginSpinBox->setValue( leftMargin );
137 return mOpenAfterExportingCheckBox->isChecked();
142 mOpenAfterExportingCheckBox->setChecked( enabled );
145void QgsLayoutImageExportOptionsDialog::mWidthSpinBox_valueChanged(
int value )
147 mHeightSpinBox->blockSignals(
true );
148 mResolutionSpinBox->blockSignals(
true );
149 mHeightSpinBox->setValue( mImageSize.height() * value / mImageSize.width() );
150 mResolutionSpinBox->setValue( value * 25.4 / mImageSize.width() );
151 mHeightSpinBox->blockSignals(
false );
152 mResolutionSpinBox->blockSignals(
false );
155void QgsLayoutImageExportOptionsDialog::mHeightSpinBox_valueChanged(
int value )
157 mWidthSpinBox->blockSignals(
true );
158 mResolutionSpinBox->blockSignals(
true );
159 mWidthSpinBox->setValue( mImageSize.width() * value / mImageSize.height() );
160 mResolutionSpinBox->setValue( value * 25.4 / mImageSize.height() );
161 mWidthSpinBox->blockSignals(
false );
162 mResolutionSpinBox->blockSignals(
false );
165void QgsLayoutImageExportOptionsDialog::mResolutionSpinBox_valueChanged(
int value )
167 mWidthSpinBox->blockSignals(
true );
168 mHeightSpinBox->blockSignals(
true );
169 if ( mClipToContentGroupBox->isChecked() )
171 mWidthSpinBox->setValue( 0 );
172 mHeightSpinBox->setValue( 0 );
176 mWidthSpinBox->setValue( mImageSize.width() * value / 25.4 );
177 mHeightSpinBox->setValue( mImageSize.height() * value / 25.4 );
179 mWidthSpinBox->blockSignals(
false );
180 mHeightSpinBox->blockSignals(
false );
183void QgsLayoutImageExportOptionsDialog::clipToContentsToggled(
bool state )
185 mWidthSpinBox->setEnabled( !state );
186 mHeightSpinBox->setEnabled( !state );
195 whileBlocking( mWidthSpinBox )->setValue( mImageSize.width() * mResolutionSpinBox->value() / 25.4 );
196 whileBlocking( mHeightSpinBox )->setValue( mImageSize.height() * mResolutionSpinBox->value() / 25.4 );
200void QgsLayoutImageExportOptionsDialog::showHelp()
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
bool antialiasing() const
Returns whether antialiasing should be used in the export.
QgsLayoutImageExportOptionsDialog(QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
Constructor for QgsLayoutImageExportOptionsDialog.
void setCropToContents(bool crop)
Sets whether the crop to contents option should be checked in the dialog.
void setImageSize(QSizeF size)
Sets the target image size.
void setAntialiasing(bool antialias)
Sets whether antialiasing should be used in the export.
double resolution() const
Returns the selected resolution from the dialog.
int imageWidth() const
Returns the user-set image width in pixels.
bool cropToContents() const
Returns whether the crop to contents option is checked in the dialog.
void setOpenAfterExporting(bool enabled)
Sets whether to open the pdf after exporting it.
bool generateWorldFile() const
Returns whether the generate world file option is checked in the dialog.
void setCropMargins(int topMargin, int rightMargin, int bottomMargin, int leftMargin)
Sets the current crop to contents margin values, in pixels.
void setResolution(double resolution)
Sets the initial resolution displayed in the dialog.
void getCropMargins(int &topMargin, int &rightMargin, int &bottomMargin, int &leftMargin) const
Fetches the current crop to contents margin values, in pixels.
int imageHeight() const
Returns the user-set image height in pixels.
void setGenerateWorldFile(bool generate)
Sets whether the generate world file option should be checked.
bool openAfterExporting() const
Returns whether the pdf should be opened after exporting it.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.