1 #include "XGUI_Command.h"
5 XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable)
6 : QWidgetAction(parent),
7 myCheckable(isCheckable)
12 XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text,
13 QObject* parent, bool isCheckable)
14 : QWidgetAction(parent),
15 myCheckable(isCheckable)
22 XGUI_Command::~XGUI_Command()
26 QWidget* XGUI_Command::createWidget(QWidget* theParent)
28 if (theParent->inherits("XGUI_MenuGroupPanel")) {
29 QToolButton* aButton = new QToolButton(theParent);
30 aButton->setIcon(icon());
31 aButton->setText(text());
32 QKeySequence aKeys = shortcut();
33 QString aToolTip = toolTip();
34 if (!aKeys.isEmpty()) {
35 aToolTip = QString("%1 (%2)").arg(aToolTip).arg(aKeys.toString());
37 if (!aToolTip.isEmpty()) {
38 aButton->setToolTip(aToolTip);
40 aButton->setCheckable(myCheckable);
41 aButton->setAutoRaise(true);
42 aButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
43 aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
44 aButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
46 connect(aButton, SIGNAL(clicked()), this, SLOT(trigger()));
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;