3 #undef SUIT_ENABLE_PYTHON
5 //#include "SUITconfig.h"
8 #include "SUITApp_Application.h"
10 #include "SUIT_Session.h"
11 #include "SUIT_ResourceMgr.h"
14 #ifdef SUIT_ENABLE_PYTHON
21 #include <qstringlist.h>
25 QString salomeVersion()
27 QString path( ::getenv( "GUI_ROOT_DIR" ) );
28 if ( !path.isEmpty() )
29 path += QDir::separator();
31 path += QString( "bin/salome/VERSION" );
34 if ( !vf.open( IO_ReadOnly ) )
38 vf.readLine( line, 1024 );
44 while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
45 line.remove( line.length() - 1, 1 );
48 int idx = line.findRev( ":" );
50 ver = line.mid( idx + 1 ).stripWhiteSpace();
57 static const char* pixmap_not_found_xpm[] = {
79 class SUITApp_Session: public SUIT_Session
82 SUITApp_Session( bool theIniFormat ) : SUIT_Session(), myIniFormat ( theIniFormat ) {}
83 virtual ~SUITApp_Session() {}
86 virtual SUIT_ResourceMgr* createResourceMgr( const QString& appName ) const
88 SUIT_ResourceMgr* resMgr = 0;
91 resMgr = new SUIT_ResourceMgr( appName );
92 resMgr->setCurrentFormat( "ini" );
96 resMgr = new SUIT_ResourceMgr( appName, QString( "%1Config" ) );
97 resMgr->setVersion( salomeVersion() );
98 resMgr->setCurrentFormat( "xml" );
103 static QPixmap defaultPixmap( pixmap_not_found_xpm );
104 resMgr->setDefaultPixmap( defaultPixmap );
105 resMgr->setOption( "translators", QString( "%P_msg_%L.qm|%P_icons.qm|%P_images.qm" ) );
114 int main( int args, char* argv[] )
116 #ifdef SUIT_ENABLE_PYTHON
118 PySys_SetArgv( args, argv );
122 bool noExceptHandling = false;
123 bool iniFormat = false;
124 for ( int i = 1; i < args /*&& !noExceptHandling*/; i++ )
126 if ( !strcmp( argv[i], "/noexcepthandling" ) )
127 noExceptHandling = true;
128 else if ( !strcmp( argv[i], "--format=ini") )
131 argList.append( QString( argv[i] ) );
134 SUITApp_Application app( args, argv );
137 if ( !argList.isEmpty() )
139 SUITApp_Session* aSession = new SUITApp_Session( iniFormat );
140 if ( aSession->startApplication( argList.first() ) )
142 if ( !noExceptHandling )
143 app.setHandler( aSession->handler() );