Salome HOME
Merge branch 'master' into BR_PYTHON_PLUGIN
[modules/shaper.git] / src / XGUI / XGUI_Command.cpp
index b289f8014ec6b65c6efe2084978bebd0fe0a6068..1194dc4543785c84b0339555b385dab588506de9 100644 (file)
@@ -1,16 +1,29 @@
 #include "XGUI_Command.h"
-
+#include <QEvent>
 #include <QToolButton>
+#include <QVariant>
+#include <QDebug>
 
-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);
@@ -21,30 +34,34 @@ XGUI_Command::~XGUI_Command()
 {
 }
 
+const QString& XGUI_Command::documentKind() const
+{
+  return myDocumentKind;
+}
+
 QWidget* XGUI_Command::createWidget(QWidget* theParent)
 {
   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())
+    if (!aKeys.isEmpty()) {
+      aToolTip = QString("%1 (%2)").arg(aToolTip).arg(aKeys.toString());
+      aButton->setShortcut(aKeys);
+    }
+    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;
@@ -54,7 +71,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