SHAPER 9.16.0
XGUI_ActionsMgr.h
1// Copyright (C) 2014-2026 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_ActionsMgr_H
21#define XGUI_ActionsMgr_H
22
23#include "XGUI.h"
24
25#include <Events_Listener.h>
26#include <ModelAPI_Feature.h>
27
28#include <ModuleBase_ActionInfo.h>
29
30#include <QObject>
31#include <QMap>
32#include <QList>
33#include <QStringList>
34#include <QKeySequence>
35
36class XGUI_Workshop;
39class QAction;
40
44class XGUI_EXPORT XGUI_ActionsMgr : public QObject, public Events_Listener
45{
46 Q_OBJECT
47
48 public:
51 XGUI_ActionsMgr(XGUI_Workshop* theWorkshop);
52 virtual ~XGUI_ActionsMgr();
53
56 Abort = 0,
57 Accept = 1,
58 AcceptPlus = 2,
59 Help = 3,
60 AbortAll = 4,
61 AcceptAll = 5,
62 Preview = 6
63 };
64
68 void addCommand(QAction* theCmd);
69
71 void addNestedCommands(const QString& theId, const QStringList& theCommands);
72
75 QStringList nestedCommands(const QString& theId) const;
76
79 bool isNested(const QString& theId) const;
80
83 QKeySequence registerShortcut(const QKeySequence& theKeySequence);
84
88 QKeySequence registerShortcut(const QString& theKeySequence);
89
91 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
92
95 QAction* operationStateAction(OperationStateActionId theId);
96
98 QAction* action(const QString& theId);
99
102 ActionInfo actionInfoById(const QString& theId);
103
104 private:
109 void updateCommandsStatus();
110
112 void updateCheckState();
113
115 void updateOnViewSelection();
116
118 void setAllEnabled();
119
122 void setNestedCommandsEnabled(bool isEnabled, const QString& theParent = QString());
123
125 void setNestedStackEnabled(ModuleBase_Operation* theOperation);
126
128 void setActionChecked(const QString& theId, const bool theChecked);
129
131 void setActionEnabled(const QString& theId, const bool theEnabled);
132
134 void updateByDocumentKind();
135
137 void updateByPlugins(FeaturePtr theActiveFeature);
138
141 QStringList allNestedCommands(ModuleBase_Operation* theOperation);
142
143 private:
144
145 QMap<QString, QAction*> myActions;
146 QMap<QString, QStringList> myNestedActions;
147 QMap<OperationStateActionId, QAction*> myOperationActions;
148 QList<QKeySequence> myShortcuts;
149
150 XGUI_Workshop* myWorkshop;
151 XGUI_OperationMgr* myOperationMgr;
152
153 friend class XGUI_Workshop;
154};
155
156#endif /* XGUI_ActionsMgr_H */
157
Base interface for any event listener.
Definition: Events_Listener.h:37
virtual EVENTS_EXPORT void processEvent(const std::shared_ptr< Events_Message > &theMessage)=0
This method is called by loop when the event is started to process.
Base class for all operations.
Definition: ModuleBase_Operation.h:53
class XGUI_ActionsMgrA class for management of actions (features) activation/deactivation
Definition: XGUI_ActionsMgr.h:45
OperationStateActionId
Actions on operations.
Definition: XGUI_ActionsMgr.h:55
Operation manager.
Definition: XGUI_OperationMgr.h:49
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:83
Definition: ModuleBase_ActionInfo.h:37