From: asl Date: Thu, 13 Aug 2015 09:36:59 +0000 (+0300) Subject: Issue #681: add undo,redo,rebuild into the standard SALOME toolbar X-Git-Tag: V_1.4.0_beta4~390 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1ba1c698d48716b29f9a71f476d3435648edda52;p=modules%2Fshaper.git Issue #681: add undo,redo,rebuild into the standard SALOME toolbar --- diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index 9a20bca77..cb422b659 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -455,6 +456,23 @@ void NewGeom_Module::addDesktopMenuSeparator(const char* theMenuSourceText, cons createMenu(separator(), aMenu, -1, theMenuPosition); } +bool NewGeom_Module::addActionInToolbar( QAction* theAction, const QString& theToolBarTitle ) +{ + if( !theAction ) + return false; + + SUIT_Desktop* aDesktop = application()->desktop(); + if( !aDesktop ) + return false; + + QtxActionToolMgr* aToolMgr = aDesktop->toolMgr(); + if( !aToolMgr ) + return false; + + aToolMgr->append( theAction, theToolBarTitle ); + return true; +} + //****************************************************** QList NewGeom_Module::commandList() const { diff --git a/src/NewGeom/NewGeom_Module.h b/src/NewGeom/NewGeom_Module.h index 89cfc45a2..7c0aa1a6e 100644 --- a/src/NewGeom/NewGeom_Module.h +++ b/src/NewGeom/NewGeom_Module.h @@ -70,6 +70,8 @@ Q_OBJECT virtual void addDesktopMenuSeparator(const char* theMenuSourceText, const int theMenuPosition = 10); + virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle ); + virtual QMainWindow* desktop() const; virtual QString commandId(const QAction* theCmd) const; diff --git a/src/XGUI/XGUI_SalomeConnector.h b/src/XGUI/XGUI_SalomeConnector.h index a7dd901c3..742a6055b 100644 --- a/src/XGUI/XGUI_SalomeConnector.h +++ b/src/XGUI/XGUI_SalomeConnector.h @@ -72,6 +72,8 @@ class XGUI_EXPORT XGUI_SalomeConnector virtual void addDesktopMenuSeparator(const char* theMenuSourceText, const int theMenuPosition = 10) = 0; + virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle ) = 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 45248744d..5f6b0e9fb 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -243,12 +243,17 @@ void XGUI_Workshop::initMenu() tr("Undo last command"), QIcon(":pictures/undo.png"), QKeySequence::Undo, false, "MEN_DESK_EDIT"); + QString aToolBarTitle = tr( "INF_DESK_TOOLBAR_STANDARD" ); + salomeConnector()->addActionInToolbar( aAction,aToolBarTitle ); + connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onUndo())); addHistoryMenu(aAction, SIGNAL(updateUndoHistory(const QList&)), SLOT(onUndo(int))); aAction = salomeConnector()->addDesktopCommand("REDO_CMD", tr("Redo"), tr("Redo last command"), QIcon(":pictures/redo.png"), QKeySequence::Redo, false, "MEN_DESK_EDIT"); + salomeConnector()->addActionInToolbar( aAction, aToolBarTitle ); + connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRedo())); addHistoryMenu(aAction, SIGNAL(updateRedoHistory(const QList&)), SLOT(onRedo(int))); @@ -256,6 +261,8 @@ void XGUI_Workshop::initMenu() aAction = salomeConnector()->addDesktopCommand("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"), QIcon(":pictures/rebuild.png"), QKeySequence(), false, "MEN_DESK_EDIT"); + salomeConnector()->addActionInToolbar( aAction, aToolBarTitle ); + connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRebuild())); salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT");