X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Command.cpp;h=4f726ab5d442b62cc99675b5ffe0fc175ee138d4;hb=61da4e89d2ec63daa429d304f928482a0e6fa0b7;hp=f260a1691ab43575caa8d72e2686c62ed33af402;hpb=8c174deb53268c1ecfdd818339ac0fb1614d3312;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Command.cpp b/src/XGUI/XGUI_Command.cpp index f260a1691..4f726ab5d 100644 --- a/src/XGUI/XGUI_Command.cpp +++ b/src/XGUI/XGUI_Command.cpp @@ -1,43 +1,29 @@ #include "XGUI_Command.h" #include +#include +#include +#include - -XGUI_MenuButton::XGUI_MenuButton(const QIcon& theIcon, - const QString& theText, - QWidget * theParent) - : QPushButton(theIcon, theText, theParent) - -{ - setFlat(true); - setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT); - setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - QString aStyleSheet = "QPushButton { text-align: left; }"; - //aStyleSheet += "QPushButton:hover { border: 1px solid gray; border-radius: 3px; }"; - setStyleSheet(aStyleSheet); - installEventFilter(this); -} - -//void XGUI_MenuButton::enterEvent(QEvent * event) -//{ -// if(isEnabled()) { -// setFlat(false); -// } -//} - -//void XGUI_MenuButton::leaveEvent(QEvent * event) -//{ -// setFlat(true); -//} - -XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable) - : QWidgetAction(parent), 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), 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); @@ -48,22 +34,33 @@ XGUI_Command::~XGUI_Command() { } +const QString& XGUI_Command::documentKind() const +{ + return myDocumentKind; +} + QWidget* XGUI_Command::createWidget(QWidget* theParent) { if (theParent->inherits("XGUI_MenuGroupPanel")) { - XGUI_MenuButton* aButton = new XGUI_MenuButton(icon(), text(), theParent); - aButton->setCheckable(myCheckable); + 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()) + 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))); - connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool))); this->setCheckable(myCheckable); return aButton; @@ -73,7 +70,7 @@ QWidget* XGUI_Command::createWidget(QWidget* theParent) 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::nestedCommands() const