1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 #ifndef XGUI_ContextMenuMgr_H
4 #define XGUI_ContextMenuMgr_H
13 class QContextMenuEvent;
18 * A claas wihich provides manement of context menu
20 class XGUI_EXPORT XGUI_ContextMenuMgr : public QObject
25 /// \param theParent a parent object
26 XGUI_ContextMenuMgr(XGUI_Workshop* theParent);
27 virtual ~XGUI_ContextMenuMgr();
29 /// Create all actions for context menus. It is called on creation of application
32 /// Returns action according to the given ID
33 /// \param theId an id of an action
34 QAction* action(const QString& theId) const;
36 QAction* actionByName(const QString& theName) const;
38 /// Returns list of registered actions Ids
39 QStringList actionIds() const;
41 /// update state of internal commands
42 void updateCommandsStatus();
44 /// Connect to object browser from workshop. Has to called at creation of viewer.
45 void connectObjectBrowser() const;
47 /// Connect to viewer from workshop. Has to called at creation of viewer.
48 void connectViewer() const;
50 /// Add menu atems for viewer into the given menu (used in SALOME mode)
51 /// \param theMenu a popup menu to be shown in the viewer
52 void addViewerItems(QMenu* theMenu) const;
55 /// Signal aabout triggered action
56 /// \param theId an id of triggered action
57 /// \param isChecked is checked flag
58 void actionTriggered(const QString& theId, bool isChecked);
60 void beforeContextMenu();
61 void afterContextMenu();
64 /// Process action event
65 /// \param isChecked a checked action flag
66 void onAction(bool isChecked);
68 /// Process context menu event
69 /// \param theEvent a context menu event
70 void onContextMenuRequest(QContextMenuEvent* theEvent);
75 * \param theId - string ID of the item
76 * \param theAction - action to add
78 void addAction(const QString& theId, QAction* theAction);
80 /// Creates menu for object browser
81 QMenu* objectBrowserMenu() const;
83 /// Creates menu for viewer
84 QMenu* viewerMenu() const;
86 /// Map of created actions [id : Action]
87 QMap<QString, QAction*> myActions;
89 /// Reference to workshop
90 XGUI_Workshop* myWorkshop;