Salome HOME
Changed mechanizm of Session::activeApplication(): now it returns an internal field...
authorasv <asv@opencascade.com>
Tue, 14 Jun 2005 12:43:17 +0000 (12:43 +0000)
committerasv <asv@opencascade.com>
Tue, 14 Jun 2005 12:43:17 +0000 (12:43 +0000)
src/SUIT/SUIT_Application.cxx
src/SUIT/SUIT_Application.h
src/SUIT/SUIT_Session.cxx
src/SUIT/SUIT_Session.h

index 0d329e8d7b3c21b272a6558ef7306fc539b23452..a107e6b33fd7f936ee2ff8861ab3acd5de618fd0 100755 (executable)
@@ -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 );
+}
index 2a3fb0c96cd2cc13b5ccb310d871dfd87acfc19c..5ef047b6232f44f8cc417ea00452242f424f4475 100755 (executable)
@@ -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;
index 08d85b0f404b1ef28191155d0c96bddf54d25a50..9dcef329a14af5edd78440d78d3189b6f9b0b372 100755 (executable)
@@ -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_Application> 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;
+}
index c51a87ed9b582c195d0afe89b75224596215e7e6..842ef0ae9da16f2ef766feb55ede2a14031a26a0 100755 (executable)
@@ -62,6 +62,7 @@ protected:
 
 private slots:
   void                         onApplicationClosed( SUIT_Application* );
+  void                         onApplicationActivated( SUIT_Application* ); 
 
 private:
   typedef QPtrList<SUIT_Application>         AppList;
@@ -77,6 +78,7 @@ private:
   SUIT_ResourceMgr*            myResMgr;
   AppList                      myAppList;
   AppLibMap                    myAppLibs;
+  SUIT_Application*            myActiveApp;
 
   SUIT_ExceptionHandler*       myHandler;
   static SUIT_Session*         mySession;