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