Skip to content
Permalink
Browse files

[layouts] Fix map item loses preset them choice if item is selected

when a map theme is renamed or changed

(cherry picked from commit 34f4d1f)
  • Loading branch information
nyalldawson committed Mar 19, 2021
1 parent f8d4a27 commit 15c6bec1347b03ea2512d3c3a8ffc2d12d4967dd
Showing with 6 additions and 0 deletions.
  1. +5 −0 src/gui/layout/qgslayoutmapwidget.cpp
  2. +1 −0 src/gui/layout/qgslayoutmapwidget.h
@@ -314,6 +314,9 @@ void QgsLayoutMapWidget::followVisibilityPresetSelected( int currentIndex )
if ( !mMapItem )
return;

if ( mBlockThemeComboChanges != 0 )
return;

if ( currentIndex == -1 )
return; // doing combo box model reset

@@ -361,6 +364,7 @@ void QgsLayoutMapWidget::onMapThemesChanged()
{
if ( QStringListModel *model = qobject_cast<QStringListModel *>( mFollowVisibilityPresetCombo->model() ) )
{
mBlockThemeComboChanges++;
QStringList lst;
lst.append( tr( "(none)" ) );
lst += QgsProject::instance()->mapThemeCollection()->mapThemes();
@@ -371,6 +375,7 @@ void QgsLayoutMapWidget::onMapThemesChanged()
mFollowVisibilityPresetCombo->blockSignals( true );
mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 ); // 0 == none
mFollowVisibilityPresetCombo->blockSignals( false );
mBlockThemeComboChanges--;
}
}

@@ -152,6 +152,7 @@ class GUI_EXPORT QgsLayoutMapWidget: public QgsLayoutItemBaseWidget, private Ui:
QMenu *mBookmarkMenu = nullptr;
QgsBookmarkManagerProxyModel *mBookmarkModel = nullptr;
QString mReportTypeString;
int mBlockThemeComboChanges = 0;

//! Sets extent of composer map from line edits
void updateComposerExtentFromGui();

0 comments on commit 15c6bec

Please sign in to comment.