From: nds Date: Tue, 11 Nov 2014 09:16:58 +0000 (+0300) Subject: Issue #251. Append Export/Import NewGeom commands in the SALOME desktop. X-Git-Tag: V_0.5~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d22fc665c79c31c9eea0625e04c2e941adfdf7be;p=modules%2Fshaper.git Issue #251. Append Export/Import NewGeom commands in the SALOME desktop. --- diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index d1a639543..9f8bc4543 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -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); } //****************************************************** diff --git a/src/NewGeom/NewGeom_Module.h b/src/NewGeom/NewGeom_Module.h index 4b970e1ac..f8fdfb8f9 100644 --- a/src/NewGeom/NewGeom_Module.h +++ b/src/NewGeom/NewGeom_Module.h @@ -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; diff --git a/src/XGUI/XGUI_SalomeConnector.h b/src/XGUI/XGUI_SalomeConnector.h index 0c36dada2..d055e67c3 100644 --- a/src/XGUI/XGUI_SalomeConnector.h +++ b/src/XGUI/XGUI_SalomeConnector.h @@ -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; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 83dc099fc..d897bc369 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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 aFiles; saveDocument(myCurrentDir, aFiles); updateCommandStatus(); - myMainWindow->setModifiedState(false); + if (!isSalomeMode()) + myMainWindow->setModifiedState(false); return true; }