1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
21 #undef SUIT_ENABLE_PYTHON
23 //#include "SUITconfig.h"
26 #include "SUITApp_Application.h"
28 #include <SUIT_Session.h>
29 #include <SUIT_Desktop.h>
30 #include <SUIT_ResourceMgr.h>
33 #ifdef SUIT_ENABLE_PYTHON
40 #include <qstringlist.h>
44 QString salomeVersion()
46 QString path( ::getenv( "GUI_ROOT_DIR" ) );
47 if ( !path.isEmpty() )
48 path += QDir::separator();
50 path += QString( "bin/salome/VERSION" );
53 if ( !vf.open( IO_ReadOnly ) )
57 vf.readLine( line, 1024 );
63 while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
64 line.remove( line.length() - 1, 1 );
67 int idx = line.findRev( ":" );
69 ver = line.mid( idx + 1 ).stripWhiteSpace();
76 static const char* pixmap_not_found_xpm[] = {
98 class SUITApp_Session: public SUIT_Session
101 SUITApp_Session( bool theIniFormat ) : SUIT_Session(), myIniFormat ( theIniFormat ) {}
102 virtual ~SUITApp_Session() {}
105 virtual SUIT_ResourceMgr* createResourceMgr( const QString& appName ) const
107 SUIT_ResourceMgr* resMgr = 0;
110 resMgr = new SUIT_ResourceMgr( appName );
111 resMgr->setCurrentFormat( "ini" );
115 resMgr = new SUIT_ResourceMgr( appName, QString( "%1Config" ) );
116 resMgr->setVersion( salomeVersion() );
117 resMgr->setCurrentFormat( "xml" );
122 static QPixmap defaultPixmap( pixmap_not_found_xpm );
123 resMgr->setDefaultPixmap( defaultPixmap );
124 resMgr->setOption( "translators", QString( "%P_msg_%L.qm|%P_icons.qm|%P_images.qm" ) );
133 int main( int args, char* argv[] )
135 #ifdef SUIT_ENABLE_PYTHON
137 PySys_SetArgv( args, argv );
141 bool noExceptHandling = false;
142 bool iniFormat = false;
143 for ( int i = 1; i < args /*&& !noExceptHandling*/; i++ )
145 if ( !strcmp( argv[i], "/noexcepthandling" ) )
146 noExceptHandling = true;
147 else if ( !strcmp( argv[i], "--format=ini") )
150 argList.append( QString( argv[i] ) );
153 SUITApp_Application app( args, argv );
156 if ( !argList.isEmpty() )
158 SUITApp_Session* aSession = new SUITApp_Session( iniFormat );
159 SUIT_Application* theApp = aSession->startApplication( argList.first() );
162 if ( !noExceptHandling )
163 app.setHandler( aSession->handler() );
165 // if ( !app.mainWidget() )
166 // app.setMainWidget( theApp->desktop() );