[qet] qet/qet: [5283] Element editor and diagram editor : context menu display only enabled actions

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 5283
Author:   blacksun
Date:     2018-03-31 13:21:55 +0200 (Sat, 31 Mar 2018)
Log Message:
-----------
Element editor and diagram editor : context menu display only enabled actions

Modified Paths:
--------------
    trunk/sources/diagramview.cpp
    trunk/sources/editor/qetelementeditor.cpp

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2018-03-29 14:32:17 UTC (rev 5282)
+++ trunk/sources/diagramview.cpp	2018-03-31 11:21:55 UTC (rev 5283)
@@ -1144,8 +1144,15 @@
 			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();

Modified: trunk/sources/editor/qetelementeditor.cpp
===================================================================
--- trunk/sources/editor/qetelementeditor.cpp	2018-03-29 14:32:17 UTC (rev 5282)
+++ trunk/sources/editor/qetelementeditor.cpp	2018-03-31 11:21:55 UTC (rev 5283)
@@ -415,7 +415,8 @@
  * @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 @@
 		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);
  }
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/