SUIT_Session::SUIT_Session()
: QObject(),
myResMgr( 0 ),
-myHandler( 0 )
+myHandler( 0 ),
+myActiveApp( 0 ),
+myExitStatus( FROM_GUI )
{
SUIT_ASSERT( !mySession )
return 0;
}
- myAppLibs.insert( appName, libHandle );
+ if (!myAppLibs.contains(appName) || !myAppLibs[appName]) // jfa 22.06.2005
+ myAppLibs.insert( appName, libHandle );
APP_CREATE_FUNC crtInst = 0;
myResMgr->loadLanguage();
}
- SUIT_Application* anApp = crtInst( args, argv );
+ //jfa 22.06.2005:SUIT_Application* anApp = crtInst( args, argv );
+ SUIT_Application* anApp = crtInst();
if ( !anApp )
{
SUIT_MessageBox::warn1(0, tr( "Error" ), tr( "Can not find function %1. %2").arg( APP_CREATE_NAME ).arg( lastError() ), tr( "Ok" ) );
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 );
*/
SUIT_Application* SUIT_Session::activeApplication() const
{
+ /*
if ( myAppList.count() == 1 )
return myAppList.getFirst();
return 0;
return study->application();
+ */
+ return myActiveApp;
}
/*!
emit applicationClosed( theApp );
myAppList.remove( theApp );
+ if ( theApp == myActiveApp )
+ myActiveApp = 0;
if ( myAppList.isEmpty() )
- qApp->quit();
+ {
+ printf( "Calling QApplication::exit() with exit code = %d\n", myExitStatus );
+ qApp->exit( myExitStatus );
+ }
}
/*!
Destroys session by closing all applications.
*/
-void SUIT_Session::closeSession()
+void SUIT_Session::closeSession( int mode )
{
- for ( AppListIterator it( myAppList ); it.current(); ++it )
+ while ( !myAppList.isEmpty() )
{
- if ( !it.current()->isPossibleToClose() )
+ SUIT_Application* app = myAppList.getFirst();
+ if ( mode == ASK && !app->isPossibleToClose() )
return;
+ else if ( mode == SAVE )
+ {
+ SUIT_Study* study = app->activeStudy();
+ if ( study->isModified() && study->isSaved() )
+ study->saveDocument();
+ }
+ else if ( mode == DONT_SAVE )
+ {
+ myExitStatus = FROM_CORBA_SESSION;
+ //....
+ }
+
+ app->closeApplication();
}
- qApp->quit();
}
SUIT_ExceptionHandler* SUIT_Session::handler() const
{
return new SUIT_ResourceMgr( appName );
}
+
+/*!
+ Slot, called on activation of some application's desktop
+*/
+void SUIT_Session::onApplicationActivated( SUIT_Application* app )
+{
+ myActiveApp = app;
+}