Salome HOME
Merge branch 'master' into Dev_1.1.0
[modules/shaper.git] / src / ModuleBase / ModuleBase_ActionInfo.h
1 /*
2  * ActionInfo.h
3  *
4  *  Created on: Feb 4, 2015
5  *      Author: sbh
6  */
7
8 #ifndef MODULEBASE_ACTIONINFO_H_
9 #define MODULEBASE_ACTIONINFO_H_
10
11 #include <ModuleBase.h>
12 #include <Config_FeatureMessage.h>
13
14 #include <QAction>
15 #include <QIcon>
16 #include <QKeySequence>
17 #include <QFont>
18
19 #include <memory>
20
21 /*!
22  * Structure to pass info about QActions, AppElements_Commands, etc.
23  */
24 struct MODULEBASE_EXPORT ModuleBase_ActionInfo
25 {
26   QString id;
27
28   bool checkable; //!< action's checkable state
29   bool checked; //!< action's checked state
30   bool enabled; //!< action's enabled state
31   bool visible; //!< action's visibility state
32   QIcon icon; //!< action's icon
33   QString text; //!< action's text
34   QString iconText; //!< action's descriptive icon text
35   QString iconFile; //!< path to icon's file. Can not be initialized from QAction
36   QString toolTip; //!< action's tooltip
37   // QString statusTip;
38   // QString whatsThis;
39   QKeySequence shortcut; //!< action's primary shortcut key
40   QFont font; //!< action's text font
41
42  public:
43   //! Default constructor, \sa initDefault
44   ModuleBase_ActionInfo();
45   //! Initializes structure with default values, except text
46   ModuleBase_ActionInfo(const QString &text);
47   //! Initializes structure with default values, except icon and text
48   ModuleBase_ActionInfo(const QIcon &icon, const QString &text);
49   virtual ~ModuleBase_ActionInfo();
50
51   //! Fills itself with info from given \param theAction
52   void initFrom(QAction* theAction);
53   //! Fills itself with info from given \param theFeatureMessage
54   void initFrom(std::shared_ptr<Config_FeatureMessage> theFeatureMessage);
55   //! Creates new QAction with given parent and data initialized from this structure
56   //! \param theParent - parent of created action
57   QAction* makeAction(QObject* theParent = 0);
58
59  protected:
60   //! Initializes structure with default values, like QAction()
61   void initDefault();
62 };
63
64 typedef ModuleBase_ActionInfo ActionInfo;
65
66 #endif /* XGUI_ACTIONINFO_H_ */