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());
52 aButton->setShortcut(aKeys);
54 if (!aToolTip.isEmpty()) {
55 aButton->setToolTip(aToolTip);
57 aButton->setCheckable(myCheckable);
58 aButton->setAutoRaise(true);
59 aButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
60 aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
61 aButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
63 connect(aButton, SIGNAL(clicked()), this, SLOT(trigger()));
64 connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
65 this->setCheckable(myCheckable);
69 return QWidgetAction::createWidget(theParent);
72 void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
74 connect(this, SIGNAL(triggered(bool)), theResiver, theSlot);
77 const QStringList& XGUI_Command::nestedCommands() const
79 return myNestedCommands;
82 void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands)
84 this->myNestedCommands = myUnblockableCommands;