Salome HOME
Property panel widgets redesign
[modules/shaper.git] / src / XGUI / XGUI_ActionsMgr.cpp
index 851e3fef0adff9e5feb81c9e2eb35d4f5c9b7f49..33f1826a792e99d7bcb183d94f35cddb37e78f2d 100644 (file)
@@ -142,9 +142,6 @@ void XGUI_ActionsMgr::updateOnViewSelection()
   foreach(QString aId, nestedCommands(aFeatureId)) {
     std::list<ModelAPI_Validator*> aValidators;
     std::list<std::list<std::string> > anArguments;
-    if (!anArguments.empty()) {
-      std::list<std::string> firstArg = anArguments.front();
-    }
     aFactory->validators(aId.toStdString(), aValidators, anArguments);
     std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
     std::list<std::list<std::string> >::iterator aValidatorArgs = anArguments.begin();
@@ -161,18 +158,28 @@ void XGUI_ActionsMgr::updateOnViewSelection()
   }
 }
 
-QKeySequence XGUI_ActionsMgr::registerShortcut(const QString& theKeySequence)
+QKeySequence XGUI_ActionsMgr::registerShortcut(const QKeySequence& theKeySequence)
 {
   if (theKeySequence.isEmpty()) {
     return QKeySequence();
   }
-  QKeySequence aResult(theKeySequence);
-  if (myShortcuts.contains(aResult)) {
-    QString aMessage = tr("Shortcut %1 is already defined. Ignore.").arg(theKeySequence);
+  if (myShortcuts.contains(theKeySequence)) {
+    QString aMessage = tr("Shortcut %1 is already defined. Ignore.");
+    aMessage = aMessage.arg(theKeySequence.toString());
     Events_Error::send(aMessage.toStdString());
     return QKeySequence();
   }
-  myShortcuts.append(aResult);
+  myShortcuts.append(theKeySequence);
+  return theKeySequence;
+}
+
+QKeySequence XGUI_ActionsMgr::registerShortcut(const QString& theKeySequence)
+{
+  if (theKeySequence.isEmpty()) {
+    return QKeySequence();
+  }
+  QKeySequence aResult(theKeySequence);
+  registerShortcut(aResult);
   return aResult;
 }
 
@@ -203,6 +210,51 @@ void XGUI_ActionsMgr::processEvent(const std::shared_ptr<Events_Message>& theMes
   }
 }
 
+QAction* XGUI_ActionsMgr::operationStateAction(OperationStateActionId theId, QObject* theParent)
+{
+  QAction* aResult = NULL;
+  if (myOperationActions.contains(theId)) {
+    aResult = myOperationActions.value(theId);
+    if (theParent && aResult->parent() != theParent) {
+      aResult->setParent(theParent);
+    }
+  } else {
+    switch (theId) {
+      case Accept:
+      case AcceptAll:
+        aResult = new QAction(QIcon(":pictures/button_ok.png"), "", theParent);
+        break;
+      case Abort:
+      case AbortAll: {
+        aResult = new QAction(QIcon(":pictures/button_cancel.png"), "", theParent);
+        if(theId == Abort) {
+          aResult->setShortcut(QKeySequence(Qt::Key_Escape));
+        }
+      }
+      break;
+      case Help:
+        aResult = new QAction(QIcon(":pictures/button_help.png"), "", theParent);
+        break;
+      default:
+        break;
+    }
+    myOperationActions.insert(theId, aResult);
+  }
+  return aResult;
+}
+
+ActionInfo XGUI_ActionsMgr::actionInfoById(const QString& theId)
+{
+  ActionInfo aResult;
+  if(myActions.contains(theId)) {
+    aResult.initFrom(myActions.value(theId));
+  } else {
+   aResult.id = theId;
+   aResult.text = theId;
+  }
+  return aResult;
+}
+
 void XGUI_ActionsMgr::setAllEnabled(bool isEnabled)
 {
   foreach(QString eachAction, myActions.keys())