Skip to content

Commit

Permalink
Disable Add Preset menu if current style is already a preset
Browse files Browse the repository at this point in the history
Prevents duplicate entries which have unexpected behaviour
  • Loading branch information
nyalldawson committed Aug 20, 2015
1 parent d2282a7 commit 415aa83
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/app/qgsvisibilitypresets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ QgsVisibilityPresets::QgsVisibilityPresets()
mMenu->addAction( QgisApp::instance()->actionHideSelectedLayers() );
mMenu->addSeparator();

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

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

mActionAddPreset->setEnabled( !hasCurrent );
mActionRemoveCurrentPreset->setEnabled( hasCurrent );
}
1 change: 1 addition & 0 deletions src/app/qgsvisibilitypresets.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class APP_EXPORT QgsVisibilityPresets : public QObject

QMenu* mMenu;
QAction* mMenuSeparator;
QAction* mActionAddPreset;
QAction* mActionRemoveCurrentPreset;
QList<QAction*> mMenuPresetActions;
};
Expand Down

0 comments on commit 415aa83

Please sign in to comment.