From: asv Date: Tue, 14 Jun 2005 12:43:17 +0000 (+0000) Subject: Changed mechanizm of Session::activeApplication(): now it returns an internal field... X-Git-Tag: T3_0_0_a4~117 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=140c5a341bb885f62cbc569dbd517610e7c76abc;p=modules%2Fgui.git Changed mechanizm of Session::activeApplication(): now it returns an internal field of Session, which is initialized in onApplicationActivated() slot. This new slot is connected to new signal of Application: activated(), which in turn is emitted when SUIT_Desktop throws activated() signal. :) --- diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index 0d329e8d7..a107e6b33 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -108,6 +108,8 @@ void SUIT_Application::setDesktop( SUIT_Desktop* desk ) delete myDesktop; myDesktop = desk; + connect( myDesktop, SIGNAL( activated() ), + this, SLOT( onDesktopActivated() ) ); } SUIT_Study* SUIT_Application::createNewStudy() @@ -296,3 +298,8 @@ QAction* SUIT_Application::separator() { return QtxActionMgr::separator(); } + +void SUIT_Application::onDesktopActivated() +{ + emit activated( this ); +} diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index 2a3fb0c96..5ef047b62 100755 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -71,6 +71,7 @@ public: signals: void applicationClosed( SUIT_Application* ); + void activated( SUIT_Application* ); protected: SUIT_Application* startApplication( int, char** ) const; @@ -108,6 +109,9 @@ protected: const QString&, const int, QObject* = 0, const bool = false, QObject* = 0, const char* = 0 ); +private slots: + void onDesktopActivated(); + private: SUIT_Study* myStudy; SUIT_Desktop* myDesktop; diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 08d85b0f4..9dcef329a 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -22,7 +22,8 @@ SUIT_Session* SUIT_Session::mySession = 0; SUIT_Session::SUIT_Session() : QObject(), myResMgr( 0 ), -myHandler( 0 ) +myHandler( 0 ), +myActiveApp( 0 ) { SUIT_ASSERT( !mySession ) @@ -100,6 +101,8 @@ SUIT_Application* SUIT_Session::startApplication( const QString& name, int args, connect( anApp, SIGNAL( applicationClosed( SUIT_Application* ) ), this, SLOT( onApplicationClosed( SUIT_Application* ) ) ); + connect( anApp, SIGNAL( activated( SUIT_Application* ) ), + this, SLOT( onApplicationActivated( SUIT_Application* ) ) ); myAppList.append( anApp ); @@ -139,6 +142,7 @@ QPtrList SUIT_Session::applications() const */ SUIT_Application* SUIT_Session::activeApplication() const { + /* if ( myAppList.count() == 1 ) return myAppList.getFirst(); @@ -162,6 +166,8 @@ SUIT_Application* SUIT_Session::activeApplication() const return 0; return study->application(); + */ + return myActiveApp; } /*! @@ -181,6 +187,8 @@ void SUIT_Session::onApplicationClosed( SUIT_Application* theApp ) emit applicationClosed( theApp ); myAppList.remove( theApp ); + if ( theApp == myActiveApp ) + myActiveApp = 0; if ( myAppList.isEmpty() ) qApp->quit(); @@ -256,3 +264,11 @@ SUIT_ResourceMgr* SUIT_Session::createResourceMgr( const QString& appName ) cons { return new SUIT_ResourceMgr( appName ); } + +/*! + Slot, called on activation of some application's desktop +*/ +void SUIT_Session::onApplicationActivated( SUIT_Application* app ) +{ + myActiveApp = app; +} diff --git a/src/SUIT/SUIT_Session.h b/src/SUIT/SUIT_Session.h index c51a87ed9..842ef0ae9 100755 --- a/src/SUIT/SUIT_Session.h +++ b/src/SUIT/SUIT_Session.h @@ -62,6 +62,7 @@ protected: private slots: void onApplicationClosed( SUIT_Application* ); + void onApplicationActivated( SUIT_Application* ); private: typedef QPtrList AppList; @@ -77,6 +78,7 @@ private: SUIT_ResourceMgr* myResMgr; AppList myAppList; AppLibMap myAppLibs; + SUIT_Application* myActiveApp; SUIT_ExceptionHandler* myHandler; static SUIT_Session* mySession;