[layouts] Update map settings variables in UI when map extent/rotation changes

Fixes #24136
This commit is contained in:
Nyall Dawson 2019-09-27 16:22:09 +10:00
parent 1afdd935cf
commit 86c83537f9
3 changed files with 20 additions and 1 deletions

View File

@ -195,6 +195,13 @@ Sets the layout item
%Docstring %Docstring
Sets the master layout associated with the item. Sets the master layout associated with the item.
.. versionadded:: 3.10
%End
void updateVariables();
%Docstring
Updates the variables widget, refreshing the values of variables shown.
.. versionadded:: 3.10 .. versionadded:: 3.10
%End %End

View File

@ -181,6 +181,8 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )
loadOverviewEntries(); loadOverviewEntries();
connect( mMapRotationSpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsLayoutMapWidget::rotationChanged ); connect( mMapRotationSpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, &QgsLayoutMapWidget::rotationChanged );
connect( mMapItem, &QgsLayoutItemMap::extentChanged, mItemPropertiesWidget, &QgsLayoutItemPropertiesWidget::updateVariables );
connect( mMapItem, &QgsLayoutItemMap::mapRotationChanged, mItemPropertiesWidget, &QgsLayoutItemPropertiesWidget::updateVariables );
blockAllSignals( false ); blockAllSignals( false );
} }
@ -211,6 +213,8 @@ bool QgsLayoutMapWidget::setNewItem( QgsLayoutItem *item )
if ( mMapItem ) if ( mMapItem )
{ {
disconnect( mMapItem, &QgsLayoutObject::changed, this, &QgsLayoutMapWidget::updateGuiElements ); disconnect( mMapItem, &QgsLayoutObject::changed, this, &QgsLayoutMapWidget::updateGuiElements );
disconnect( mMapItem, &QgsLayoutItemMap::extentChanged, mItemPropertiesWidget, &QgsLayoutItemPropertiesWidget::updateVariables );
disconnect( mMapItem, &QgsLayoutItemMap::mapRotationChanged, mItemPropertiesWidget, &QgsLayoutItemPropertiesWidget::updateVariables );
} }
mMapItem = qobject_cast< QgsLayoutItemMap * >( item ); mMapItem = qobject_cast< QgsLayoutItemMap * >( item );
@ -221,6 +225,8 @@ bool QgsLayoutMapWidget::setNewItem( QgsLayoutItem *item )
if ( mMapItem ) if ( mMapItem )
{ {
connect( mMapItem, &QgsLayoutObject::changed, this, &QgsLayoutMapWidget::updateGuiElements ); connect( mMapItem, &QgsLayoutObject::changed, this, &QgsLayoutMapWidget::updateGuiElements );
connect( mMapItem, &QgsLayoutItemMap::extentChanged, mItemPropertiesWidget, &QgsLayoutItemPropertiesWidget::updateVariables );
connect( mMapItem, &QgsLayoutItemMap::mapRotationChanged, mItemPropertiesWidget, &QgsLayoutItemPropertiesWidget::updateVariables );
mOverviewFrameStyleButton->registerExpressionContextGenerator( mMapItem ); mOverviewFrameStyleButton->registerExpressionContextGenerator( mMapItem );
} }

View File

@ -244,6 +244,13 @@ class GUI_EXPORT QgsLayoutItemPropertiesWidget: public QWidget, private Ui::QgsL
*/ */
void setMasterLayout( QgsMasterLayoutInterface *masterLayout ); void setMasterLayout( QgsMasterLayoutInterface *masterLayout );
/**
* Updates the variables widget, refreshing the values of variables shown.
*
* \since QGIS 3.10
*/
void updateVariables();
protected slots: protected slots:
//! Initializes data defined buttons to current atlas coverage layer //! Initializes data defined buttons to current atlas coverage layer
void initializeDataDefinedButtons(); void initializeDataDefinedButtons();
@ -302,7 +309,6 @@ class GUI_EXPORT QgsLayoutItemPropertiesWidget: public QWidget, private Ui::QgsL
void setValuesForGuiNonPositionElements(); void setValuesForGuiNonPositionElements();
void variablesChanged(); void variablesChanged();
void updateVariables();
private: private: