25 : QDialog( parent, flags )
31 mPageOrientationComboBox->setCurrentIndex( 1 );
36 mPageSizeComboBox->addItem( size.displayName, size.name );
38 mPageSizeComboBox->addItem( tr(
"Custom" ) );
39 mPageSizeComboBox->setCurrentIndex( mPageSizeComboBox->findData( QStringLiteral(
"A4" ) ) );
40 pageSizeChanged( mPageSizeComboBox->currentIndex() );
41 orientationChanged( 1 );
43 mSizeUnitsComboBox->linkToWidget( mWidthSpin );
44 mSizeUnitsComboBox->linkToWidget( mHeightSpin );
46 mLockAspectRatio->setWidthSpinBox( mWidthSpin );
47 mLockAspectRatio->setHeightSpinBox( mHeightSpin );
49 connect( mPositionComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAddPagesDialog::positionChanged );
50 mExistingPageSpinBox->setEnabled(
false );
52 connect( mPageSizeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAddPagesDialog::pageSizeChanged );
53 connect( mPageOrientationComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAddPagesDialog::orientationChanged );
55 connect( mWidthSpin,
static_cast< void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutAddPagesDialog::setToCustomSize );
56 connect( mHeightSpin,
static_cast< void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutAddPagesDialog::setToCustomSize );
58 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsLayoutAddPagesDialog::showHelp );
64 mSizeUnitsComboBox->setConverter( &mConverter );
66 mSizeUnitsComboBox->setUnit( layout->
units() );
71 return mPagesSpinBox->value();
76 return static_cast< PagePosition >( mPositionComboBox->currentIndex() );
81 return mExistingPageSpinBox->value();
86 return QgsLayoutSize( mWidthSpin->value(), mHeightSpin->value(), mSizeUnitsComboBox->unit() );
89 void QgsLayoutAddPagesDialog::positionChanged(
int index )
91 mExistingPageSpinBox->setEnabled( index != 2 );
94 void QgsLayoutAddPagesDialog::pageSizeChanged(
int )
96 if ( mPageSizeComboBox->currentData().toString().isEmpty() )
99 mLockAspectRatio->setEnabled(
true );
100 mSizeUnitsComboBox->setEnabled(
true );
101 mPageOrientationComboBox->setEnabled(
false );
105 mLockAspectRatio->setEnabled(
false );
106 mLockAspectRatio->setLocked(
false );
107 mSizeUnitsComboBox->setEnabled(
false );
108 mPageOrientationComboBox->setEnabled(
true );
111 mSettingPresetSize =
true;
112 switch ( mPageOrientationComboBox->currentData().toInt() )
115 mWidthSpin->setValue( convertedSize.
height() );
116 mHeightSpin->setValue( convertedSize.
width() );
120 mWidthSpin->setValue( convertedSize.
width() );
121 mHeightSpin->setValue( convertedSize.
height() );
124 mSettingPresetSize =
false;
128 void QgsLayoutAddPagesDialog::orientationChanged(
int )
130 if ( mPageSizeComboBox->currentData().toString().isEmpty() )
133 const double width = mWidthSpin->value();
134 const double height = mHeightSpin->value();
135 switch ( mPageOrientationComboBox->currentData().toInt() )
138 if ( width < height )
146 if ( width > height )
155 void QgsLayoutAddPagesDialog::setToCustomSize()
157 if ( mSettingPresetSize )
159 whileBlocking( mPageSizeComboBox )->setCurrentIndex( mPageSizeComboBox->count() - 1 );
160 mPageOrientationComboBox->setEnabled(
false );
161 mLockAspectRatio->setEnabled(
true );
162 mSizeUnitsComboBox->setEnabled(
true );
165 void QgsLayoutAddPagesDialog::showHelp()
167 QgsHelp::openHelp( QStringLiteral(
"print_composer/overview_composer.html#working-with-the-page-properties" ) );