mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Fix some multiple updates from gui, squash some undo commands
This commit is contained in:
parent
db17c2c43a
commit
8f0144b32b
@ -81,6 +81,7 @@ QgsLayoutPagePropertiesWidget::QgsLayoutPagePropertiesWidget( QWidget *parent, Q
|
||||
|
||||
void QgsLayoutPagePropertiesWidget::pageSizeChanged( int )
|
||||
{
|
||||
mBlockPageUpdate = true;
|
||||
if ( mPageSizeComboBox->currentData().toString().isEmpty() )
|
||||
{
|
||||
//custom size
|
||||
@ -111,6 +112,7 @@ void QgsLayoutPagePropertiesWidget::pageSizeChanged( int )
|
||||
}
|
||||
mSettingPresetSize = false;
|
||||
}
|
||||
mBlockPageUpdate = false;
|
||||
updatePageSize();
|
||||
}
|
||||
|
||||
@ -145,12 +147,17 @@ void QgsLayoutPagePropertiesWidget::orientationChanged( int )
|
||||
|
||||
void QgsLayoutPagePropertiesWidget::updatePageSize()
|
||||
{
|
||||
if ( mBlockPageUpdate )
|
||||
return;
|
||||
|
||||
mPage->layout()->undoStack()->beginMacro( tr( "Change Page Size" ) );
|
||||
mPage->layout()->pageCollection()->beginPageSizeChange();
|
||||
mPage->layout()->undoStack()->beginCommand( mPage, tr( "Change Page Size" ), 1 + mPage->layout()->pageCollection()->pageNumber( mPage ) );
|
||||
mPage->setPageSize( QgsLayoutSize( mWidthSpin->value(), mHeightSpin->value(), mSizeUnitsComboBox->unit() ) );
|
||||
mPage->layout()->undoStack()->endCommand();
|
||||
mPage->layout()->pageCollection()->reflow();
|
||||
mPage->layout()->pageCollection()->endPageSizeChange();
|
||||
mPage->layout()->undoStack()->endMacro();
|
||||
}
|
||||
|
||||
void QgsLayoutPagePropertiesWidget::setToCustomSize()
|
||||
@ -186,7 +193,7 @@ void QgsLayoutPagePropertiesWidget::showCurrentPageSize()
|
||||
QString pageSize = QgsApplication::pageSizeRegistry()->find( paperSize );
|
||||
if ( !pageSize.isEmpty() )
|
||||
{
|
||||
mPageSizeComboBox->setCurrentIndex( mPageSizeComboBox->findData( pageSize ) );
|
||||
whileBlocking( mPageSizeComboBox )->setCurrentIndex( mPageSizeComboBox->findData( pageSize ) );
|
||||
mLockAspectRatio->setEnabled( false );
|
||||
mLockAspectRatio->setLocked( false );
|
||||
mSizeUnitsComboBox->setEnabled( false );
|
||||
@ -195,7 +202,7 @@ void QgsLayoutPagePropertiesWidget::showCurrentPageSize()
|
||||
else
|
||||
{
|
||||
// custom
|
||||
mPageSizeComboBox->setCurrentIndex( mPageSizeComboBox->count() - 1 );
|
||||
whileBlocking( mPageSizeComboBox )->setCurrentIndex( mPageSizeComboBox->count() - 1 );
|
||||
mLockAspectRatio->setEnabled( true );
|
||||
mSizeUnitsComboBox->setEnabled( true );
|
||||
mPageOrientationComboBox->setEnabled( false );
|
||||
|
@ -58,6 +58,7 @@ class QgsLayoutPagePropertiesWidget : public QgsLayoutItemBaseWidget, private Ui
|
||||
QgsLayoutMeasurementConverter mConverter;
|
||||
|
||||
bool mSettingPresetSize = false;
|
||||
bool mBlockPageUpdate = false;
|
||||
|
||||
void showCurrentPageSize();
|
||||
|
||||
|
@ -700,10 +700,12 @@ QList<QgsLayoutItem *> QgsLayout::ungroupItems( QgsLayoutItemGroup *group )
|
||||
|
||||
void QgsLayout::refresh()
|
||||
{
|
||||
mUndoStack->blockCommands( true );
|
||||
mPageCollection->beginPageSizeChange();
|
||||
emit refreshed();
|
||||
mPageCollection->reflow();
|
||||
mPageCollection->endPageSizeChange();
|
||||
mUndoStack->blockCommands( false );
|
||||
update();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user