-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 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
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-//#if defined WIN32
-//#ifdef SUIT_ENABLE_PYTHON
-//#undef SUIT_ENABLE_PYTHON
+//#ifdefined WIN32
+//#ifndef DISABLE_PYCONSOLE
+//#define DISABLE_PYCONSOLE
//#endif
//#else //#if defined WIN32
-//#ifndef SUIT_ENABLE_PYTHON
+//#ifdef DISABLE_PYCONSOLE
// NOTE: DO NOT DELETE THIS DEFINITION ON LINUX
// or make sure Python is initialized in main() in any case
// Otherwise, application based on light SALOME and using Python
// are unlikely to work properly.
-//#define SUIT_ENABLE_PYTHON
+//#undef DISABLE_PYCONSOLE
//#include <Python.h>
//#endif
//
-#ifdef SUIT_ENABLE_PYTHON
+#ifndef DISABLE_PYCONSOLE
#include "SUITApp_init_python.hxx"
#endif
#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 <QDir>
#include <QFile>
+#include <QLocale>
#include <QRegExp>
#include <QString>
#include <QStringList>
// }
// }
-/* XPM */
-static const char* pixmap_not_found_xpm[] = {
-"16 16 3 1",
-" c None",
-". c #000000",
-"+ c #A80000",
-" ",
-" ",
-" . . ",
-" .+. .+. ",
-" .+++. .+++. ",
-" .+++.+++. ",
-" .+++++. ",
-" .+++. ",
-" .+++++. ",
-" .+++.+++. ",
-" .+++. .+++. ",
-" .+. .+. ",
-" . . ",
-" ",
-" ",
-" "};
-
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
if ( resMgr )
{
- static QPixmap defaultPixmap( pixmap_not_found_xpm );
- resMgr->setDefaultPixmap( defaultPixmap );
resMgr->setOption( "translators", QString( "%P_msg_%L.qm|%P_icons.qm|%P_images.qm" ) );
}
return resMgr;
int main( int argc, char* argv[] )
{
- //#ifdef SUIT_ENABLE_PYTHON
+ //#ifndef DISABLE_PYCONSOLE
// // First of all initialize Python, as in complex multi-component applications
// // someone else might initialize it some way unsuitable for light SALOME!
// Py_SetProgramName( argv[0] );
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 <qtdir>/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() );
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 )
}
}
-#ifdef SUIT_ENABLE_PYTHON
+#ifndef DISABLE_PYCONSOLE
//...Initialize python
int _argc = 1;
char* _argv[] = {(char*)""};
SUIT_PYTHON::init_python(_argc,_argv);
-
- PyEval_RestoreThread( SUIT_PYTHON::_gtstate );
-
- if ( !SUIT_PYTHON::salome_shared_modules_module ) // import only once
- SUIT_PYTHON::salome_shared_modules_module = PyImport_ImportModule( (char*)"salome_shared_modules" );
- if ( !SUIT_PYTHON::salome_shared_modules_module )
- PyErr_Print();
-
- PyEval_ReleaseThread( SUIT_PYTHON::_gtstate );
-
#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;