1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "SUITApp_Application.h"
21 #include "SUIT_Session.h"
22 #include "SUIT_MessageBox.h"
23 #include "SUIT_ExceptionHandler.h"
26 #include <qfileinfo.h>
38 SUITApp_Application::SUITApp_Application( int& argc, char** argv, SUIT_ExceptionHandler* hand )
39 : QApplication( argc, argv ),
40 myExceptHandler( hand )
42 QString path = QFileInfo( argv[0] ).dirPath() + QDir::separator() + "../../resources";
43 path = QDir::convertSeparators( QDir( path ).canonicalPath() );
45 QTranslator* strTbl = new QTranslator( 0 );
46 if ( strTbl->load( "SUITApp_msg_en.po", path ) )
47 installTranslator( strTbl );
55 SUITApp_Application::SUITApp_Application( int& argc, char** argv, Type type, SUIT_ExceptionHandler* hand )
56 : QApplication( argc, argv, type ),
57 myExceptHandler( hand )
59 QTranslator* strTbl = new QTranslator( 0 );
60 strTbl->load( "resources\\SUITApp_msg_en.po" );
61 installTranslator( strTbl );
65 Sends event to receiver
66 \return the value that is returned from the receiver's event handler
68 \param receiver - receiver
70 bool SUITApp_Application::notify( QObject* receiver, QEvent* e )
72 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) < 0x060101
73 // Disable GUI user actions while python command is executed
74 if (SUIT_Session::IsPythonExecuted()) {
75 // Disable mouse and keyboard events
76 QEvent::Type aType = e->type();
77 if (aType == QEvent::MouseButtonPress || aType == QEvent::MouseButtonRelease ||
78 aType == QEvent::MouseButtonDblClick || aType == QEvent::MouseMove ||
79 aType == QEvent::Wheel || aType == QEvent::ContextMenu ||
80 aType == QEvent::KeyPress || aType == QEvent::KeyRelease ||
81 aType == QEvent::Accel || aType == QEvent::AccelOverride)
86 return myExceptHandler ? myExceptHandler->handle( receiver, e ) :
87 QApplication::notify( receiver, e );
91 Changes exception handler
92 \param hand - new handler
94 void SUITApp_Application::setHandler( SUIT_ExceptionHandler* hand )
96 myExceptHandler = hand;
100 \return exception handler
102 SUIT_ExceptionHandler* SUITApp_Application::handler() const
104 return myExceptHandler;