Salome HOME
Fix for constraints selection
[modules/shaper.git] / src / XGUI / XGUI_ActionsMgr.cpp
index f1d5e49b15ddf7ab4de2dfc415746b13f76e4823..129a595daa13fc12b0df39660277a150701d20d2 100644 (file)
@@ -12,7 +12,7 @@
 #include <XGUI_SelectionMgr.h>
 
 #include <Events_Loop.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Events.h>
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationFeature.h>
 #include <ModuleBase_SelectionValidator.h>
+#include <ModuleBase_Tools.h>
 
 
 #include <QAction>
+#include <QMainWindow>
 
 #ifdef _DEBUG
 #include <iostream>
@@ -173,7 +175,7 @@ QKeySequence XGUI_ActionsMgr::registerShortcut(const QKeySequence& theKeySequenc
   if (myShortcuts.contains(theKeySequence)) {
     QString aMessage = tr("Shortcut %1 is already defined. Ignore.");
     aMessage = aMessage.arg(theKeySequence.toString());
-    Events_Error::send(aMessage.toStdString());
+    Events_InfoMessage("XGUI_ActionsMgr", aMessage.toStdString()).send();
     return QKeySequence();
   }
   myShortcuts.append(theKeySequence);
@@ -217,39 +219,40 @@ void XGUI_ActionsMgr::processEvent(const std::shared_ptr<Events_Message>& theMes
   }
 }
 
-QAction* XGUI_ActionsMgr::operationStateAction(OperationStateActionId theId, QObject* theParent)
+QAction* XGUI_ActionsMgr::operationStateAction(OperationStateActionId theId)
 {
   QAction* aResult = NULL;
   if (myOperationActions.contains(theId)) {
     aResult = myOperationActions.value(theId);
-    if (theParent && aResult->parent() != theParent) {
-      aResult->setParent(theParent);
-    }
+    //if (theParent && aResult->parent() != theParent) {
+    //  aResult->setParent(theParent);
+    //}
   } else {
+    QWidget* aParent = myWorkshop->desktop();
     switch (theId) {
       case Accept:
       case AcceptAll: {
-        aResult = new QAction(QIcon(":pictures/button_ok.png"), "", theParent);
-        aResult->setToolTip("Apply");
+        aResult = ModuleBase_Tools::createAction(QIcon(":pictures/button_ok.png"),
+                            "Apply" /*empty to show error*/, aParent);
       }
       break;
       case Abort:
       case AbortAll: {
-        aResult = new QAction(QIcon(":pictures/button_cancel.png"), "", theParent);
-        aResult->setToolTip("Cancel");
+        aResult = ModuleBase_Tools::createAction(QIcon(":pictures/button_cancel.png"), "Cancel",
+                                                 aParent);
         if (theId == Abort) {
           aResult->setShortcut(QKeySequence(Qt::Key_Escape));
         }
       }
       break;
       case Help: {
-        aResult = new QAction(QIcon(":pictures/button_help.png"), "", theParent);
-        aResult->setToolTip("Help");
+        aResult = ModuleBase_Tools::createAction(QIcon(":pictures/button_help.png"), "Help",
+                                                 aParent);
       }
       break;
       case Preview: {
-        aResult = new QAction("See preview", theParent);
-        aResult->setToolTip("Compute preview");
+        aResult = ModuleBase_Tools::createAction(QIcon(), tr("See preview"), aParent, 0, 0, "Compute preview");
+        aResult->setStatusTip(aResult->toolTip());
       }
       break;
       default: