From d9ae8d107fbaf3a2d3d460e721eab699efcba314 Mon Sep 17 00:00:00 2001 From: adv Date: Mon, 2 Apr 2012 13:55:01 +0000 Subject: [PATCH] Customise new/close application actions. --- src/STD/STD_Application.cxx | 56 ++++++++++++++++++++++++++++++++++++- src/STD/STD_Application.h | 10 +++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index ec1e7b2ab..792ab4cb9 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -50,7 +50,9 @@ STD_Application::STD_Application() myActiveViewMgr( 0 ), myExitConfirm( true ), myEditEnabled( true ), - myCustomPersistence( false ) + myCustomPersistence( false ), + myCustomNew( false ), + myCustomClose( false ) { setDesktop( new STD_MDIDesktop() ); } @@ -266,6 +268,12 @@ void STD_Application::onNewDoc() /*!Opens new application*/ bool STD_Application::onNewDoc( const QString& name ) { + if ( myCustomNew ) + { + emit newDoc( name ); + return true; + } + QApplication::setOverrideCursor( Qt::WaitCursor ); bool res = true; @@ -343,6 +351,12 @@ void STD_Application::afterCloseDoc() /*!Close document, if it's possible.*/ void STD_Application::onCloseDoc( bool ask ) { + if ( myCustomClose ) + { + emit closeDoc(); + return; + } + bool closePermanently = true; if ( ask && !isPossibleToClose( closePermanently ) ) @@ -966,3 +980,43 @@ bool STD_Application::isCustomPersistence() const { return myCustomPersistence; } + +/*! + Replace standard SALOME open document mechanism with custom one. + If custom open is set SALOME does not perform standard actions on + new button pressing; it emits corresponding signal instead. + \sa isCustomNewDoc +*/ +void STD_Application::setCustomNewDoc( const bool theVal ) +{ + myCustomNew = theVal; +} + +/*! + Check flag of custom action "New Document" + \sa setCustomNewDoc +*/ +bool STD_Application::isCustomNewDoc() const +{ + return myCustomNew; +} + +/*! + Replace standard SALOME close document mechanism with custom one. + If custom close is set SALOME does not perform standard actions on + close button pressing; it emits corresponding signal instead. + \sa isCustomCloseDoc +*/ +void STD_Application::setCustomCloseDoc( const bool theVal ) +{ + myCustomClose = theVal; +} + +/*! + Check flag of custom action "Close Document" + \sa setCustomCloseDoc +*/ +bool STD_Application::isCustomCloseDoc() const +{ + return myCustomClose; +} \ No newline at end of file diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index f102e5e27..6c069f934 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -102,6 +102,12 @@ public: void setCustomPersistence( const bool ); bool isCustomPersistence() const; + void setCustomNewDoc( const bool ); + bool isCustomNewDoc() const; + + void setCustomCloseDoc( const bool ); + bool isCustomCloseDoc() const; + signals: /*!emit that view manager added*/ void viewManagerAdded( SUIT_ViewManager* ); @@ -111,6 +117,8 @@ signals: void viewManagerActivated( SUIT_ViewManager* ); /*!*/ + void newDoc( const QString& ); + void closeDoc(); void openDoc(); void saveDoc(); void saveAsDoc(); @@ -177,6 +185,8 @@ private: bool myExitConfirm; bool myEditEnabled; bool myCustomPersistence; + bool myCustomNew; + bool myCustomClose; }; #if defined WIN32 -- 2.39.2