1 #include "XGUI_Command.h"
5 XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable)
6 : QWidgetAction(parent), myId(theId), myCheckable(isCheckable)
10 XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text,
11 QObject* parent, bool isCheckable)
12 : QWidgetAction(parent), myId(theId), myCheckable(isCheckable)
18 XGUI_Command::~XGUI_Command()
22 QWidget* XGUI_Command::createWidget(QWidget* theParent)
24 if (theParent->inherits("XGUI_MenuGroupPanel")) {
25 QPushButton* aButton = new QPushButton(theParent);
26 aButton->setIcon(icon());
27 aButton->setText(text());
28 aButton->setStyleSheet("text-align: left");
29 QKeySequence aKeys = shortcut();
30 QString aToolTip = toolTip();
32 aToolTip = aToolTip + " (" + aKeys.toString() + ")";
33 if (!aToolTip.isEmpty())
34 aButton->setToolTip(aToolTip);
36 aButton->addAction(this);
37 connect(aButton, SIGNAL(clicked()), this, SLOT(trigger()));
38 connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
39 aButton->setFlat(true);
40 aButton->setCheckable(myCheckable);
41 this->setCheckable(myCheckable);
42 aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
46 return QWidgetAction::createWidget(theParent);
49 bool XGUI_Command::enabled() const
54 void XGUI_Command::enable()
59 void XGUI_Command::disable()
64 void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
66 connect(this, SIGNAL(triggered(bool)), theResiver, theSlot);
69 const QStringList& XGUI_Command::unblockableCommands() const
71 return myUnblockableCommands;
74 void XGUI_Command::setUnblockableCommands(const QStringList& myUnblockableCommands)
76 this->myUnblockableCommands = myUnblockableCommands;