Element editor and diagram editor : context menu display only enabled actions

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5283 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2018-03-31 11:21:55 +00:00
parent 819c6c6f86
commit 250b2d42fe
2 changed files with 19 additions and 3 deletions

View File

@@ -1144,8 +1144,15 @@ void DiagramView::contextMenuEvent(QContextMenuEvent *e) {
m_context_menu -> addSeparator();
m_context_menu -> addActions(qde -> m_selection_actions_group.actions());
}
// affiche le menu contextuel
//Remove from the context menu the actions which are disabled.
const QList<QAction *> actions = m_context_menu->actions();
for(QAction *action : actions)
{
if(!action->isEnabled())
m_context_menu->removeAction(action);
}
m_context_menu -> popup(e -> globalPos());
}
e -> accept();

View File

@@ -415,7 +415,8 @@ void QETElementEditor::setupMenus() {
* @brief QETElementEditor::contextMenuEvent
* @param event
*/
void QETElementEditor::contextMenu(QPoint p) {
void QETElementEditor::contextMenu(QPoint p)
{
QMenu menu(this);
menu.addAction(undo);
menu.addAction(redo);
@@ -432,6 +433,14 @@ void QETElementEditor::contextMenu(QPoint p) {
menu.addMenu(paste_from_menu);
menu.addSeparator();
menu.addActions(m_depth_ag -> actions());
//Remove from the context menu the actions which are disabled.
const QList<QAction *>actions = menu.actions();
for(QAction *action : actions)
{
if(!action->isEnabled())
menu.removeAction(action);
}
menu.exec(p);
}