37     mPageSizeComboBox->addItem( size.displayName, size.name );
 
   39   mPageSizeComboBox->addItem( tr( 
"Custom" ) );
 
   46   mPageOrientationComboBox->setCurrentIndex( mPageOrientationComboBox->findData( mPage->
orientation() ) );
 
   48   mSizeUnitsComboBox->linkToWidget( mWidthSpin );
 
   49   mSizeUnitsComboBox->linkToWidget( mHeightSpin );
 
   52   mLockAspectRatio->setWidthSpinBox( mWidthSpin );
 
   53   mLockAspectRatio->setHeightSpinBox( mHeightSpin );
 
   58   connect( mPageSizeComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLayoutPagePropertiesWidget::pageSizeChanged );
 
   59   connect( mPageOrientationComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLayoutPagePropertiesWidget::orientationChanged );
 
   61   connect( mWidthSpin, 
static_cast< void ( QDoubleSpinBox::* )( 
double )
>( &QDoubleSpinBox::valueChanged ), 
this, &QgsLayoutPagePropertiesWidget::updatePageSize );
 
   62   connect( mHeightSpin, 
static_cast< void ( QDoubleSpinBox::* )( 
double )
>( &QDoubleSpinBox::valueChanged ), 
this, &QgsLayoutPagePropertiesWidget::updatePageSize );
 
   63   connect( mWidthSpin, 
static_cast< void ( QDoubleSpinBox::* )( 
double )
>( &QDoubleSpinBox::valueChanged ), 
this, &QgsLayoutPagePropertiesWidget::setToCustomSize );
 
   64   connect( mHeightSpin, 
static_cast< void ( QDoubleSpinBox::* )( 
double )
>( &QDoubleSpinBox::valueChanged ), 
this, &QgsLayoutPagePropertiesWidget::setToCustomSize );
 
   65   connect( mExcludePageCheckBox, &QCheckBox::toggled, 
this, &QgsLayoutPagePropertiesWidget::excludeExportsToggled );
 
   79   mExcludePageDDBtn->registerEnabledWidget( mExcludePageCheckBox, 
false );
 
   81   mSymbolButton->registerExpressionContextGenerator( mPage );
 
   88   showCurrentPageSize();
 
   91 void QgsLayoutPagePropertiesWidget::pageSizeChanged( 
int )
 
   93   mBlockPageUpdate = 
true;
 
   94   if ( mPageSizeComboBox->currentData().toString().isEmpty() )
 
   97     mLockAspectRatio->setEnabled( 
true );
 
   98     mSizeUnitsComboBox->setEnabled( 
true );
 
   99     mPageOrientationComboBox->setEnabled( 
false );
 
  103     mLockAspectRatio->setEnabled( 
false );
 
  104     mLockAspectRatio->setLocked( 
false );
 
  105     mSizeUnitsComboBox->setEnabled( 
false );
 
  106     mPageOrientationComboBox->setEnabled( 
true );
 
  108     QgsLayoutSize convertedSize = mConverter.convert( size.
size, mSizeUnitsComboBox->unit() );
 
  109     mSettingPresetSize = 
true;
 
  110     switch ( mPageOrientationComboBox->currentData().toInt() )
 
  113         mWidthSpin->setValue( convertedSize.
height() );
 
  114         mHeightSpin->setValue( convertedSize.
width() );
 
  118         mWidthSpin->setValue( convertedSize.
width() );
 
  119         mHeightSpin->setValue( convertedSize.
height() );
 
  122     mSettingPresetSize = 
false;
 
  124   mBlockPageUpdate = 
false;
 
  128 void QgsLayoutPagePropertiesWidget::orientationChanged( 
int )
 
  130   if ( mPageSizeComboBox->currentData().toString().isEmpty() )
 
  133   double width = mWidthSpin->value();
 
  134   double height = mHeightSpin->value();
 
  135   switch ( mPageOrientationComboBox->currentData().toInt() )
 
  138       if ( width < height )
 
  146       if ( width > height )
 
  157 void QgsLayoutPagePropertiesWidget::updatePageSize()
 
  159   if ( mBlockPageUpdate )
 
  162   mPage->layout()->undoStack()->beginMacro( tr( 
"Change Page Size" ) );
 
  163   mPage->layout()->pageCollection()->beginPageSizeChange();
 
  164   mPage->layout()->undoStack()->beginCommand( mPage, tr( 
"Change Page Size" ), 1 + mPage->layout()->pageCollection()->pageNumber( mPage ) );
 
  165   mPage->setPageSize( 
QgsLayoutSize( mWidthSpin->value(), mHeightSpin->value(), mSizeUnitsComboBox->unit() ) );
 
  166   mPage->layout()->undoStack()->endCommand();
 
  167   mPage->layout()->pageCollection()->reflow();
 
  168   mPage->layout()->pageCollection()->endPageSizeChange();
 
  169   mPage->layout()->undoStack()->endMacro();
 
  172   emit pageOrientationChanged();
 
  175 void QgsLayoutPagePropertiesWidget::setToCustomSize()
 
  177   if ( mSettingPresetSize )
 
  179   whileBlocking( mPageSizeComboBox )->setCurrentIndex( mPageSizeComboBox->count() - 1 );
 
  180   mPageOrientationComboBox->setEnabled( 
false );
 
  183 void QgsLayoutPagePropertiesWidget::symbolChanged()
 
  186   mPage->setPageStyleSymbol( 
static_cast< QgsFillSymbol * 
>( mSymbolButton->symbol() )->
clone() );
 
  187   mPage->layout()->undoStack()->endCommand();
 
  190 void QgsLayoutPagePropertiesWidget::excludeExportsToggled( 
bool checked )
 
  192   mPage->beginCommand( !checked ? tr( 
"Include Page in Exports" ) : tr( 
"Exclude Page from Exports" ) );
 
  193   mPage->setExcludeFromExports( checked );
 
  197 void QgsLayoutPagePropertiesWidget::refreshLayout()
 
  199   mPage->layout()->refresh();
 
  202 void QgsLayoutPagePropertiesWidget::showCurrentPageSize()
 
  206   if ( !pageSize.isEmpty() )
 
  208     whileBlocking( mPageSizeComboBox )->setCurrentIndex( mPageSizeComboBox->findData( pageSize ) );
 
  209     mLockAspectRatio->setEnabled( 
false );
 
  210     mLockAspectRatio->setLocked( 
false );
 
  211     mSizeUnitsComboBox->setEnabled( 
false );
 
  212     mPageOrientationComboBox->setEnabled( 
true );
 
  217     whileBlocking( mPageSizeComboBox )->setCurrentIndex( mPageSizeComboBox->count() - 1 );
 
  218     mLockAspectRatio->setEnabled( 
true );
 
  219     mSizeUnitsComboBox->setEnabled( 
true );
 
  220     mPageOrientationComboBox->setEnabled( 
false );