Salome HOME
380b64ae4b8ce90eb1761995cc724d67dc5f81ca
[modules/shaper.git] / src / XGUI / XGUI_Command.h
1 #ifndef XGUI_Command_H
2 #define XGUI_Command_H
3
4 #include "XGUI.h"
5 #include <QWidgetAction>
6
7 #define MIN_BUTTON_HEIGHT 18
8 #define MIN_BUTTON_WIDTH 40
9
10 /**\class XGUI_Command
11  * \ingroup GUI
12  * \brief Represents a command item in the application menu (Workbench)
13  */
14 class XGUI_EXPORT XGUI_Command: public QWidgetAction
15 {
16 Q_OBJECT
17 public:
18   XGUI_Command(const QString& theId, QObject * parent, bool isCheckable = false);
19   XGUI_Command(const QString& theId, const QIcon& icon, const QString& text, QObject* parent, bool isCheckable = false);
20   ~XGUI_Command();
21
22   //! Returns true if the command is enabled
23   virtual bool enabled() const;
24
25   //! Set the command enabled
26   virtual void enable();
27
28   //! Set the command disabled
29   virtual void disable();
30
31   //! Returns Id of the command
32   virtual QString id() const
33   {
34     return myId;
35   }
36
37   const QStringList& unblockableCommands() const;
38   void setUnblockableCommands(const QStringList& myUnblockableCommands);
39
40   //! Connect the command to a slot
41   virtual void connectTo(const QObject* theResiver, const char* theSlot);
42
43 protected:
44   //! Creates a command representation widget dependently on parent widget type
45   virtual QWidget* createWidget(QWidget* theParent);
46
47 private:
48   QString myId;
49   bool myCheckable;
50   //! List of Ids of commands which WILL NOT be blocked when the command is on.
51   QStringList myUnblockableCommands;
52 };
53
54 #endif