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 QToolButton* aButton = new QToolButton(theParent);
28 aButton->setIcon(icon());
29 aButton->setText(text());
30 aButton->setStyleSheet("QToolButton::menu-indicator { image: none; }");
31 aButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
32 aButton->setAutoRaise(true);
33 aButton->setArrowType(Qt::NoArrow);
34 aButton->setCheckable(myCheckable);
35 aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
36 aButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
37 QKeySequence aKeys = shortcut();
38 QString aToolTip = toolTip();
40 aToolTip = aToolTip + " (" + aKeys.toString() + ")";
41 if (!aToolTip.isEmpty())
42 aButton->setToolTip(aToolTip);
44 aButton->addAction(this);
45 connect(aButton, SIGNAL(clicked()), this, SLOT(trigger()));
46 connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
47 connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
48 this->setCheckable(myCheckable);
52 return QWidgetAction::createWidget(theParent);
55 void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
57 connect(this, SIGNAL(triggered(bool)), theResiver, theSlot);
60 const QStringList& XGUI_Command::nestedCommands() const
62 return myNestedCommands;
65 void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands)
67 this->myNestedCommands = myUnblockableCommands;