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;
28 * A class for management of actions (features) activation/deactivation
30 class XGUI_EXPORT XGUI_ActionsMgr : public QObject, public Events_Listener
36 /// \param theWorkshop an instance of workshop
37 XGUI_ActionsMgr(XGUI_Workshop* theWorkshop);
38 virtual ~XGUI_ActionsMgr();
40 //! Add a command in the manager.
41 //! Please note that nested commands in the Salome mode (No AppElements_Command, pure QActions)
42 //! won't be extracted and should be added manually using the addNestedCommands method.
43 void addCommand(QAction* theCmd);
45 //! Sets relation between the command (with given Id) and it's nested actions.
46 void addNestedCommands(const QString& theId, const QStringList& theCommands);
48 //! Returns list of nested commands by parent command Id
49 //! \param theId a parent command Id
50 QStringList nestedCommands(const QString& theId) const;
52 /// Returns True if the given Id is an Id of nested command
53 /// \param theId an Id to check
54 bool isNested(const QString& theId) const;
56 /// Registers shortcut (key sequence) for the command triggering
57 /// \param theKeySequence a key sequence to register
58 QKeySequence registerShortcut(const QString& theKeySequence);
60 //! Redefinition of Events_Listener method
61 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
64 //! Update workbench actions according to OperationMgr state:
65 //! No active operations: all actions but nested are available
66 //! There is active operation: current operation + it's nested
67 //! are enabled, all the rest is disabled. All active commands is checked.
69 //! Sets all commands checked if it's operation is active.
70 void updateCheckState();
71 //! Updates actions according to current selection in the viewer
72 void updateOnViewSelection();
75 //! Sets all actions to isEnabled state.
76 void setAllEnabled(bool isEnabled);
77 //! Sets all nested actions to isEnabled state for the command with given ID.
78 //! If ID is empty - all nested actions will be affected.
79 void setNestedCommandsEnabled(bool isEnabled, const QString& theParent = QString());
80 //! Sets to enabled state all siblings of the given operation and it's parents recursively
81 void setNestedStackEnabled(ModuleBase_Operation* theOperation);
82 //! Sets the action with theId to theChecked state.
83 void setActionChecked(const QString& theId, const bool theChecked);
84 //! Sets the action with theId to theEnabled state.
85 void setActionEnabled(const QString& theId, const bool theEnabled);
86 //! Updates actions according to their "document" tag
87 void updateByDocumentKind();
88 //! Asks plugins about their features state, using the Events system
89 void updateByPlugins(FeaturePtr theActiveFeature);
92 QMap<QString, QAction*> myActions;
93 QMap<QString, QStringList> myNestedActions;
94 QList<QKeySequence> myShortcuts;
96 XGUI_Workshop* myWorkshop;
97 XGUI_OperationMgr* myOperationMgr;
100 #endif /* XGUI_ACTIONSMGR_H_ */