1 #include "XGUI_Command.h"
5 XGUI_MenuButton::XGUI_MenuButton(const QIcon& theIcon,
6 const QString& theText,
8 : QPushButton(theIcon, theText, theParent)
12 setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
13 setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
14 QString aStyleSheet = "QPushButton { text-align: left; }";
15 //aStyleSheet += "QPushButton:hover { border: 1px solid gray; border-radius: 3px; }";
16 setStyleSheet(aStyleSheet);
17 installEventFilter(this);
20 //void XGUI_MenuButton::enterEvent(QEvent * event)
27 //void XGUI_MenuButton::leaveEvent(QEvent * event)
32 XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable)
33 : QWidgetAction(parent), myCheckable(isCheckable)
38 XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text,
39 QObject* parent, bool isCheckable)
40 : QWidgetAction(parent), myCheckable(isCheckable)
47 XGUI_Command::~XGUI_Command()
51 QWidget* XGUI_Command::createWidget(QWidget* theParent)
53 if (theParent->inherits("XGUI_MenuGroupPanel")) {
54 XGUI_MenuButton* aButton = new XGUI_MenuButton(icon(), text(), theParent);
55 aButton->setCheckable(myCheckable);
56 QKeySequence aKeys = shortcut();
57 QString aToolTip = toolTip();
59 aToolTip = aToolTip + " (" + aKeys.toString() + ")";
60 if (!aToolTip.isEmpty())
61 aButton->setToolTip(aToolTip);
63 aButton->addAction(this);
64 connect(aButton, SIGNAL(clicked()), this, SLOT(trigger()));
65 connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
66 connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
67 this->setCheckable(myCheckable);
71 return QWidgetAction::createWidget(theParent);
74 void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
76 connect(this, SIGNAL(triggered(bool)), theResiver, theSlot);
79 const QStringList& XGUI_Command::nestedCommands() const
81 return myNestedCommands;
84 void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands)
86 this->myNestedCommands = myUnblockableCommands;