Salome HOME
Initial version
[modules/gui.git] / src / SUITApp / SUITApp_Application.cxx
1 #include "SUITApp_Application.h"
2
3 #include "SUIT_MessageBox.h"
4 #include "SUIT_ExceptionHandler.h"
5
6 #include <qdir.h>
7 #include <qfileinfo.h>
8
9 #ifdef WIN32
10 #include <windows.h>
11 #include <winbase.h>
12 #else
13 #include <unistd.h>
14 #endif
15
16 SUITApp_Application::SUITApp_Application( int& argc, char** argv, SUIT_ExceptionHandler* hand )
17 : QApplication( argc, argv ),
18 myExceptHandler( hand )
19 {
20   QString path = QFileInfo( argv[0] ).dirPath() + QDir::separator() + "../../resources";
21   path = QDir::convertSeparators( QDir( path ).canonicalPath() );
22
23   QTranslator* strTbl = new QTranslator( 0 );
24   if ( strTbl->load( "SUITApp_msg_en.po", path  ) )
25     installTranslator( strTbl );
26   else
27     delete strTbl;
28 }
29
30 SUITApp_Application::SUITApp_Application( int& argc, char** argv, Type type, SUIT_ExceptionHandler* hand )
31 : QApplication( argc, argv, type ),
32 myExceptHandler( hand )
33 {
34     QTranslator* strTbl = new QTranslator( 0 );
35     strTbl->load( "resources\\SUITApp_msg_en.po" );
36     installTranslator( strTbl );
37 }
38
39 bool SUITApp_Application::notify( QObject* receiver, QEvent* e )
40 {
41   return myExceptHandler ? myExceptHandler->handle( receiver, e ) :
42                            QApplication::notify( receiver, e );
43 }
44
45 void SUITApp_Application::setHandler( SUIT_ExceptionHandler* hand )
46 {
47         myExceptHandler = hand;
48 }
49
50 SUIT_ExceptionHandler* SUITApp_Application::handler() const
51 {
52   return myExceptHandler;
53 }