[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
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
%End

View File

@ -181,6 +181,8 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )
loadOverviewEntries();
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 );
}
@ -211,6 +213,8 @@ bool QgsLayoutMapWidget::setNewItem( QgsLayoutItem *item )
if ( mMapItem )
{
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 );
@ -221,6 +225,8 @@ bool QgsLayoutMapWidget::setNewItem( QgsLayoutItem *item )
if ( mMapItem )
{
connect( mMapItem, &QgsLayoutObject::changed, this, &QgsLayoutMapWidget::updateGuiElements );
connect( mMapItem, &QgsLayoutItemMap::extentChanged, mItemPropertiesWidget, &QgsLayoutItemPropertiesWidget::updateVariables );
connect( mMapItem, &QgsLayoutItemMap::mapRotationChanged, mItemPropertiesWidget, &QgsLayoutItemPropertiesWidget::updateVariables );
mOverviewFrameStyleButton->registerExpressionContextGenerator( mMapItem );
}

View File

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