1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
7 #ifndef XGUI_ACTIONSMGR_H_
8 #define XGUI_ACTIONSMGR_H_
12 #include <Events_Listener.h>
13 #include <ModelAPI_Feature.h>
18 #include <QStringList>
19 #include <QKeySequence>
22 class XGUI_OperationMgr;
23 class ModuleBase_Operation;
26 class XGUI_EXPORT XGUI_ActionsMgr : public QObject, public Events_Listener
31 XGUI_ActionsMgr(XGUI_Workshop* theWorkshop);
32 virtual ~XGUI_ActionsMgr();
34 //! Add a command in the manager.
35 //! Please note that nested commands in the Salome mode (No AppElements_Command, pure QActions)
36 //! won't be extracted and should be added manually using the addNestedCommands method.
37 void addCommand(QAction* theCmd);
38 //! Sets relation between the command (with given Id) and it's nested actions.
39 void addNestedCommands(const QString& theId, const QStringList& theCommands);
41 QStringList nestedCommands(const QString& theId) const;
43 bool isNested(const QString& theId) const;
45 QKeySequence registerShortcut(const QString& theKeySequence);
47 //! Redefinition of Events_Listener method
48 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
51 //! Update workbench actions according to OperationMgr state:
52 //! No active operations: all actions but nested are available
53 //! There is active operation: current operation + it's nested
54 //! are enabled, all the rest is disabled. All active commands is checked.
56 //! Sets all commands checked if it's operation is active.
57 void updateCheckState();
58 //! Updates actions according to current selection in the viewer
59 void updateOnViewSelection();
62 //! Sets all actions to isEnabled state.
63 void setAllEnabled(bool isEnabled);
64 //! Sets all nested actions to isEnabled state for the command with given ID.
65 //! If ID is empty - all nested actions will be affected.
66 void setNestedCommandsEnabled(bool isEnabled, const QString& theParent = QString());
67 //! Sets to enabled state all siblings of the given operation and it's parents recursively
68 void setNestedStackEnabled(ModuleBase_Operation* theOperation);
69 //! Sets the action with theId to theChecked state.
70 void setActionChecked(const QString& theId, const bool theChecked);
71 //! Sets the action with theId to theEnabled state.
72 void setActionEnabled(const QString& theId, const bool theEnabled);
73 //! Updates actions according to their "document" tag
74 void updateByDocumentKind();
75 //! Asks plugins about their features state, using the Events system
76 void updateByPlugins(FeaturePtr theActiveFeature);
79 QMap<QString, QAction*> myActions;
80 QMap<QString, QStringList> myNestedActions;
81 QList<QKeySequence> myShortcuts;
83 XGUI_Workshop* myWorkshop;
84 XGUI_OperationMgr* myOperationMgr;
87 #endif /* XGUI_ACTIONSMGR_H_ */