3 #undef SUIT_ENABLE_PYTHON
5 //#include "SUITconfig.h"
8 #include "SUITApp_Application.h"
10 #include <SUIT_Session.h>
11 #include <SUIT_Desktop.h>
12 #include <SUIT_ResourceMgr.h>
15 #ifdef SUIT_ENABLE_PYTHON
22 #include <qstringlist.h>
26 QString salomeVersion()
28 QString path( ::getenv( "GUI_ROOT_DIR" ) );
29 if ( !path.isEmpty() )
30 path += QDir::separator();
32 path += QString( "bin/salome/VERSION" );
35 if ( !vf.open( IO_ReadOnly ) )
39 vf.readLine( line, 1024 );
45 while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
46 line.remove( line.length() - 1, 1 );
49 int idx = line.findRev( ":" );
51 ver = line.mid( idx + 1 ).stripWhiteSpace();
58 static const char* pixmap_not_found_xpm[] = {
80 class SUITApp_Session: public SUIT_Session
83 SUITApp_Session( bool theIniFormat ) : SUIT_Session(), myIniFormat ( theIniFormat ) {}
84 virtual ~SUITApp_Session() {}
87 virtual SUIT_ResourceMgr* createResourceMgr( const QString& appName ) const
89 SUIT_ResourceMgr* resMgr = 0;
92 resMgr = new SUIT_ResourceMgr( appName );
93 resMgr->setCurrentFormat( "ini" );
97 resMgr = new SUIT_ResourceMgr( appName, QString( "%1Config" ) );
98 resMgr->setVersion( salomeVersion() );
99 resMgr->setCurrentFormat( "xml" );
104 static QPixmap defaultPixmap( pixmap_not_found_xpm );
105 resMgr->setDefaultPixmap( defaultPixmap );
106 resMgr->setOption( "translators", QString( "%P_msg_%L.qm|%P_icons.qm|%P_images.qm" ) );
115 int main( int args, char* argv[] )
117 #ifdef SUIT_ENABLE_PYTHON
119 PySys_SetArgv( args, argv );
123 bool noExceptHandling = false;
124 bool iniFormat = false;
125 for ( int i = 1; i < args /*&& !noExceptHandling*/; i++ )
127 if ( !strcmp( argv[i], "/noexcepthandling" ) )
128 noExceptHandling = true;
129 else if ( !strcmp( argv[i], "--format=ini") )
132 argList.append( QString( argv[i] ) );
135 SUITApp_Application app( args, argv );
138 if ( !argList.isEmpty() )
140 SUITApp_Session* aSession = new SUITApp_Session( iniFormat );
141 SUIT_Application* theApp = aSession->startApplication( argList.first() );
144 if ( !noExceptHandling )
145 app.setHandler( aSession->handler() );
147 if ( !app.mainWidget() )
148 app.setMainWidget( theApp->desktop() );