1 #include "XGUI_Command.h"
7 XGUI_Command::XGUI_Command(const QString& theId,
8 const QString& theDocumentKind,
11 : QWidgetAction(parent),
12 myCheckable(isCheckable),
13 myDocumentKind(theDocumentKind)
18 XGUI_Command::XGUI_Command(const QString& theId,
19 const QString& theDocumentKind,
24 : QWidgetAction(parent),
25 myCheckable(isCheckable),
26 myDocumentKind(theDocumentKind)
33 XGUI_Command::~XGUI_Command()
37 const QString& XGUI_Command::documentKind() const
39 return myDocumentKind;
42 QWidget* XGUI_Command::createWidget(QWidget* theParent)
44 if (theParent->inherits("XGUI_MenuGroupPanel")) {
45 QToolButton* aButton = new QToolButton(theParent);
46 aButton->setIcon(icon());
47 aButton->setText(text());
48 QKeySequence aKeys = shortcut();
49 QString aToolTip = toolTip();
50 if (!aKeys.isEmpty()) {
51 aToolTip = QString("%1 (%2)").arg(aToolTip).arg(aKeys.toString());
53 if (!aToolTip.isEmpty()) {
54 aButton->setToolTip(aToolTip);
56 aButton->setCheckable(myCheckable);
57 aButton->setAutoRaise(true);
58 aButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
59 aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
60 aButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
62 connect(aButton, SIGNAL(clicked()), this, SLOT(trigger()));
63 connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
64 this->setCheckable(myCheckable);
68 return QWidgetAction::createWidget(theParent);
71 void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
73 connect(this, SIGNAL(triggered(bool)), theResiver, theSlot);
76 const QStringList& XGUI_Command::nestedCommands() const
78 return myNestedCommands;
81 void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands)
83 this->myNestedCommands = myUnblockableCommands;