Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / ModuleBase / ModuleBase_ActionInfo.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef MODULEBASE_ACTIONINFO_H_
22 #define MODULEBASE_ACTIONINFO_H_
23
24 #include <ModuleBase.h>
25 #include <Config_FeatureMessage.h>
26
27 #include <QAction>
28 #include <QIcon>
29 #include <QKeySequence>
30 #include <QFont>
31
32 #include <memory>
33
34 /*!
35  * Structure to pass info about QActions, AppElements_Commands, etc.
36  */
37 struct MODULEBASE_EXPORT ModuleBase_ActionInfo
38 {
39   QString id; //!< action's (command) id
40   bool checkable; //!< action's checkable state
41   bool checked; //!< action's checked state
42   bool enabled; //!< action's enabled state
43   bool visible; //!< action's visibility state
44
45   //! = true if the acton is a modal dialog box else property panel (==false by default)
46   bool modal;
47   QIcon icon; //!< action's icon
48   QString text; //!< action's text
49   QString iconText; //!< action's descriptive icon text
50   QString iconFile; //!< path to icon's file. Can not be initialized from QAction
51   QString toolTip; //!< action's tooltip
52   // QString statusTip;
53   // QString whatsThis;
54   QKeySequence shortcut; //!< action's primary shortcut key
55   QFont font; //!< action's text font
56
57  public:
58   //! Default constructor, \sa initDefault
59   ModuleBase_ActionInfo();
60   //! Initializes structure with default values, except text
61   ModuleBase_ActionInfo(const QString &text);
62   //! Initializes structure with default values, except icon and text
63   ModuleBase_ActionInfo(const QIcon &icon, const QString &text);
64   virtual ~ModuleBase_ActionInfo();
65
66   //! Fills itself with info from given \param theAction
67   void initFrom(QAction* theAction);
68   //! Fills itself with info from given \param theFeatureMessage
69   void initFrom(std::shared_ptr<Config_FeatureMessage> theFeatureMessage);
70
71  protected:
72   //! Initializes structure with default values, like QAction()
73   void initDefault();
74 };
75
76 typedef ModuleBase_ActionInfo ActionInfo;
77
78 #endif /* XGUI_ACTIONINFO_H_ */