Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / XGUI / XGUI_ActionsMgr.cpp
index 611976e2a91c3da4186b17d8acf72da68f951f9b..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()
@@ -132,4 +141,19 @@ bool XGUI_ActionsMgr::isNested(const QString& theId) const
       return true;
   }
   return false;
-}
\ No newline at end of file
+}
+
+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;
+}