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 QKeySequence aKeys = shortcut();
31 QString aToolTip = toolTip();
32 if (!aKeys.isEmpty()) {
33 aToolTip = QString("%1 (%2)").arg(aToolTip).arg(aKeys.toString());
35 if (!aToolTip.isEmpty()) {
36 aButton->setToolTip(aToolTip);
38 aButton->setCheckable(myCheckable);
39 aButton->setAutoRaise(true);
40 aButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
41 aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
42 aButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
44 connect(aButton, SIGNAL(clicked()), this, SLOT(trigger()));
45 connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
46 this->setCheckable(myCheckable);
50 return QWidgetAction::createWidget(theParent);
53 void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
55 connect(this, SIGNAL(triggered(bool)), theResiver, theSlot);
58 const QStringList& XGUI_Command::nestedCommands() const
60 return myNestedCommands;
63 void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands)
65 this->myNestedCommands = myUnblockableCommands;