#include <QPushButton>
-XGUI_Command::XGUI_Command(const QString& theId, QObject * parent)
- : QWidgetAction(parent), myId(theId)
+XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable)
+ : QWidgetAction(parent), myCheckable(isCheckable)
{
+ setData(theId);
}
XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text,
- QObject* parent)
- : QWidgetAction(parent), myId(theId)
+ QObject* parent, bool isCheckable)
+ : QWidgetAction(parent), myCheckable(isCheckable)
{
setIcon(icon);
setText(text);
+ setData(theId);
}
XGUI_Command::~XGUI_Command()
QWidget* XGUI_Command::createWidget(QWidget* theParent)
{
if (theParent->inherits("XGUI_MenuGroupPanel")) {
- QPushButton* aBtn = new QPushButton(theParent);
- aBtn->setIcon(icon());
- aBtn->setText(text());
- aBtn->setStyleSheet("text-align: left");
+ QPushButton* aButton = new QPushButton(theParent);
+ aButton->setIcon(icon());
+ aButton->setText(text());
+ aButton->setStyleSheet("text-align: left");
QKeySequence aKeys = shortcut();
QString aToolTip = toolTip();
if (!aKeys.isEmpty())
aToolTip = aToolTip + " (" + aKeys.toString() + ")";
if (!aToolTip.isEmpty())
- aBtn->setToolTip(aToolTip);
+ aButton->setToolTip(aToolTip);
- aBtn->addAction(this);
- connect(aBtn, SIGNAL(clicked()), this, SLOT(trigger()));
- aBtn->setFlat(true);
- aBtn->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
- return aBtn;
+ aButton->addAction(this);
+ connect(aButton, SIGNAL(clicked()), this, SLOT(trigger()));
+ connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
+ aButton->setFlat(true);
+ aButton->setCheckable(myCheckable);
+ this->setCheckable(myCheckable);
+ aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
+
+ return aButton;
}
return QWidgetAction::createWidget(theParent);
}
-bool XGUI_Command::enabled() const
-{
- return isEnabled();
-}
-
-void XGUI_Command::enable()
+void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
{
- setEnabled(true);
+ connect(this, SIGNAL(triggered(bool)), theResiver, theSlot);
}
-void XGUI_Command::disable()
+const QStringList& XGUI_Command::unblockableCommands() const
{
- setEnabled(false);
+ return myUnblockableCommands;
}
-void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
+void XGUI_Command::setUnblockableCommands(const QStringList& myUnblockableCommands)
{
- connect(this, SIGNAL(triggered()), theResiver, theSlot);
+ this->myUnblockableCommands = myUnblockableCommands;
}