X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Command.cpp;h=4f726ab5d442b62cc99675b5ffe0fc175ee138d4;hb=ed165fd07e71c11885fdc5f475a8522a5914e00d;hp=9b5dd7b9abfa4ea89a6e5e81f9e2ecbc529a0dab;hpb=f3c113af79cf08e90316b2d27303a0a12d93fddc;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Command.cpp b/src/XGUI/XGUI_Command.cpp index 9b5dd7b9a..4f726ab5d 100644 --- a/src/XGUI/XGUI_Command.cpp +++ b/src/XGUI/XGUI_Command.cpp @@ -1,77 +1,84 @@ #include "XGUI_Command.h" +#include +#include +#include +#include -#include - -XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable) - : QWidgetAction(parent), myId(theId), myCheckable(isCheckable) +XGUI_Command::XGUI_Command(const QString& theId, + const QString& theDocumentKind, + QObject * parent, + bool isCheckable) + : QWidgetAction(parent), + myCheckable(isCheckable), + myDocumentKind(theDocumentKind) { + setData(theId); } -XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text, - QObject* parent, bool isCheckable) - : QWidgetAction(parent), myId(theId), myCheckable(isCheckable) +XGUI_Command::XGUI_Command(const QString& theId, + const QString& theDocumentKind, + const QIcon& icon, + const QString& text, + QObject* parent, + bool isCheckable) + : QWidgetAction(parent), + myCheckable(isCheckable), + myDocumentKind(theDocumentKind) { setIcon(icon); setText(text); + setData(theId); } XGUI_Command::~XGUI_Command() { } +const QString& XGUI_Command::documentKind() const +{ + return myDocumentKind; +} + QWidget* XGUI_Command::createWidget(QWidget* theParent) { if (theParent->inherits("XGUI_MenuGroupPanel")) { - QPushButton* aButton = new QPushButton(theParent); + QToolButton* aButton = new QToolButton(theParent); aButton->setIcon(icon()); aButton->setText(text()); - aButton->setStyleSheet("text-align: left"); QKeySequence aKeys = shortcut(); QString aToolTip = toolTip(); - if (!aKeys.isEmpty()) - aToolTip = aToolTip + " (" + aKeys.toString() + ")"; - if (!aToolTip.isEmpty()) + 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); - aButton->addAction(this); connect(aButton, SIGNAL(clicked()), this, SLOT(trigger())); connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool))); - aButton->setFlat(true); - aButton->setCheckable(myCheckable); this->setCheckable(myCheckable); - aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT); return aButton; } return QWidgetAction::createWidget(theParent); } -bool XGUI_Command::enabled() const -{ - return isEnabled(); -} - -void XGUI_Command::enable() -{ - setEnabled(true); -} - -void XGUI_Command::disable() -{ - setEnabled(false); -} - void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot) { - connect(this, SIGNAL(triggered(bool)), theResiver, theSlot); + connect(this, SIGNAL(triggered(bool)), theResiver, theSlot); } -const QStringList& XGUI_Command::unblockableCommands() const +const QStringList& XGUI_Command::nestedCommands() const { - return myUnblockableCommands; + return myNestedCommands; } -void XGUI_Command::setUnblockableCommands(const QStringList& myUnblockableCommands) +void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands) { - this->myUnblockableCommands = myUnblockableCommands; + this->myNestedCommands = myUnblockableCommands; }