20 #include "qgssettings.h"
25 #include <QPushButton>
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( buttonBox, &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 );
135 void QgsLayoutImageExportOptionsDialog::mWidthSpinBox_valueChanged(
int value )
137 mHeightSpinBox->blockSignals(
true );
138 mResolutionSpinBox->blockSignals(
true );
139 mHeightSpinBox->setValue( mImageSize.height() * value / mImageSize.width() );
140 mResolutionSpinBox->setValue( value * 25.4 / mImageSize.width() );
141 mHeightSpinBox->blockSignals(
false );
142 mResolutionSpinBox->blockSignals(
false );
145 void QgsLayoutImageExportOptionsDialog::mHeightSpinBox_valueChanged(
int value )
147 mWidthSpinBox->blockSignals(
true );
148 mResolutionSpinBox->blockSignals(
true );
149 mWidthSpinBox->setValue( mImageSize.width() * value / mImageSize.height() );
150 mResolutionSpinBox->setValue( value * 25.4 / mImageSize.height() );
151 mWidthSpinBox->blockSignals(
false );
152 mResolutionSpinBox->blockSignals(
false );
155 void QgsLayoutImageExportOptionsDialog::mResolutionSpinBox_valueChanged(
int value )
157 mWidthSpinBox->blockSignals(
true );
158 mHeightSpinBox->blockSignals(
true );
159 if ( mClipToContentGroupBox->isChecked() )
161 mWidthSpinBox->setValue( 0 );
162 mHeightSpinBox->setValue( 0 );
166 mWidthSpinBox->setValue( mImageSize.width() * value / 25.4 );
167 mHeightSpinBox->setValue( mImageSize.height() * value / 25.4 );
169 mWidthSpinBox->blockSignals(
false );
170 mHeightSpinBox->blockSignals(
false );
173 void QgsLayoutImageExportOptionsDialog::clipToContentsToggled(
bool state )
175 mWidthSpinBox->setEnabled( !state );
176 mHeightSpinBox->setEnabled( !state );
185 whileBlocking( mWidthSpinBox )->setValue( mImageSize.width() * mResolutionSpinBox->value() / 25.4 );
186 whileBlocking( mHeightSpinBox )->setValue( mImageSize.height() * mResolutionSpinBox->value() / 25.4 );
190 void 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.
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.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.