Skip to content

Commit 94b63d1

Browse files
committedDec 17, 2017
Fix updating gui after undoing layout settings change
1 parent 2e68dd7 commit 94b63d1

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed
 

‎python/core/layout/qgslayout.sip

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,13 @@ Updates the scene bounds of the layout.
541541

542542
signals:
543543

544+
void changed();
545+
%Docstring
546+
Is emitted when properties of the layout change. This signal is only
547+
emitted for settings directly managed by the layout, and is not emitted
548+
when child items change.
549+
%End
550+
544551
void variablesChanged();
545552
%Docstring
546553
Emitted whenever the expression variables stored in the layout have been changed.

‎src/app/layout/qgslayoutpropertieswidget.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ QgsLayoutPropertiesWidget::QgsLayoutPropertiesWidget( QWidget *parent, QgsLayout
7474
connect( mReferenceMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutPropertiesWidget::referenceMapChanged );
7575

7676
mReferenceMapComboBox->setCurrentLayout( mLayout );
77-
mReferenceMapComboBox->setItem( mLayout->referenceMap() );
77+
78+
connect( mLayout, &QgsLayout::changed, this, &QgsLayoutPropertiesWidget::updateGui );
79+
updateGui();
80+
}
81+
82+
void QgsLayoutPropertiesWidget::updateGui()
83+
{
84+
whileBlocking( mReferenceMapComboBox )->setItem( mLayout->referenceMap() );
7885
}
7986

8087
void QgsLayoutPropertiesWidget::updateSnappingElements()

‎src/app/layout/qgslayoutpropertieswidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class QgsLayoutPropertiesWidget: public QgsPanelWidget, private Ui::QgsLayoutWid
3030

3131
private slots:
3232

33+
void updateGui();
34+
3335
void gridResolutionChanged( double d );
3436
void gridResolutionUnitsChanged( QgsUnitTypes::LayoutUnit unit );
3537
void gridOffsetXChanged( double d );

‎src/core/layout/qgslayout.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ class QgsLayoutUndoCommand: public QgsAbstractLayoutUndoCommand
624624
return;
625625
}
626626

627-
mLayout->readXmlLayoutSettings( stateDoc.documentElement().firstChild().toElement(), stateDoc, QgsReadWriteContext() );
627+
mLayout->readXmlLayoutSettings( stateDoc.documentElement(), stateDoc, QgsReadWriteContext() );
628628
mLayout->project()->setDirty( true );
629629
}
630630

@@ -753,6 +753,7 @@ bool QgsLayout::readXmlLayoutSettings( const QDomElement &layoutElement, const Q
753753
setName( layoutElement.attribute( QStringLiteral( "name" ) ) );
754754
setUnits( QgsUnitTypes::decodeLayoutUnit( layoutElement.attribute( QStringLiteral( "units" ) ) ) );
755755
mWorldFileMapId = layoutElement.attribute( QStringLiteral( "worldFileMap" ) );
756+
emit changed();
756757

757758
return true;
758759
}
@@ -848,13 +849,17 @@ bool QgsLayout::readXml( const QDomElement &layoutElement, const QDomDocument &d
848849
return object->readXml( layoutElement, document, context );
849850
};
850851

852+
blockSignals( true ); // defer changed signal to end
851853
readXmlLayoutSettings( layoutElement, document, context );
854+
blockSignals( false );
852855

853856
restore( mPageCollection.get() );
854857
restore( &mSnapper );
855858
restore( &mGridSettings );
856859
addItemsFromXml( layoutElement, document, context );
857860

861+
emit changed();
862+
858863
return true;
859864
}
860865

‎src/core/layout/qgslayout.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,13 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
582582

583583
signals:
584584

585+
/**
586+
* Is emitted when properties of the layout change. This signal is only
587+
* emitted for settings directly managed by the layout, and is not emitted
588+
* when child items change.
589+
*/
590+
void changed();
591+
585592
/**
586593
* Emitted whenever the expression variables stored in the layout have been changed.
587594
*/

0 commit comments

Comments
 (0)
Please sign in to comment.