Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[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/ or email : webmaster.salome@opencascade.com
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 /*!
35   Constructor
36 */
37 SUITApp_Application::SUITApp_Application( int& argc, char** argv, SUIT_ExceptionHandler* hand )
38 : QApplication( argc, argv ),
39 myExceptHandler( hand )
40 {
41   QString path = QFileInfo( argv[0] ).dirPath() + QDir::separator() + "../../resources";
42   path = QDir::convertSeparators( QDir( path ).canonicalPath() );
43
44   QTranslator* strTbl = new QTranslator( 0 );
45   if ( strTbl->load( "SUITApp_msg_en.po", path  ) )
46     installTranslator( strTbl );
47   else
48     delete strTbl;
49 }
50
51 /*!
52   Constructor
53 */
54 SUITApp_Application::SUITApp_Application( int& argc, char** argv, Type type, SUIT_ExceptionHandler* hand )
55 : QApplication( argc, argv, type ),
56 myExceptHandler( hand )
57 {
58     QTranslator* strTbl = new QTranslator( 0 );
59     strTbl->load( "resources\\SUITApp_msg_en.po" );
60     installTranslator( strTbl );
61 }
62
63 /*!
64   Sends event to receiver
65   \return the value that is returned from the receiver's event handler
66   \param e - event
67   \param receiver - receiver
68 */
69 bool SUITApp_Application::notify( QObject* receiver, QEvent* e )
70 {
71   return myExceptHandler ? myExceptHandler->handle( receiver, e ) :
72                            QApplication::notify( receiver, e );
73 }
74
75 /*!
76   Changes exception handler
77   \param hand - new handler
78 */
79 void SUITApp_Application::setHandler( SUIT_ExceptionHandler* hand )
80 {
81         myExceptHandler = hand;
82 }
83
84 /*!
85   \return exception handler
86 */
87 SUIT_ExceptionHandler* SUITApp_Application::handler() const
88 {
89   return myExceptHandler;
90 }