@@ -81,6 +81,7 @@ QgsLayoutPagePropertiesWidget::QgsLayoutPagePropertiesWidget( QWidget *parent, Q
81
81
82
82
void QgsLayoutPagePropertiesWidget::pageSizeChanged ( int )
83
83
{
84
+ mBlockPageUpdate = true ;
84
85
if ( mPageSizeComboBox ->currentData ().toString ().isEmpty () )
85
86
{
86
87
// custom size
@@ -111,6 +112,7 @@ void QgsLayoutPagePropertiesWidget::pageSizeChanged( int )
111
112
}
112
113
mSettingPresetSize = false ;
113
114
}
115
+ mBlockPageUpdate = false ;
114
116
updatePageSize ();
115
117
}
116
118
@@ -145,12 +147,17 @@ void QgsLayoutPagePropertiesWidget::orientationChanged( int )
145
147
146
148
void QgsLayoutPagePropertiesWidget::updatePageSize ()
147
149
{
150
+ if ( mBlockPageUpdate )
151
+ return ;
152
+
153
+ mPage ->layout ()->undoStack ()->beginMacro ( tr ( " Change Page Size" ) );
148
154
mPage ->layout ()->pageCollection ()->beginPageSizeChange ();
149
155
mPage ->layout ()->undoStack ()->beginCommand ( mPage , tr ( " Change Page Size" ), 1 + mPage ->layout ()->pageCollection ()->pageNumber ( mPage ) );
150
156
mPage ->setPageSize ( QgsLayoutSize ( mWidthSpin ->value (), mHeightSpin ->value (), mSizeUnitsComboBox ->unit () ) );
151
157
mPage ->layout ()->undoStack ()->endCommand ();
152
158
mPage ->layout ()->pageCollection ()->reflow ();
153
159
mPage ->layout ()->pageCollection ()->endPageSizeChange ();
160
+ mPage ->layout ()->undoStack ()->endMacro ();
154
161
}
155
162
156
163
void QgsLayoutPagePropertiesWidget::setToCustomSize ()
@@ -186,7 +193,7 @@ void QgsLayoutPagePropertiesWidget::showCurrentPageSize()
186
193
QString pageSize = QgsApplication::pageSizeRegistry ()->find ( paperSize );
187
194
if ( !pageSize.isEmpty () )
188
195
{
189
- mPageSizeComboBox ->setCurrentIndex ( mPageSizeComboBox ->findData ( pageSize ) );
196
+ whileBlocking ( mPageSizeComboBox ) ->setCurrentIndex ( mPageSizeComboBox ->findData ( pageSize ) );
190
197
mLockAspectRatio ->setEnabled ( false );
191
198
mLockAspectRatio ->setLocked ( false );
192
199
mSizeUnitsComboBox ->setEnabled ( false );
@@ -195,7 +202,7 @@ void QgsLayoutPagePropertiesWidget::showCurrentPageSize()
195
202
else
196
203
{
197
204
// custom
198
- mPageSizeComboBox ->setCurrentIndex ( mPageSizeComboBox ->count () - 1 );
205
+ whileBlocking ( mPageSizeComboBox ) ->setCurrentIndex ( mPageSizeComboBox ->count () - 1 );
199
206
mLockAspectRatio ->setEnabled ( true );
200
207
mSizeUnitsComboBox ->setEnabled ( true );
201
208
mPageOrientationComboBox ->setEnabled ( false );
0 commit comments