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 aButton->setFlat(true);
42 aButton->setCheckable(myCheckable);
43 this->setCheckable(myCheckable);
44 aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
48 return QWidgetAction::createWidget(theParent);
51 void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
53 connect(this, SIGNAL(triggered(bool)), theResiver, theSlot);
56 const QStringList& XGUI_Command::unblockableCommands() const
58 return myUnblockableCommands;
61 void XGUI_Command::setUnblockableCommands(const QStringList& myUnblockableCommands)
63 this->myUnblockableCommands = myUnblockableCommands;