//
#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
#include <QDir>
#include <QFileInfo>
{
QString pathName;
- QStringList arguments = QApplication::arguments();
+ QStringList arguments;
+ if ( SUIT_Session::session() ) arguments = SUIT_Session::session()->arguments();
// Try config file, given in arguments
for (int i = 1; i < arguments.count(); i++) {
QRegExp rx ("--resources=(.+)");
mySession = this;
}
+SUIT_Session::SUIT_Session( int argc, char** argv )
+: QObject(),
+ myResMgr( 0 ),
+ myActiveApp( 0 ),
+ myHandler( 0 ),
+ myExitStatus( NORMAL ),
+ myExitFlags ( 0 )
+{
+ SUIT_ASSERT( !mySession )
+
+ mySession = this;
+
+ for ( int i = 0; i < argc; i++ )
+ myArguments << QString( argv[i] );
+}
+
/*!destructor. Clear applications list and set mySession to zero.*/
SUIT_Session::~SUIT_Session()
{
mySession = 0;
}
+/*!
+ Get arguments of the current session
+ */
+QStringList SUIT_Session::arguments()
+{
+ QStringList r;
+ if ( !myArguments.isEmpty() ) r = myArguments;
+ else if ( QApplication::instance() ) r = QApplication::arguments();
+ return r;
+}
+
/*! \retval return mySession */
SUIT_Session* SUIT_Session::session()
{
#include <QList>
#include <QObject>
#include <QString>
+#include <QStringList>
#ifdef WIN32
#include <windows.h>
public:
SUIT_Session();
+ SUIT_Session( int, char** );
virtual ~SUIT_Session();
static SUIT_Session* session();
+ QStringList arguments();
+
SUIT_Application* startApplication( const QString&, int = 0, char** = 0 );
QList<SUIT_Application*> applications() const;
QString applicationName( const QString& ) const;
private:
+ QStringList myArguments;
+
SUIT_ResourceMgr* myResMgr;
AppList myAppList;
AppLibMap myAppLibs;
#include <QDir>
#include <QFile>
+#include <QLocale>
#include <QRegExp>
#include <QString>
#include <QStringList>
class SUITApp_Session: public SUIT_Session
{
public:
- SUITApp_Session( bool theIniFormat ) : SUIT_Session(), myIniFormat ( theIniFormat ) {}
+ SUITApp_Session( bool theIniFormat, int argc, char** argv ) : SUIT_Session( argc, argv ), myIniFormat ( theIniFormat ) {}
virtual ~SUITApp_Session() {}
virtual SUIT_ResourceMgr* createResourceMgr( const QString& appName ) const
argList.append( QString( argv[i] ) );
}
+ // set "C" locale if requested via preferences
+ {
+ SUITApp_Session stmp( iniFormat, argc, argv );
+ QApplication::setApplicationName( "salome" );
+ SUIT_ResourceMgr* resMgr = stmp.createResourceMgr( "LightApp" );
+ bool isCloc = resMgr->booleanValue( "language", "locale", true );
+ if ( isCloc ) {
+ QLocale::setDefault( QLocale::c() );
+ }
+ else {
+ QLocale::setDefault( QLocale::system() );
+ }
+ }
+
// add $QTDIR/plugins to the pluins search path for image plugins
QString qtdir( ::getenv( "QTDIR" ) );
if ( !qtdir.isEmpty() )
if ( !argList.isEmpty() )
{
- SUITApp_Session* aSession = new SUITApp_Session( iniFormat );
+ SUITApp_Session aSession( iniFormat, argc, argv );
QtxSplash* splash = 0;
- SUIT_ResourceMgr* resMgr = aSession->createResourceMgr( argList.first() );
+ SUIT_ResourceMgr* resMgr = aSession.createResourceMgr( argList.first() );
if ( !noSplash )
{
if ( resMgr )
SUIT_PYTHON::init_python(_argc,_argv);
#endif
- SUIT_Application* theApp = aSession->startApplication( argList.first() );
+ SUIT_Application* theApp = aSession.startApplication( argList.first() );
if ( theApp )
{
Style_Salome::initialize( theApp->resourceMgr() );
Style_Salome::apply();
if ( !noExceptHandling )
- app.setHandler( aSession->handler() );
+ app.setHandler( aSession.handler() );
if ( splash )
splash->finish( theApp->desktop() );
result = app.exec();
}
- delete aSession;
}
return result;
class SALOME_Session : public SUIT_Session
{
public:
- SALOME_Session() : SUIT_Session() {}
+ SALOME_Session( int argc, char** argv ) : SUIT_Session( argc, argv ) {}
virtual ~SALOME_Session() {}
public:
if ( !qtdir.isEmpty() )
QApplication::addLibraryPath( QDir( qtdir ).absoluteFilePath( "plugins" ) );
+ // set "C" locale if requested via preferences
{
- SALOME_Session s;
+ SALOME_Session stmp( argc, argv );
QApplication::setApplicationName( "salome" );
- SUIT_ResourceMgr* resMgr = s.createResourceMgr( "SalomeApp" );
+ SUIT_ResourceMgr* resMgr = stmp.createResourceMgr( "SalomeApp" );
bool isCloc = resMgr->booleanValue( "language", "locale", true );
- if ( isCloc ) {
+ if ( isCloc ) {
QLocale::setDefault( QLocale::c() );
}
else {
}
// SUIT_Session creation
- aGUISession = new SALOME_Session();
+ aGUISession = new SALOME_Session( argc, argv );
// Load SalomeApp dynamic library
MESSAGE( "creation SUIT_Application" );