2 //=============================================================================
3 // File : SALOME_Session_QThread.cxx
4 // Created : mar jun 19 15:18:31 CEST 2001
5 // Author : Paul RASCLE, EDF
7 // Copyright : EDF 2001
9 //=============================================================================
11 #include <qapplication.h>
14 #include "utilities.h"
15 #include "SALOME_Session_QThread.hxx"
16 #include "SALOME_NamingService.hxx"
17 #include "SALOMEGUI_Application.h"
19 #include "QAD_MessageBox.h"
20 #include "QAD_Application.h"
21 #include "QAD_Settings.h"
22 #include "QAD_Config.h"
23 #include "QAD_Tools.h"
24 // only to use findFile method : perhaps put it in QAD_Tools ???
25 #include "QAD_ResourceMgr.h"
29 #include <SALOMEconfig.h>
30 #include CORBA_SERVER_HEADER(SALOMEDS)
32 //=============================================================================
33 /*! SALOME_Session_QThread
36 //=============================================================================
38 SALOME_Session_QThread::SALOME_Session_QThread(int argc, char ** argv) : QThread()
47 //=============================================================================
49 * Creates one QApplication for the all the session life.
50 * Executes the Qt main window of the GUI on a separate thread
52 //=============================================================================
54 void SALOME_Session_QThread::run()
58 _qappl = new QApplication(_argc, _argv );
59 INFOS("creation QApplication");
62 QAD_ASSERT ( QObject::connect(_qappl, SIGNAL(lastWindowClosed()), _qappl, SLOT(quit()) ) );
63 _mw = new SALOMEGUI_Application ( "MDTV-Standard", "HDF", "hdf" );
64 INFOS("creation SALOMEGUI_Application");
66 if ( !SALOMEGUI_Application::addToDesktop ( _mw, _NS ) )
68 QAD_MessageBox::error1 ( 0,
69 QObject::tr("ERR_ERROR"),
70 QObject::tr("ERR_APP_INITFAILED"),
71 QObject::tr("BUT_OK") );
76 QFileInfo prgInfo(_argv[0]);
77 QDir prgDir(prgInfo.dirPath(true));
78 QAD_CONFIG->setPrgDir(prgDir); // CWD is program directory
79 QAD_CONFIG->createConfigFile(false); // Create config file ~/.tr(MEN_APPNAME)/tr(MEN_APPNAME).conf if there's none
80 QAD_CONFIG->readConfigFile(); // Read config file
82 _qappl->setPalette( QAD_Application::getPalette() );
84 /* Run 'SALOMEGUI' application */
85 QAD_Application::run();
87 // T2.12 - catch exceptions thrown on attempts to modified a locked study
90 MESSAGE("run(): starting the main event loop")
91 _ret = _qappl->exec();
94 catch(SALOMEDS::StudyBuilder::LockProtection&) {
95 MESSAGE("run(): An attempt to modify a locked study has not been handled by QAD_Operation")
96 QApplication::restoreOverrideCursor();
97 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
98 QObject::tr("WRN_WARNING"),
99 QObject::tr("WRN_STUDY_LOCKED"),
100 QObject::tr("BUT_OK") );
103 MESSAGE("run(): An exception has been caught")
104 QApplication::restoreOverrideCursor();
105 QAD_MessageBox::error1 ( (QWidget*)QAD_Application::getDesktop(),
106 QObject::tr("ERR_ERROR"),
107 QObject::tr("ERR_APP_EXCEPTION"),
108 QObject::tr("BUT_OK") );
112 QString confMsg = "Settings create $HOME/." + QObject::tr("MEN_APPNAME") + "/" + QObject::tr("MEN_APPNAME") + ".conf";
114 QAD_CONFIG->createConfigFile(true);
118 //=============================================================================
120 * gives the naming service interface
122 //=============================================================================
123 void SALOME_Session_QThread::setNamingService(SALOME_NamingService *ns)