1 #include "XGUI_Command.h"
7 XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable)
8 : QWidgetAction(parent),
9 myCheckable(isCheckable)
14 XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text,
15 QObject* parent, bool isCheckable)
16 : QWidgetAction(parent),
17 myCheckable(isCheckable)
24 XGUI_Command::~XGUI_Command()
28 QWidget* XGUI_Command::createWidget(QWidget* theParent)
30 if (theParent->inherits("XGUI_MenuGroupPanel")) {
31 QToolButton* aButton = new QToolButton(theParent);
32 aButton->setIcon(icon());
33 aButton->setText(text());
34 QKeySequence aKeys = shortcut();
35 QString aToolTip = toolTip();
36 if (!aKeys.isEmpty()) {
37 aToolTip = QString("%1 (%2)").arg(aToolTip).arg(aKeys.toString());
39 if (!aToolTip.isEmpty()) {
40 aButton->setToolTip(aToolTip);
42 aButton->setCheckable(myCheckable);
43 aButton->setAutoRaise(true);
44 aButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
45 aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
46 aButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
48 connect(aButton, SIGNAL(clicked()), this, SLOT(trigger()));
49 connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
50 this->setCheckable(myCheckable);
54 return QWidgetAction::createWidget(theParent);
57 void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
59 connect(this, SIGNAL(triggered(bool)), theResiver, theSlot);
62 const QStringList& XGUI_Command::nestedCommands() const
64 return myNestedCommands;
67 void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands)
69 this->myNestedCommands = myUnblockableCommands;