Salome HOME
Issue #1005: To improve user-friendship of error-messages for features and attributes
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetAction.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModuleBase_WidgetAction.h
4 // Created:     15 Apr 2016
5 // Author:      Natalia Ermolaeva
6
7 #ifndef ModuleBase_WidgetAction_H
8 #define ModuleBase_WidgetAction_H
9
10 #include "ModuleBase.h"
11 #include "ModuleBase_ModelWidget.h"
12
13 class Config_WidgetAPI;
14 class QWidget;
15 class QToolButton;
16
17 /**
18 * \ingroup GUI
19 * Implementation of widget for feature action (tool button)
20 */ 
21 class MODULEBASE_EXPORT ModuleBase_WidgetAction : public ModuleBase_ModelWidget
22 {
23 Q_OBJECT
24  public:
25   /// Constructor
26   /// \param theParent the parent object
27   /// \param theData the widget configuation. The attribute of the model widget is obtained from
28   ModuleBase_WidgetAction(QWidget* theParent, const Config_WidgetAPI* theData);
29
30   virtual ~ModuleBase_WidgetAction();
31
32   /// Do not accept focus, returns false
33   virtual bool focusTo();
34
35   /// Returns list of widget controls
36   /// \return a control list
37   virtual QList<QWidget*> getControls() const;
38
39   /// \return Context for translation
40   virtual std::string context() const {
41     std::string aContext = myFeatureId;
42     if(!aContext.empty() && !myActionID.empty()) {
43       aContext += ":";
44     }
45     aContext += myActionID;
46
47     return aContext;
48   }
49
50 protected:
51   /// Do nothing
52   /// \return True in success
53   virtual bool storeValueCustom();
54
55   /// Do nothing
56   virtual bool restoreValueCustom();
57
58 protected slots:
59   /// Listens the button click and call the customAction function of the current feature
60   void onActionClicked();
61
62 private:
63   QToolButton* myButton; ///< action button
64   std::string myActionID; ///< action index
65 };
66
67 #endif