Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / XGUI / XGUI_ActionsMgr.cpp
index 8722c089649af58c9bd6f1229c8d06ba1e1c8f78..4bfb31b9d6e31eb7807415815e4a04f815149c66 100644 (file)
@@ -9,18 +9,27 @@
 #include "XGUI_SalomeConnector.h"
 
 #include <ModuleBase_Operation.h>
+#include <Events_Error.h>
 
 #include <QAction>
 
 #ifdef _DEBUG
+#include <iostream>
 #include <QDebug>
 #endif
 
 
 XGUI_ActionsMgr::XGUI_ActionsMgr(XGUI_Workshop* theParent)
- : QObject(theParent), myOperationMgr(theParent->operationMgr())
+ : QObject(theParent),
+   myWorkshop(theParent),
+   myOperationMgr(theParent->operationMgr())
 {
-
+  // Default shortcuts
+  myShortcuts << QKeySequence::Save;
+  myShortcuts << QKeySequence::Undo;
+  myShortcuts << QKeySequence::Redo;
+  myShortcuts << QKeySequence::Open;
+  myShortcuts << QKeySequence::Close;
 }
 
 XGUI_ActionsMgr::~XGUI_ActionsMgr()
@@ -116,3 +125,35 @@ void XGUI_ActionsMgr::updateCheckState()
     setActionChecked(eachCommand, true);
   }
 }
+
+QStringList XGUI_ActionsMgr::nestedCommands(const QString& theId) const
+{
+  if (myNestedActions.contains(theId))
+    return myNestedActions[theId];
+  return QStringList();
+}
+
+bool XGUI_ActionsMgr::isNested(const QString& theId) const
+{
+  foreach(QString aId, myNestedActions.keys()) {
+    QStringList aList = myNestedActions[aId];
+    if (aList.contains(theId))
+      return true;
+  }
+  return false;
+}
+
+QKeySequence XGUI_ActionsMgr::registerShortcut(const QString& theKeySequence)
+{
+  if(theKeySequence.isEmpty()) {
+    return QKeySequence();
+  }
+  QKeySequence aResult(theKeySequence);
+  if(myShortcuts.contains(aResult)) {
+    QString aMessage = tr("Shortcut %1 is already defined. Ignore.").arg(theKeySequence);
+    Events_Error::send(aMessage.toStdString());
+    return QKeySequence();
+  }
+  myShortcuts.append(aResult);
+  return aResult;
+}