From: vsr Date: Mon, 14 May 2007 15:55:55 +0000 (+0000) Subject: Porting to Qt4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2e5b96278afc2455c8729d1297277a5e9cfa68f3;p=modules%2Fgui.git Porting to Qt4 --- diff --git a/src/SUITApp/Makefile.am b/src/SUITApp/Makefile.am index 6e76029de..e79026278 100644 --- a/src/SUITApp/Makefile.am +++ b/src/SUITApp/Makefile.am @@ -25,13 +25,16 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am lib_LTLIBRARIES = libSUITApp.la -salomeinclude_HEADERS= SUITApp_Application.h +salomeinclude_HEADERS= \ + SUITApp_Application.h -dist_libSUITApp_la_SOURCES= \ - SUITApp.cxx \ +dist_libSUITApp_la_SOURCES= \ + SUITApp.cxx \ SUITApp_Application.cxx -MOC_FILES=SUITApp_Application_moc.cxx +MOC_FILES= \ + SUITApp_Application_moc.cxx + nodist_libSUITApp_la_SOURCES= $(MOC_FILES) nodist_salomeres_DATA= SUITApp_msg_en.qm @@ -40,7 +43,7 @@ libSUITApp_la_CPPFLAGS=$(QT_INCLUDES) $(PYTHON_INCLUDES) \ -I$(srcdir)/../SUIT -I$(srcdir)/../Qtx libSUITApp_la_LDFLAGS=$(QT_MT_LIBS) -libSUITApp_la_LIBADD= ../SUIT/libsuit.la ../Qtx/libqtx.la +libSUITApp_la_LIBADD=../Qtx/libqtx.la ../SUIT/libsuit.la if ENABLE_PYCONSOLE libSUITApp_la_LDFLAGS+= -Xlinker -export-dynamic $(PYTHON_LIBS) @@ -54,4 +57,4 @@ dist_SUITApp_SOURCES=SUITApp.cxx SUITApp_CPPFLAGS=$(QT_INCLUDES) $(PYTHON_INCLUDES) \ -I$(srcdir)/../SUIT -I$(srcdir)/../Qtx -SUITApp_LDADD= libSUITApp.la ../SUIT/libsuit.la ../Qtx/libqtx.la +SUITApp_LDADD= libSUITApp.la ../Qtx/libqtx.la ../SUIT/libsuit.la diff --git a/src/SUITApp/SUITApp.cxx b/src/SUITApp/SUITApp.cxx index f343c435e..5647e6bad 100644 --- a/src/SUITApp/SUITApp.cxx +++ b/src/SUITApp/SUITApp.cxx @@ -16,7 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#if defined WNT +#if defined WIN32 #undef SUIT_ENABLE_PYTHON //#else @@ -26,20 +26,21 @@ #include "SUITApp_Application.h" #include -#include +//#include #include -#include +// TODO +//#include #ifdef SUIT_ENABLE_PYTHON #include #endif -#include -#include -#include -#include -#include +#include +#include +//#include +#include +#include #include @@ -52,11 +53,10 @@ QString salomeVersion() path += QString( "bin/salome/VERSION" ); QFile vf( path ); - if ( !vf.open( IO_ReadOnly ) ) + if ( !vf.open( QFile::ReadOnly ) ) return QString::null; - QString line; - vf.readLine( line, 1024 ); + QString line = vf.readLine( 1024 ); vf.close(); if ( line.isEmpty() ) @@ -66,9 +66,9 @@ QString salomeVersion() line.remove( line.length() - 1, 1 ); QString ver; - int idx = line.findRev( ":" ); + int idx = line.lastIndexOf( ":" ); if ( idx != -1 ) - ver = line.mid( idx + 1 ).stripWhiteSpace(); + ver = line.mid( idx + 1 ).trimmed(); return ver; } @@ -108,7 +108,7 @@ public: SUIT_ResourceMgr* resMgr = 0; if ( myIniFormat ) { - resMgr = new SUIT_ResourceMgr( appName ); + resMgr = new SUIT_ResourceMgr( appName, QString( "%1Config" ) ); resMgr->setCurrentFormat( "ini" ); } else @@ -160,69 +160,80 @@ int main( int args, char* argv[] ) if ( !argList.isEmpty() ) { SUITApp_Session* aSession = new SUITApp_Session( iniFormat ); + // TODO +/* QtxSplash* splash = 0; - if ( !noSplash ) { + if ( !noSplash ) + { SUIT_ResourceMgr* resMgr = aSession->createResourceMgr( argList.first() ); - if ( resMgr ) { - resMgr->loadLanguage(); - QString splashIcon, splashInfo, splashTextColors; - resMgr->value( "splash", "image", splashIcon ); - resMgr->value( "splash", "info", splashInfo, false ); - resMgr->value( "splash", "text_colors", splashTextColors ); - QString appName = QObject::tr( "APP_NAME" ).stripWhiteSpace(); - QString appVersion = QObject::tr( "APP_VERSION" ).stripWhiteSpace(); - if ( appVersion == "APP_VERSION" ) { - if ( appName == "APP_NAME" || appName.lower() == "salome" ) - appVersion = salomeVersion(); - else - appVersion = ""; - } - QPixmap px( splashIcon ); - if ( !px.isNull() ) { - splash = QtxSplash::splash( px ); - if ( !splashTextColors.isEmpty() ) { - QStringList colors = QStringList::split( "|", splashTextColors ); - QColor c1, c2; - if ( colors.count() > 0 ) c1 = QColor( colors[0] ); - if ( colors.count() > 1 ) c2 = QColor( colors[1] ); - splash->setTextColors( c1, c2 ); - } - else { - splash->setTextColors( Qt::white, Qt::black ); - } + if ( resMgr ) + { + resMgr->loadLanguage(); + QString splashIcon, splashInfo, splashTextColors; + resMgr->value( "splash", "image", splashIcon ); + resMgr->value( "splash", "info", splashInfo, false ); + resMgr->value( "splash", "text_colors", splashTextColors ); + QString appName = QObject::tr( "APP_NAME" ).stripWhiteSpace(); + QString appVersion = QObject::tr( "APP_VERSION" ).stripWhiteSpace(); + if ( appVersion == "APP_VERSION" ) + { + if ( appName == "APP_NAME" || appName.toLower() == "salome" ) + appVersion = salomeVersion(); + else + appVersion = ""; + } + QPixmap px( splashIcon ); + if ( !px.isNull() ) + { + splash = QtxSplash::splash( px ); + if ( !splashTextColors.isEmpty() ) + { + QStringList colors = QStringList::split( "|", splashTextColors ); + QColor c1, c2; + if ( colors.count() > 0 ) + c1 = QColor( colors[0] ); + if ( colors.count() > 1 ) + c2 = QColor( colors[1] ); + splash->setTextColors( c1, c2 ); + } + else + { + splash->setTextColors( Qt::white, Qt::black ); + } #ifdef _DEBUG_ - splash->setHideOnClick( true ); + splash->setHideOnClick( true ); #endif - QFont f = splash->font(); - f.setBold( true ); - splash->setFont( f ); - if ( !splashInfo.isEmpty() ) { - splashInfo.replace( QRegExp( "%A" ), appName ); - splashInfo.replace( QRegExp( "%V" ), QObject::tr( "ABOUT_VERSION" ).arg( appVersion ) ); - splashInfo.replace( QRegExp( "%L" ), QObject::tr( "ABOUT_LICENSE" ) ); - splashInfo.replace( QRegExp( "%C" ), QObject::tr( "ABOUT_COPYRIGHT" ) ); - splashInfo.replace( QRegExp( "\\\\n" ), "\n" ); - splash->message( splashInfo ); - } - splash->show(); - qApp->processEvents(); - } + QFont f = splash->font(); + f.setBold( true ); + splash->setFont( f ); + if ( !splashInfo.isEmpty() ) + { + splashInfo.replace( QRegExp( "%A" ), appName ); + splashInfo.replace( QRegExp( "%V" ), QObject::tr( "ABOUT_VERSION" ).arg( appVersion ) ); + splashInfo.replace( QRegExp( "%L" ), QObject::tr( "ABOUT_LICENSE" ) ); + splashInfo.replace( QRegExp( "%C" ), QObject::tr( "ABOUT_COPYRIGHT" ) ); + splashInfo.replace( QRegExp( "\\\\n" ), "\n" ); + splash->message( splashInfo ); + } + splash->show(); + QApplication::instance()->processEvents(); + } } } +*/ SUIT_Application* theApp = aSession->startApplication( argList.first() ); if ( theApp ) { if ( !noExceptHandling ) app.setHandler( aSession->handler() ); -// if ( !app.mainWidget() ) -// app.setMainWidget( theApp->desktop() ); - if ( splash ) - splash->finish( theApp->desktop() ); +// TODO +// if ( splash ) +// splash->finish( theApp->desktop() ); result = app.exec(); - if ( splash ) - delete splash; +// TODO +// delete splash; } delete aSession; } diff --git a/src/SUITApp/SUITApp.pro b/src/SUITApp/SUITApp.pro new file mode 100644 index 000000000..157b8f4a0 --- /dev/null +++ b/src/SUITApp/SUITApp.pro @@ -0,0 +1,18 @@ +TEMPLATE = app +TARGET = SUITApp +DESTDIR = ../../bin +MOC_DIR = ../../moc +OBJECTS_DIR = ../../obj/$$TARGET + +INCLUDEPATH += ../../include ../Qtx ../SUIT +LIBS += -L../../lib -lqtx -lsuit + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 + +HEADERS = SUITApp_Application.h + +SOURCES = SUITApp.cxx +SOURCES += SUITApp_Application.cxx diff --git a/src/SUITApp/SUITApp_Application.cxx b/src/SUITApp/SUITApp_Application.cxx index bf32979de..7027184df 100644 --- a/src/SUITApp/SUITApp_Application.cxx +++ b/src/SUITApp/SUITApp_Application.cxx @@ -18,12 +18,11 @@ // #include "SUITApp_Application.h" -#include "SUIT_Session.h" -#include "SUIT_MessageBox.h" -#include "SUIT_ExceptionHandler.h" +#include +#include -#include -#include +#include +#include #ifdef WIN32 #include @@ -39,7 +38,7 @@ SUITApp_Application::SUITApp_Application( int& argc, char** argv, SUIT_Exception : QApplication( argc, argv ), myExceptHandler( hand ) { - QString path = QFileInfo( argv[0] ).dirPath() + QDir::separator() + "../../resources"; + QString path = SUIT_Tools::dir( argv[0] ) + QDir::separator() + "../../resources"; path = QDir::convertSeparators( QDir( path ).canonicalPath() ); QTranslator* strTbl = new QTranslator( 0 ); @@ -69,20 +68,6 @@ myExceptHandler( hand ) */ bool SUITApp_Application::notify( QObject* receiver, QEvent* e ) { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) < 0x060101 - // Disable GUI user actions while python command is executed - if (SUIT_Session::IsPythonExecuted()) { - // Disable mouse and keyboard events - QEvent::Type aType = e->type(); - if (aType == QEvent::MouseButtonPress || aType == QEvent::MouseButtonRelease || - aType == QEvent::MouseButtonDblClick || aType == QEvent::MouseMove || - aType == QEvent::Wheel || aType == QEvent::ContextMenu || - aType == QEvent::KeyPress || aType == QEvent::KeyRelease || - aType == QEvent::Accel || aType == QEvent::AccelOverride) - return false; - } -#endif - return myExceptHandler ? myExceptHandler->handle( receiver, e ) : QApplication::notify( receiver, e ); } diff --git a/src/SUITApp/SUITApp_Application.h b/src/SUITApp/SUITApp_Application.h index 479f07a20..808e464cc 100644 --- a/src/SUITApp/SUITApp_Application.h +++ b/src/SUITApp/SUITApp_Application.h @@ -19,7 +19,7 @@ #ifndef SUITAPP_APPLICATION_H #define SUITAPP_APPLICATION_H -#include +#include class SUIT_ExceptionHandler;