Skip to content

Commit 415aa83

Browse files
committed
Disable Add Preset menu if current style is already a preset
Prevents duplicate entries which have unexpected behaviour
1 parent d2282a7 commit 415aa83

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/app/qgsvisibilitypresets.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ QgsVisibilityPresets::QgsVisibilityPresets()
4444
mMenu->addAction( QgisApp::instance()->actionHideSelectedLayers() );
4545
mMenu->addSeparator();
4646

47-
mMenu->addAction( tr( "Add Preset..." ), this, SLOT( addPreset() ) );
47+
mActionAddPreset = mMenu->addAction( tr( "Add Preset..." ), this, SLOT( addPreset() ) );
4848
mMenuSeparator = mMenu->addSeparator();
4949

5050
mActionRemoveCurrentPreset = mMenu->addAction( tr( "Remove Current Preset" ), this, SLOT( removeCurrentPreset() ) );
@@ -263,5 +263,6 @@ void QgsVisibilityPresets::menuAboutToShow()
263263
}
264264
mMenu->insertActions( mMenuSeparator, mMenuPresetActions );
265265

266+
mActionAddPreset->setEnabled( !hasCurrent );
266267
mActionRemoveCurrentPreset->setEnabled( hasCurrent );
267268
}

src/app/qgsvisibilitypresets.h

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class APP_EXPORT QgsVisibilityPresets : public QObject
8787

8888
QMenu* mMenu;
8989
QAction* mMenuSeparator;
90+
QAction* mActionAddPreset;
9091
QAction* mActionRemoveCurrentPreset;
9192
QList<QAction*> mMenuPresetActions;
9293
};

0 commit comments

Comments
 (0)