]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #251. Append Export/Import NewGeom commands in the SALOME desktop.
authornds <natalia.donis@opencascade.com>
Tue, 11 Nov 2014 09:16:58 +0000 (12:16 +0300)
committernds <natalia.donis@opencascade.com>
Tue, 11 Nov 2014 09:16:58 +0000 (12:16 +0300)
src/NewGeom/NewGeom_Module.cpp
src/NewGeom/NewGeom_Module.h
src/XGUI/XGUI_SalomeConnector.h
src/XGUI/XGUI_Workshop.cpp

index d1a639543bef99eabe6e237100890ac538230d6b..9f8bc4543a6ee76012b5b0515195bd9c35e7f6ff 100644 (file)
@@ -269,11 +269,12 @@ QAction* NewGeom_Module::addFeature(const QString& theWBName, const QString& the
 }
 
 //******************************************************
-QAction* NewGeom_Module::addEditCommand(const QString& theId, const QString& theTitle,
-                                        const QString& theTip, const QIcon& theIcon,
-                                        const QKeySequence& theKeys, bool isCheckable)
+QAction* NewGeom_Module::addDesktopCommand(const QString& theId, const QString& theTitle,
+                                           const QString& theTip, const QIcon& theIcon,
+                                           const QKeySequence& theKeys, bool isCheckable,
+                                           const char* theMenuSourceText, const int theMenuPosition)
 {
-  int aMenu = createMenu(tr("MEN_DESK_EDIT"), -1, -1);
+  int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
 
   int aId = myActionsList.size();
   myActionsList.append(theId);
@@ -284,15 +285,15 @@ QAction* NewGeom_Module::addEditCommand(const QString& theId, const QString& the
   QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
                                   isCheckable);
   aAction->setData(theId);
-  createMenu(aId, aMenu, 10);
+  createMenu(aId, aMenu, theMenuPosition);
   return aAction;
 }
 
 //******************************************************
-void NewGeom_Module::addEditMenuSeparator()
+void NewGeom_Module::addDesktopMenuSeparator(const char* theMenuSourceText, const int theMenuPosition)
 {
-  int aMenu = createMenu(tr("MEN_DESK_EDIT"), -1, -1);
-  createMenu(separator(), aMenu, -1, 10);
+  int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
+  createMenu(separator(), aMenu, -1, theMenuPosition);
 }
 
 //******************************************************
index 4b970e1ac6379473357a2c4ac0b694be26205c29..f8fdfb8f960d3e5ace4eb18f349d3932eb1e0bac 100644 (file)
@@ -38,11 +38,14 @@ Q_OBJECT
                               const QKeySequence& theKeys = QKeySequence(),
                               bool isCheckable = false);
 
-  virtual QAction* addEditCommand(const QString& theId, const QString& theTitle,
-                                  const QString& theTip, const QIcon& theIcon,
-                                  const QKeySequence& theKeys, bool isCheckable);
-
-  virtual void addEditMenuSeparator();
+  virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
+                                     const QString& theTip, const QIcon& theIcon,
+                                     const QKeySequence& theKeys, bool isCheckable,
+                                     const char* theMenuSourceText,
+                                     const int theMenuPosition = 10);
+
+  virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
+                                       const int theMenuPosition = 10);
 
   virtual QMainWindow* desktop() const;
 
index 0c36dada2d5113a860c4ca6e388abb3b0bd2a4f5..d055e67c37f13bdd2758cc7c4e878ed6feaf0deb 100644 (file)
@@ -36,13 +36,18 @@ class XGUI_EXPORT XGUI_SalomeConnector
   //! \param theIcon - icon
   //! \param isCheckable - is checkable or not
   //! \param theKeys - hot keys
+  //! \param theMenuSourceText - a source text of the desktop menu
+  //! \param theMenuPosition - a position of the command in the desktop menu
   //! returns created action
-  virtual QAction* addEditCommand(const QString& theId, const QString& theTitle,
-                                  const QString& theTip, const QIcon& theIcon,
-                                  const QKeySequence& theKeys, bool isCheckable) = 0;
+  virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
+                                     const QString& theTip, const QIcon& theIcon,
+                                     const QKeySequence& theKeys, bool isCheckable,
+                                     const char* theMenuSourceText,
+                                     const int theMenuPosition = 10) = 0;
 
   //! Insert separator into Edit menu of SALOME desktop
-  virtual void addEditMenuSeparator() = 0;
+  virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
+                                       const int theMenuPosition = 10) = 0;
 
   //! Returns desktop window of SALOME
   virtual QMainWindow* desktop() const = 0;
index 83dc099fc44d10a7db66717b0d887fc6198e7df9..d897bc369e4180775b64b8e01c2d270bbd285213 100644 (file)
@@ -169,21 +169,33 @@ void XGUI_Workshop::initMenu()
 
   if (isSalomeMode()) {
     // Create only Undo, Redo commands
-    QAction* aAction = salomeConnector()->addEditCommand("UNDO_CMD", tr("Undo"),
+    QAction* aAction = salomeConnector()->addDesktopCommand("UNDO_CMD", tr("Undo"),
                                                          tr("Undo last command"),
                                                          QIcon(":pictures/undo.png"),
-                                                         QKeySequence::Undo, false);
+                                                         QKeySequence::Undo, false, "MEN_DESK_EDIT");
     connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onUndo()));
-    aAction = salomeConnector()->addEditCommand("REDO_CMD", tr("Redo"), tr("Redo last command"),
+    aAction = salomeConnector()->addDesktopCommand("REDO_CMD", tr("Redo"), tr("Redo last command"),
                                                 QIcon(":pictures/redo.png"), QKeySequence::Redo,
-                                                false);
+                                                false, "MEN_DESK_EDIT");
     connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRedo()));
-    salomeConnector()->addEditMenuSeparator();
-    aAction = salomeConnector()->addEditCommand("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
+    salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT");
+    aAction = salomeConnector()->addDesktopCommand("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
                                                 QIcon(":pictures/rebuild.png"), QKeySequence(),
-                                                false);
+                                                false, "MEN_DESK_EDIT");
     connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRebuild()));
-    salomeConnector()->addEditMenuSeparator();
+    salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT");
+
+    aAction = salomeConnector()->addDesktopCommand("SAVEAS_CMD", tr("Export NewGeom..."), tr("Export the current NewGeom document into a file"),
+                                                QIcon(), QKeySequence(),
+                                                false, "MEN_DESK_FILE");
+    connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onSaveAs()));
+
+    aAction = salomeConnector()->addDesktopCommand("OPEN_CMD", tr("Import NewGeom..."), tr("Import a NewGeom file"),
+                                                QIcon(), QKeySequence(),
+                                                false, "MEN_DESK_FILE");
+    connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onOpen()));
+    salomeConnector()->addDesktopMenuSeparator("MEN_DESK_FILE");
+
     return;
   }
   // File commands group
@@ -747,7 +759,8 @@ bool XGUI_Workshop::onSave()
   std::list<std::string> aFiles;
   saveDocument(myCurrentDir, aFiles);
   updateCommandStatus();
-  myMainWindow->setModifiedState(false);
+  if (!isSalomeMode())
+    myMainWindow->setModifiedState(false);
   return true;
 }