SHAPER  9.12.0
XGUI_ContextMenuMgr.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef XGUI_ContextMenuMgr_H
21 #define XGUI_ContextMenuMgr_H
22 
23 #include "XGUI.h"
24 
25 #include <QObject>
26 #include <QMap>
27 
28 class XGUI_Workshop;
29 class QAction;
30 class QContextMenuEvent;
31 class QMenu;
32 class QActionGroup;
33 
38 class XGUI_EXPORT XGUI_ContextMenuMgr : public QObject
39 {
40 Q_OBJECT
41  public:
45  virtual ~XGUI_ContextMenuMgr();
46 
48  void createActions();
49 
52  QAction* action(const QString& theId) const;
53 
56  QAction* actionByName(const QString& theName) const;
57 
59  QStringList actionIds() const;
60 
62  void updateCommandsStatus();
63 
65  void connectObjectBrowser();
66 
68  void connectViewer();
69 
71  void addObjBrowserMenu(QMenu*) const;
72 
74  void addViewerMenu(QMenu*) const;
75 
79  QStringList actionObjectGroups(const QString& theName);
80 
82  void updateObjectBrowserMenu();
83 
85  void updateViewerMenu();
86 
87 signals:
91  void actionTriggered(const QString& theId, bool isChecked);
92 
95 
98 
99  private slots:
102  void onAction(bool isChecked);
103 
106  void onContextMenuRequest(QContextMenuEvent* theEvent);
107 
108  void onRename();
109 
111  void onResultSelection(bool theChecked);
112 
114  void onShapeSelection(bool theChecked);
115 
116  private:
122  void addAction(const QString& theId, QAction* theAction);
123 
124  void addFeatures(QMenu* theMenu) const;
125 
127  void buildObjBrowserMenu();
128 
130  void buildViewerMenu();
131 
133  QMap<QString, QAction*> myActions;
134 
136  XGUI_Workshop* myWorkshop;
137 
138  typedef QList<QAction*> QActionsList;
139  QMap<std::string, QActionsList> myObjBrowserMenus;
140  QMap<std::string, QActionsList> myViewerMenu;
141 
142  //QActionGroup* mySelectActions;
143 
144  QAction* mySeparator1;
145  QAction* mySeparator2;
146  QAction* mySeparator3;
147  QAction* mySeparator4;
148 };
149 
150 #endif
A class wihich provides managent of context menu.
Definition: XGUI_ContextMenuMgr.h:39
void actionTriggered(const QString &theId, bool isChecked)
Signal aabout triggered action.
void afterContextMenu()
A signal which is sent after context menu show.
void beforeContextMenu()
A signal which is sent before context menu show.
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:82