@@ -33,7 +33,6 @@ QgsLayoutPagePropertiesWidget::QgsLayoutPagePropertiesWidget( QWidget *parent, Q
33
33
mPageSizeComboBox ->addItem ( size.displayName , size.name );
34
34
}
35
35
mPageSizeComboBox ->addItem ( tr ( " Custom" ) );
36
- showCurrentPageSize ();
37
36
38
37
mWidthSpin ->setValue ( mPage ->pageSize ().width () );
39
38
mHeightSpin ->setValue ( mPage ->pageSize ().height () );
@@ -53,30 +52,30 @@ QgsLayoutPagePropertiesWidget::QgsLayoutPagePropertiesWidget( QWidget *parent, Q
53
52
54
53
connect ( mWidthSpin , static_cast < void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this , &QgsLayoutPagePropertiesWidget::updatePageSize );
55
54
connect ( mHeightSpin , static_cast < void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this , &QgsLayoutPagePropertiesWidget::updatePageSize );
55
+ connect ( mWidthSpin , static_cast < void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this , &QgsLayoutPagePropertiesWidget::setToCustomSize );
56
+ connect ( mHeightSpin , static_cast < void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this , &QgsLayoutPagePropertiesWidget::setToCustomSize );
56
57
58
+ showCurrentPageSize ();
57
59
}
58
60
59
61
void QgsLayoutPagePropertiesWidget::pageSizeChanged ( int )
60
62
{
61
63
if ( mPageSizeComboBox ->currentData ().toString ().isEmpty () )
62
64
{
63
65
// custom size
64
- mWidthSpin ->setEnabled ( true );
65
- mHeightSpin ->setEnabled ( true );
66
66
mLockAspectRatio ->setEnabled ( true );
67
67
mSizeUnitsComboBox ->setEnabled ( true );
68
68
mPageOrientationComboBox ->setEnabled ( false );
69
69
}
70
70
else
71
71
{
72
- mWidthSpin ->setEnabled ( false );
73
- mHeightSpin ->setEnabled ( false );
74
72
mLockAspectRatio ->setEnabled ( false );
75
73
mLockAspectRatio ->setLocked ( false );
76
74
mSizeUnitsComboBox ->setEnabled ( false );
77
75
mPageOrientationComboBox ->setEnabled ( true );
78
76
QgsPageSize size = QgsApplication::pageSizeRegistry ()->find ( mPageSizeComboBox ->currentData ().toString () ).value ( 0 );
79
77
QgsLayoutSize convertedSize = mConverter .convert ( size.size , mSizeUnitsComboBox ->unit () );
78
+ mSettingPresetSize = true ;
80
79
switch ( mPageOrientationComboBox ->currentData ().toInt () )
81
80
{
82
81
case QgsLayoutItemPage::Landscape:
@@ -89,6 +88,7 @@ void QgsLayoutPagePropertiesWidget::pageSizeChanged( int )
89
88
mHeightSpin ->setValue ( convertedSize.height () );
90
89
break ;
91
90
}
91
+ mSettingPresetSize = false ;
92
92
}
93
93
updatePageSize ();
94
94
}
@@ -128,6 +128,14 @@ void QgsLayoutPagePropertiesWidget::updatePageSize()
128
128
mPage ->layout ()->pageCollection ()->reflow ();
129
129
}
130
130
131
+ void QgsLayoutPagePropertiesWidget::setToCustomSize ()
132
+ {
133
+ if ( mSettingPresetSize )
134
+ return ;
135
+ whileBlocking ( mPageSizeComboBox )->setCurrentIndex ( mPageSizeComboBox ->count () - 1 );
136
+ mPageOrientationComboBox ->setEnabled ( false );
137
+ }
138
+
131
139
void QgsLayoutPagePropertiesWidget::showCurrentPageSize ()
132
140
{
133
141
QgsLayoutSize paperSize = mPage ->pageSize ();
0 commit comments