X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FXGUI%2FXGUI_Command.cpp;h=b289f8014ec6b65c6efe2084978bebd0fe0a6068;hb=27f3f6a3fbbe1541d70ab399463afc903fd486f6;hp=4c4249c6ff905e3d430a753bd468e7445c0e1471;hpb=f09c9895be486d30c9aa48da040c3aeb3ccbaa74;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Command.cpp b/src/XGUI/XGUI_Command.cpp index 4c4249c6f..b289f8014 100644 --- a/src/XGUI/XGUI_Command.cpp +++ b/src/XGUI/XGUI_Command.cpp @@ -1,42 +1,68 @@ #include "XGUI_Command.h" -#include +#include -XGUI_Command::XGUI_Command(QObject * parent) : - QWidgetAction(parent) +XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable) + : QWidgetAction(parent), myCheckable(isCheckable) { + setData(theId); } -XGUI_Command::XGUI_Command(const QIcon& icon, const QString& text, QObject* parent): - QWidgetAction(parent) +XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text, + QObject* parent, bool isCheckable) + : QWidgetAction(parent), myCheckable(isCheckable) { - setIcon(icon); - setText(text); + setIcon(icon); + setText(text); + setData(theId); } - 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()); - 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; - } - return QWidgetAction::createWidget(theParent); -} \ No newline at end of file + if (theParent->inherits("XGUI_MenuGroupPanel")) { + QToolButton* aButton = new QToolButton(theParent); + aButton->setIcon(icon()); + aButton->setText(text()); + aButton->setStyleSheet("QToolButton::menu-indicator { image: none; }"); + aButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + aButton->setAutoRaise(true); + aButton->setArrowType(Qt::NoArrow); + aButton->setCheckable(myCheckable); + aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT); + aButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + QKeySequence aKeys = shortcut(); + QString aToolTip = toolTip(); + if (!aKeys.isEmpty()) + aToolTip = aToolTip + " (" + aKeys.toString() + ")"; + if (!aToolTip.isEmpty()) + aButton->setToolTip(aToolTip); + + aButton->addAction(this); + connect(aButton, SIGNAL(clicked()), this, SLOT(trigger())); + connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool))); + connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool))); + this->setCheckable(myCheckable); + + return aButton; + } + return QWidgetAction::createWidget(theParent); +} + +void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot) +{ + connect(this, SIGNAL(triggered(bool)), theResiver, theSlot); +} + +const QStringList& XGUI_Command::nestedCommands() const +{ + return myNestedCommands; +} + +void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands) +{ + this->myNestedCommands = myUnblockableCommands; +}