#include <iostream>
#include <unistd.h>
-#include <qthread.h>
+#include <qdir.h>
+#include <qfile.h>
#include <qapplication.h>
-#include <qlabel.h>
#include <qwaitcondition.h>
#include "Utils_SALOME_Exception.hxx"
* - get session state
*/
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
+QString salomeVersion()
+{
+ QString path( ::getenv( "GUI_ROOT_DIR" ) );
+ if ( !path.isEmpty() )
+ path += QDir::separator();
+ path += QString( "bin/salome/VERSION" );
+
+ QFile vf( path );
+ if ( !vf.open( IO_ReadOnly ) )
+ return QString::null;
+
+ QString line;
+ vf.readLine( line, 1024 );
+ vf.close();
+
+ if ( line.isEmpty() )
+ return QString::null;
+
+ while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
+ line.remove( line.length() - 1, 1 );
+
+ QString ver;
+ int idx = line.findRev( ":" );
+ if ( idx != -1 )
+ ver = line.mid( idx + 1 ).stripWhiteSpace();
+
+ return ver;
+}
PyObject *salome_shared_modules_module = NULL;
+
void MessageOutput( QtMsgType type, const char *msg )
{
switch ( type ) {
virtual SUIT_ResourceMgr* createResourceMgr( const QString& appName ) const
{
SUIT_ResourceMgr* resMgr = new SUIT_ResourceMgr( appName, QString( "%1Config" ) );
+ resMgr->setVersion( salomeVersion() );
resMgr->setCurrentFormat( "xml" );
return resMgr;
}
SUIT_ExceptionHandler* myHandler;
};
-
-
-
int main(int argc, char **argv)
{
qInstallMsgHandler( MessageOutput );
/*
- * Python initialisation : only once
- */
+ char* _argv_0[512];
+ strcpy( (char*)_argv_0, (char*)argv[0] );
+ */
+
+ // QApplication should be create before all other operations
+ // When uses QApplication::libraryPaths() (example, QFile::encodeName())
+ // qApp used for detection of the executable dir path.
+ SALOME_QApplication _qappl( argc, argv );
+ ASSERT( QObject::connect(&_qappl, SIGNAL( lastWindowClosed() ), &_qappl, SLOT( quit() ) ) );
+ QString path( ::getenv( "GUI_ROOT_DIR" ) );
+ if ( !path.isEmpty() )
+ path += QDir::separator();
+ path += QString( "bin/salome" );
+ _qappl.addLibraryPath( path );
+ _qappl.setStyle( "salome" );
+
+ /*
+ Python initialisation : only once
+ */
+
int _argc = 1;
char* _argv[] = {""};
KERNEL_PYTHON::init_python(_argc,_argv);
// this thread wakes up, and lock mutex
INFOS("Session activated, Launch IAPP...");
-
+ /*
int qArgc = 1;
+ argv[0] = (char*)_argv_0;
SALOME_QApplication* _qappl = new SALOME_QApplication( qArgc, argv );
+
+ QStringList lst = _qappl->libraryPaths();
+ for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
+ printf( "=====> Library path: %s\n", (*it).latin1() );
+
+ _qappl->setStyle( "salome" );
+
+ ASSERT ( QObject::connect(_qappl, SIGNAL(lastWindowClosed()), _qappl, SLOT(quit()) ) );
+ */
INFOS("creation QApplication");
_GUIMutex.unlock();
- ASSERT ( QObject::connect(_qappl, SIGNAL(lastWindowClosed()), _qappl, SLOT(quit()) ) );
-
// 3.1 SUIT_Session creation
SUIT_Session* aGUISession = new SALOME_Session();
INFOS("creation SUIT_Application");
{
MESSAGE("run(): starting the main event loop");
-// 3.2 load SalomeApp dynamic library
-#ifdef WNT
- SUIT_Application* aGUIApp = aGUISession->startApplication( "SalomeApp.dll", 0, 0 );
-#else
- SUIT_Application* aGUIApp = aGUISession->startApplication( "libSalomeApp.so", 0, 0 );
-#endif
+ // 3.2 load SalomeApp dynamic library
+ SUIT_Application* aGUIApp = aGUISession->startApplication( "SalomeApp", 0, 0 );
if ( aGUIApp )
{
- _qappl->setHandler( aGUISession->handler() ); // after loading SalomeApp application
+ _qappl.setHandler( aGUISession->handler() ); // after loading SalomeApp application
// aGUISession contains SalomeApp_ExceptionHandler
- result = _qappl->exec();
+ result = _qappl.exec();
}
break;
}