Salome HOME
Issue #101: Fixed editing of nested features
[modules/shaper.git] / src / XGUI / XGUI_Command.cpp
index 0ddb0ecfcd8dafc2aa6bd851b42d4094ade036cb..59df312b1e3338caf61be7232afe89797af4c5da 100644 (file)
@@ -1,16 +1,18 @@
 #include "XGUI_Command.h"
-
-#include <QPushButton>
+#include <QEvent>
+#include <QToolButton>
 
 XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable)
-    : QWidgetAction(parent), myCheckable(isCheckable)
+    : QWidgetAction(parent),
+      myCheckable(isCheckable)
 {
   setData(theId);
 }
 
 XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text,
                            QObject* parent, bool isCheckable)
-    : QWidgetAction(parent), myCheckable(isCheckable)
+    : QWidgetAction(parent),
+      myCheckable(isCheckable)
 {
   setIcon(icon);
   setText(text);
@@ -24,25 +26,26 @@ XGUI_Command::~XGUI_Command()
 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)));
-    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;
   }
@@ -51,7 +54,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