X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FXGUI%2FXGUI_Command.cpp;h=59df312b1e3338caf61be7232afe89797af4c5da;hb=dbe90044b0b96aa64dfe6609083413da2bdf08ec;hp=5e9ffb8fb8113df363de9eaa668aa6cb2d5a669d;hpb=3a272fa1aff115d8ff8744d54a09bc7f2d5576b4;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Command.cpp b/src/XGUI/XGUI_Command.cpp index 5e9ffb8fb..59df312b1 100644 --- a/src/XGUI/XGUI_Command.cpp +++ b/src/XGUI/XGUI_Command.cpp @@ -1,18 +1,22 @@ #include "XGUI_Command.h" +#include +#include -#include - -XGUI_Command::XGUI_Command(const QString& theId, QObject * parent) - : QWidgetAction(parent), myId(theId) +XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable) + : QWidgetAction(parent), + myCheckable(isCheckable) { + setData(theId); } XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text, - QObject* parent) - : QWidgetAction(parent), myId(theId) + QObject* parent, bool isCheckable) + : QWidgetAction(parent), + myCheckable(isCheckable) { setIcon(icon); setText(text); + setData(theId); } XGUI_Command::~XGUI_Command() @@ -22,42 +26,43 @@ XGUI_Command::~XGUI_Command() QWidget* XGUI_Command::createWidget(QWidget* theParent) { if (theParent->inherits("XGUI_MenuGroupPanel")) { - QPushButton* aBtn = new QPushButton(theParent); - aBtn->setIcon(icon()); - aBtn->setText(text()); - aBtn->setStyleSheet("text-align: left"); + QToolButton* aButton = new QToolButton(theParent); + aButton->setIcon(icon()); + aButton->setText(text()); QKeySequence aKeys = shortcut(); QString aToolTip = toolTip(); - if (!aKeys.isEmpty()) - aToolTip = aToolTip + " (" + aKeys.toString() + ")"; - if (!aToolTip.isEmpty()) - aBtn->setToolTip(aToolTip); - - aBtn->addAction(this); - connect(aBtn, SIGNAL(clicked()), this, SLOT(trigger())); - aBtn->setFlat(true); - aBtn->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT); - return aBtn; + if (!aKeys.isEmpty()) { + aToolTip = QString("%1 (%2)").arg(aToolTip).arg(aKeys.toString()); + } + if (!aToolTip.isEmpty()) { + aButton->setToolTip(aToolTip); + } + aButton->setCheckable(myCheckable); + aButton->setAutoRaise(true); + aButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT); + aButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + + connect(aButton, SIGNAL(clicked()), this, SLOT(trigger())); + connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool))); + this->setCheckable(myCheckable); + + return aButton; } return QWidgetAction::createWidget(theParent); } -bool XGUI_Command::enabled() const -{ - return isEnabled(); -} - -void XGUI_Command::enable() +void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot) { - setEnabled(true); + connect(this, SIGNAL(triggered(bool)), theResiver, theSlot); } -void XGUI_Command::disable() +const QStringList& XGUI_Command::nestedCommands() const { - setEnabled(false); + return myNestedCommands; } -void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot) +void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands) { - connect(this, SIGNAL(triggered()), theResiver, theSlot); + this->myNestedCommands = myUnblockableCommands; }