]> SALOME platform Git repositories - modules/gui.git/blob - src/SUITApp/SUITApp_Application.cxx
Salome HOME
744d84acc481b4ee0ecc7302dac66b89e4b13626
[modules/gui.git] / src / SUITApp / SUITApp_Application.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #include "SUITApp_Application.h"
20
21 #include "SUIT_MessageBox.h"
22 #include "SUIT_ExceptionHandler.h"
23
24 #include <qdir.h>
25 #include <qfileinfo.h>
26
27 #ifdef WIN32
28 #include <windows.h>
29 #include <winbase.h>
30 #else
31 #include <unistd.h>
32 #endif
33
34 SUITApp_Application::SUITApp_Application( int& argc, char** argv, SUIT_ExceptionHandler* hand )
35 : QApplication( argc, argv ),
36 myExceptHandler( hand )
37 {
38   QString path = QFileInfo( argv[0] ).dirPath() + QDir::separator() + "../../resources";
39   path = QDir::convertSeparators( QDir( path ).canonicalPath() );
40
41   QTranslator* strTbl = new QTranslator( 0 );
42   if ( strTbl->load( "SUITApp_msg_en.po", path  ) )
43     installTranslator( strTbl );
44   else
45     delete strTbl;
46 }
47
48 SUITApp_Application::SUITApp_Application( int& argc, char** argv, Type type, SUIT_ExceptionHandler* hand )
49 : QApplication( argc, argv, type ),
50 myExceptHandler( hand )
51 {
52     QTranslator* strTbl = new QTranslator( 0 );
53     strTbl->load( "resources\\SUITApp_msg_en.po" );
54     installTranslator( strTbl );
55 }
56
57 bool SUITApp_Application::notify( QObject* receiver, QEvent* e )
58 {
59   return myExceptHandler ? myExceptHandler->handle( receiver, e ) :
60                            QApplication::notify( receiver, e );
61 }
62
63 void SUITApp_Application::setHandler( SUIT_ExceptionHandler* hand )
64 {
65         myExceptHandler = hand;
66 }
67
68 SUIT_ExceptionHandler* SUITApp_Application::handler() const
69 {
70   return myExceptHandler;
71 }