1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
7 #ifndef XGUI_ACTIONSMGR_H_
8 #define XGUI_ACTIONSMGR_H_
15 #include <QStringList>
16 #include <QKeySequence>
19 class XGUI_OperationMgr;
20 class ModuleBase_Operation;
23 class XGUI_EXPORT XGUI_ActionsMgr : public QObject
28 XGUI_ActionsMgr(XGUI_Workshop* theWorkshop);
29 virtual ~XGUI_ActionsMgr();
31 //! Add a command in the manager.
32 //! Please note that nested commands in the Salome mode (No AppElements_Command, pure QActions)
33 //! won't be extracted and should be added manually using the addNestedCommands method.
34 void addCommand(QAction* theCmd);
35 //! Sets relation between the command (with given Id) and it's nested actions.
36 void addNestedCommands(const QString& theId, const QStringList& theCommands);
38 QStringList nestedCommands(const QString& theId) const;
40 bool isNested(const QString& theId) const;
42 QKeySequence registerShortcut(const QString& theKeySequence);
44 void updateByDocumentKind();
47 //! Update workbench actions according to OperationMgr state:
48 //! No active operations: all actions but nested are available
49 //! There is active operation: current operation + it's nested
50 //! are enabled, all the rest is disabled. All active commands is checked.
52 //! Sets all commands checked if it's operation is active.
53 void updateCheckState();
56 //! Sets all actions to isEnabled state.
57 void setAllEnabled(bool isEnabled);
58 //! Sets to isEnabled state all siblings of the given operation and it's parents recursively
59 void setNestedStackEnabled(ModuleBase_Operation* theOperation);
60 //! Sets all nested actions to isEnabled state for the command with given ID.
61 //! If ID is empty - all nested actions will be affected.
62 void setNestedCommandsEnabled(bool isEnabled, const QString& theParent = QString());
63 //! Sets the action with theId to theChecked state.
64 void setActionChecked(const QString& theId, const bool theChecked);
65 //! Sets the action with theId to theEnabled state.
66 void setActionEnabled(const QString& theId, const bool theEnabled);
69 QMap<QString, QAction*> myActions;
70 QMap<QString, QStringList> myNestedActions;
71 QList<QKeySequence> myShortcuts;
73 XGUI_Workshop* myWorkshop;
74 XGUI_OperationMgr* myOperationMgr;
77 #endif /* XGUI_ACTIONSMGR_H_ */