Salome HOME
Testing GUI version
[modules/shaper.git] / src / XGUI / XGUI_Command.cpp
1 #include "XGUI_Command.h"
2
3 #include <QPushButton>
4
5 XGUI_Command::XGUI_Command(QObject * parent) :
6     QWidgetAction(parent)
7 {
8 }
9
10 XGUI_Command::XGUI_Command(const QIcon& icon, const QString& text, QObject* parent):
11     QWidgetAction(parent)
12 {
13     setIcon(icon);
14     setText(text);
15 }
16
17
18 XGUI_Command::~XGUI_Command()
19 {
20 }
21
22 QWidget* XGUI_Command::createWidget(QWidget* theParent)
23 {
24     if (theParent->inherits("XGUI_MenuGroupPanel")) {
25         QPushButton* aBtn = new QPushButton(theParent);
26         aBtn->setIcon(icon());
27         aBtn->setText(text());
28         QKeySequence aKeys = shortcut();
29         QString aToolTip = toolTip();
30         if (!aKeys.isEmpty())
31             aToolTip = aToolTip + " (" + aKeys.toString() + ")";
32         if (!aToolTip.isEmpty())
33             aBtn->setToolTip(aToolTip);
34
35         aBtn->addAction(this);
36         connect(aBtn, SIGNAL(clicked()), this, SLOT(trigger()));
37         aBtn->setFlat(true);
38         aBtn->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
39         return aBtn;
40     }
41     return QWidgetAction::createWidget(theParent);
42 }