Salome HOME
A sketcher operations manager is created
[modules/shaper.git] / src / XGUI / XGUI_ContextMenuMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 #ifndef XGUI_ContextMenuMgr_H
4 #define XGUI_ContextMenuMgr_H
5
6 #include "XGUI.h"
7
8 #include <QObject>
9 #include <QMap>
10
11 class XGUI_Workshop;
12 class QAction;
13 class QContextMenuEvent;
14 class QMenu;
15
16 /**
17  * A claas wihich provides manement of context menu
18  */
19 class XGUI_EXPORT XGUI_ContextMenuMgr : public QObject
20 {
21 Q_OBJECT
22  public:
23   XGUI_ContextMenuMgr(XGUI_Workshop* theParent);
24   virtual ~XGUI_ContextMenuMgr();
25
26   /// Create all actions for context menus. It is called on creation of application
27   void createActions();
28
29   /// Returns action according to the given ID
30   QAction* action(const QString& theId) const;
31
32   /// Returns list of registered actions Ids
33   QStringList actionIds() const;
34
35   /// update state of internal commands
36   void updateCommandsStatus();
37
38   /// Connect to object browser from workshop. Has to called at creation of viewer.
39   void connectObjectBrowser() const;
40
41   /// Connect to viewer from workshop. Has to called at creation of viewer.
42   void connectViewer() const;
43
44   /// Add menu atems for viewer into the given menu (used in SALOME mode)
45   void addViewerItems(QMenu* theMenu) const;
46
47 signals:
48   void actionTriggered(const QString& theId, bool isChecked);
49
50  private slots:
51   void onAction(bool isChecked);
52
53   void onContextMenuRequest(QContextMenuEvent* theEvent);
54
55  private:
56   /** 
57    * Add action
58    * \param theId - string ID of the item
59    * \param theAction - action to add
60    */
61   void addAction(const QString& theId, QAction* theAction);
62
63   QMenu* objectBrowserMenu() const;
64   QMenu* viewerMenu() const;
65
66   QMap<QString, QAction*> myActions;
67
68   XGUI_Workshop* myWorkshop;
69 };
70
71 #endif