X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSUITApp%2FSUITApp.cxx;h=c3b31f35dab4cf0b2bec03ce7520a26b08951739;hb=5015bf4f1283a8ca5d6ab862f235322755cb7be9;hp=1f693f34b506aa56787ea30a2a9079245ca23e06;hpb=5591003bbd7a8bb88d87944015ecb01243ffce99;p=modules%2Fgui.git diff --git a/src/SUITApp/SUITApp.cxx b/src/SUITApp/SUITApp.cxx index 1f693f34b..c3b31f35d 100644 --- a/src/SUITApp/SUITApp.cxx +++ b/src/SUITApp/SUITApp.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -46,11 +46,14 @@ #include "SUIT_LicenseDlg.h" #include "SUIT_ResourceMgr.h" #include "SUIT_Session.h" +#ifdef USE_SALOME_STYLE #include "Style_Salome.h" +#endif // USE_SALOME_STYLE #include "QtxSplash.h" #include #include +#include #include #include #include @@ -100,7 +103,7 @@ static QString getAppName( const QString& libName ) 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 @@ -162,17 +165,42 @@ int main( int argc, char* argv[] ) argList.append( QString( argv[i] ) ); } - // add $QTDIR/plugins to the pluins search path for image plugins - QString qtdir( ::getenv( "QTDIR" ) ); + // 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() ); + } + } + +#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) + // RNV: setup the default format: + // QSurfaceFormat should be set before creation of QApplication, + // so to avoid conflicts beetween SALOME and ParaView QSurfaceFormats we should merge theirs formats + // (see void Qtx::initDefaultSurfaceFormat()) and set the resultant format here. + Qtx::initDefaultSurfaceFormat(); +#endif + + // add /plugins directory to the pluins search path for image plugins + QString qtdir = Qtx::qtDir( "plugins" ); if ( !qtdir.isEmpty() ) - QApplication::addLibraryPath( QDir( qtdir ).absoluteFilePath( "plugins" ) ); + QApplication::addLibraryPath( qtdir ); +// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5 +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) //Set a "native" graphic system in case if application runs on the remote host QString remote(::getenv("REMOTEHOST")); QString client(::getenv("SSH_CLIENT")); if(remote.length() > 0 || client.length() > 0 ) { QApplication::setGraphicsSystem(QLatin1String("native")); } +#endif SUITApp_Application app( argc, argv ); QString cfgAppName = getAppName( argList.isEmpty() ? QString() : argList.first() ); @@ -190,12 +218,17 @@ int main( int argc, char* argv[] ) #ifdef WIN32 DWORD aLen=1024; - char aStr[1024]; + TCHAR aStr[1024]; HANDLE aToken=0; HANDLE hProcess = GetCurrentProcess(); OpenProcessToken(hProcess,TOKEN_QUERY,&aToken); - if( GetUserProfileDirectory( aToken, aStr, &aLen ) ) - env = aStr; + if( GetUserProfileDirectory( aToken, aStr, &aLen ) ) { +#ifdef UNICODE + env = QString::fromWCharArray(aStr); +#else + env = aStr; +#endif + } #else if ( ::getenv( "HOME" ) ) @@ -212,9 +245,9 @@ int main( int argc, char* argv[] ) 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 ) @@ -254,22 +287,23 @@ int main( int argc, char* argv[] ) SUIT_PYTHON::init_python(_argc,_argv); #endif - SUIT_Application* theApp = aSession->startApplication( argList.first() ); + SUIT_Application* theApp = aSession.startApplication( argList.first() ); if ( theApp ) { +#ifdef USE_SALOME_STYLE Style_Salome::initialize( theApp->resourceMgr() ); if ( theApp->resourceMgr()->booleanValue( "Style", "use_salome_style", true ) ) Style_Salome::apply(); +#endif // USE_SALOME_STYLE if ( !noExceptHandling ) - app.setHandler( aSession->handler() ); + app.setHandler( aSession.handler() ); if ( splash ) splash->finish( theApp->desktop() ); result = app.exec(); } - delete aSession; } return result;