Salome HOME
ac25c80ecacaf181dabfbdc6eae24676015b6b69
[modules/shaper.git] / src / XGUI / XGUI_MenuMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        XGUI_MenuMgr.hxx
4 // Created:     13 Apr 2016
5 // Author:      Natalia ERMOLAEVA
6
7 #ifndef XGUI_MENUMGR_H_
8 #define XGUI_MENUMGR_H_
9
10 #include "XGUI.h"
11
12 #include <Events_Listener.h>
13
14 #include <string>
15 #include <list>
16 #include <memory>
17
18 class XGUI_MenuWorkbench;
19 class XGUI_Workshop;
20 class Config_FeatureMessage;
21
22 class QAction;
23
24 /**
25 * \ingroup GUI
26 * A class for management of menu actions (features). The actions should be arranged like they are
27 * in XML file. It listens the read feature of XML and fills internal structure of menu workbenches
28 * and groups of feature. After, it creates menues and tools in the module.
29 */
30 class XGUI_MenuMgr : public Events_Listener
31 {
32  public:
33   /// Constructor
34   /// \param the current workshop
35   XGUI_EXPORT XGUI_MenuMgr(XGUI_Workshop* theWorkshop);
36   XGUI_EXPORT virtual ~XGUI_MenuMgr() {}
37
38   XGUI_EXPORT void createFeatureActions();
39
40   /// Redefinition of Events_Listener method
41   XGUI_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
42
43 protected:
44   /// Process event "Add a feature"
45   void addFeature(const std::shared_ptr<Config_FeatureMessage>& theMessage);
46
47   /// Finds or creates a workbench for the given name
48   /// \param theWorkbenchName a name defined in XML
49   /// \return an instance of workbench
50   std::shared_ptr<XGUI_MenuWorkbench> findWorkbench(const std::string& theWorkbenchName);
51
52   /// Creates a new action by the message
53   /// \param theMessage an XML information of the feature
54   /// \param theWchName a workbench name, will be used as menu/tool bar name
55   /// \param aUseSeparator boolean value if a separator should be added after the action
56   /// \return an action
57   QAction* buildAction(const std::shared_ptr<Config_FeatureMessage>& theMessage,
58                        const std::string& theWchName, const bool aUseSeparator) const;
59
60 private:
61   XGUI_Workshop* myWorkshop; /// the current workshop
62   std::list< std::shared_ptr<XGUI_MenuWorkbench> > myWorkbenches; /// container of existing workbenchs
63 };
64
65 #endif /* XGUI_MENUMGR_H_ */