1 #include "XGUI_Command.h"
5 XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable)
6 : QWidgetAction(parent), myCheckable(isCheckable)
11 XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text,
12 QObject* parent, bool isCheckable)
13 : QWidgetAction(parent), myCheckable(isCheckable)
20 XGUI_Command::~XGUI_Command()
24 QWidget* XGUI_Command::createWidget(QWidget* theParent)
26 if (theParent->inherits("XGUI_MenuGroupPanel")) {
27 QPushButton* aButton = new QPushButton(theParent);
28 aButton->setIcon(icon());
29 aButton->setText(text());
30 aButton->setStyleSheet("text-align: left");
31 QKeySequence aKeys = shortcut();
32 QString aToolTip = toolTip();
34 aToolTip = aToolTip + " (" + aKeys.toString() + ")";
35 if (!aToolTip.isEmpty())
36 aButton->setToolTip(aToolTip);
38 aButton->addAction(this);
39 connect(aButton, SIGNAL(clicked()), this, SLOT(trigger()));
40 connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
41 connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
42 aButton->setFlat(true);
43 aButton->setCheckable(myCheckable);
44 this->setCheckable(myCheckable);
45 aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
49 return QWidgetAction::createWidget(theParent);
52 void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
54 connect(this, SIGNAL(triggered(bool)), theResiver, theSlot);
57 const QStringList& XGUI_Command::nestedCommands() const
59 return myNestedCommands;
62 void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands)
64 this->myNestedCommands = myUnblockableCommands;