From: imn Date: Wed, 18 Nov 2015 13:16:40 +0000 (+0300) Subject: Restored Qt4 support after porting code X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b01bd643e05fbb684faf7fe029946a817b465bd2;p=modules%2Fgui.git Restored Qt4 support after porting code --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 843bdd168..90f98e1c2 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,9 +153,10 @@ ENDIF() IF(NOT SALOME_BUILD_WITH_QT5) FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtWebKit QtOpenGL QtNetwork) INCLUDE(${QT_USE_FILE}) + #SET(SALOME_USE_PVVIEWER OFF) ELSE() ADD_DEFINITIONS(-fPIC) - #SET(CMAKE_AUTOMOC ON) +# SET(CMAKE_AUTOMOC ON) SET(CMAKE_INCLUDE_CURRENT_DIR ON) FIND_PACKAGE(SalomeQt5 REQUIRED) SET(SALOME_USE_PVVIEWER OFF) @@ -189,8 +190,7 @@ ELSE() ADD_DEFINITIONS("-DDISABLE_PLOT2DVIEWER") ENDIF() IF (SALOME_USE_PVVIEWER) - find_package(ParaView REQUIRED) - #FIND_PACKAGE(SalomeParaView) + FIND_PACKAGE(SalomeParaView) SALOME_LOG_OPTIONAL_PACKAGE(ParaView SALOME_USE_PVVIEWER) ELSE() ADD_DEFINITIONS("-DDISABLE_PVVIEWER") @@ -404,8 +404,16 @@ EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets} # Ensure the variables are always defined for the configure: SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}") SET(SIP_ROOT_DIR "${SIP_ROOT_DIR}") -SET(QT_ROOT_DIR "${QT_ROOT_DIR}") -SET(PYQT_ROOT_DIR "${PYQT_ROOT_DIR}") +IF(NOT SALOME_BUILD_WITH_QT5) + SET(_QT_ROOT_DIR "${QT4_ROOT_DIR}") +ELSE() + SET(_QT_ROOT_DIR "${QT5_ROOT_DIR}") +ENDIF() +IF(NOT SALOME_BUILD_WITH_PYQT5) + SET(_PYQT_ROOT_DIR "${PYQT4_ROOT_DIR}") +ELSE() + SET(_PYQT_ROOT_DIR "${PYQT5_ROOT_DIR}") +ENDIF() SET(CAS_ROOT_DIR "${CAS_ROOT_DIR}") SET(OPENGL_ROOT_DIR "${OPENGL_ROOT_DIR}") SET(VTK_ROOT_DIR "${VTK_ROOT_DIR}") @@ -416,16 +424,21 @@ SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/inc # Build variables that will be expanded when configuring SalomeConfig.cmake: SALOME_CONFIGURE_PREPARE(CAS OpenGL Qwt SIP VTK) IF(NOT SALOME_BUILD_WITH_QT5) - SALOME_CONFIGURE_PREPARE(PyQt4 Qt4) + SALOME_CONFIGURE_PREPARE(Qt4) +ELSE() + SALOME_CONFIGURE_PREPARE(Qt5) +ENDIF() +IF(NOT SALOME_BUILD_WITH_PYQT5) + SALOME_CONFIGURE_PREPARE(PyQt4) ELSE() - SALOME_CONFIGURE_PREPARE(PyQt5 Qt5) + SALOME_CONFIGURE_PREPARE(PyQt5) ENDIF() CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX - KERNEL_ROOT_DIR SIP_ROOT_DIR QT_ROOT_DIR PYQT_ROOT_DIR CAS_ROOT_DIR + KERNEL_ROOT_DIR SIP_ROOT_DIR _QT_ROOT_DIR _PYQT_ROOT_DIR CAS_ROOT_DIR OPENGL_ROOT_DIR VTK_ROOT_DIR QWT_ROOT_DIR) # - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?): @@ -436,7 +449,7 @@ CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in # ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake # INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" # PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX -# KERNEL_ROOT_DIR SIP_ROOT_DIR QT5_ROOT_DIR PYQT5_ROOT_DIR CAS_ROOT_DIR +# KERNEL_ROOT_DIR SIP_ROOT_DIR _QT_ROOT_DIR _PYQT_ROOT_DIR CAS_ROOT_DIR # OPENGL_ROOT_DIR VTK_ROOT_DIR QWT_ROOT_DIR) WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake diff --git a/src/GLViewer/GLViewer_Drawer.cxx b/src/GLViewer/GLViewer_Drawer.cxx index a38fd76a6..1d4e95d8a 100644 --- a/src/GLViewer/GLViewer_Drawer.cxx +++ b/src/GLViewer/GLViewer_Drawer.cxx @@ -442,25 +442,33 @@ static GLuint displayListBase( QFont* theFont ) int aFontCont = 0; QString aFontDef = theFont->toString(); char** xFontList = XListFonts( aDisp, aFontDef.toLatin1()/*aFindFont.myFontString.data()*/, 1, &aFontCont ); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + if( !theFont->handle() ) + { +#endif #ifdef _DEBUG_ - printf( "Can't load font %s. loading default font....\n", aFontDef.toLatin1().data()/*aFindFont.myFontString.data()*/ ); + printf( "Can't load font %s. loading default font....\n", aFontDef.toLatin1().data()/*aFindFont.myFontString.data()*/ ); #endif - QString aFontMask ("-*-*-*-r-*-*-"); - aFontMask += aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 ); + QString aFontMask ("-*-*-*-r-*-*-"); + aFontMask += aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 ); #ifdef _DEBUG_ - printf( "Height of Default font: %s\n", aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 ).data() ); + printf( "Height of Default font: %s\n", aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 ).data() ); #endif - aFontMask += "-*-*-*-m-*-*-*"; - xFontList = XListFonts( aDisp, aFontMask.toLatin1().constData()/*"-*-*-*-r-*-*-12-*-*-*-m-*-*-*"*/, 1, &aFontCont ); - if( aFontCont == 0 ) - { + aFontMask += "-*-*-*-m-*-*-*"; + xFontList = XListFonts( aDisp, aFontMask.toLatin1().constData()/*"-*-*-*-r-*-*-12-*-*-*-m-*-*-*"*/, 1, &aFontCont ); + if( aFontCont == 0 ) + { #ifdef _DEBUG_ - printf( "Can't load default font\n" ); + printf( "Can't load default font\n" ); #endif - return 0; + return 0; + } + glXUseXFont( (Font)(XLoadFont( aDisp,xFontList[0] )), 0, 256, listBase ); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) } - glXUseXFont( (Font)(XLoadFont( aDisp,xFontList[0] )), 0, 256, listBase ); - + else + glXUseXFont( (Font)(theFont->handle()), 0, 256, listBase ); +#endif aList = listBase; GLViewer_TexFont::BitmapFontCache[aFindFont] = aList; } diff --git a/src/GLViewer/GLViewer_Viewer.cxx b/src/GLViewer/GLViewer_Viewer.cxx index 38dbcad82..395dd686f 100644 --- a/src/GLViewer/GLViewer_Viewer.cxx +++ b/src/GLViewer/GLViewer_Viewer.cxx @@ -888,7 +888,11 @@ void GLViewer_ViewSketcher::onSketch( SketchState state ) if ( state == Fin ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QApplication::syncX(); /* force rectangle redrawing */ +#else QApplication::sync(); /* force rectangle redrawing */ +#endif myViewer->activateSketching( GLViewer_Viewer::NoSketching ); } } diff --git a/src/GUI_PY/dockwidgets.py b/src/GUI_PY/dockwidgets.py index 4322cb5ea..8bd579758 100644 --- a/src/GUI_PY/dockwidgets.py +++ b/src/GUI_PY/dockwidgets.py @@ -1,5 +1,5 @@ -from PyQt5.QtCore import * -from PyQt5.QtGui import * +from PyQt4.QtCore import * +from PyQt4.QtGui import * import SalomePyQt diff --git a/src/GUI_PY/genericdialog.py b/src/GUI_PY/genericdialog.py index 8bd156955..9be5cee62 100644 --- a/src/GUI_PY/genericdialog.py +++ b/src/GUI_PY/genericdialog.py @@ -21,7 +21,7 @@ __author__="gboulant" __date__ ="$31 mars 2010 17:09:53$" -from PyQt5.QtGui import QDialog, QMessageBox +from PyQt4.QtGui import QDialog, QMessageBox from genericdialog_ui import Ui_GenericDialog @@ -113,8 +113,8 @@ class GenericDialog(QDialog): # def TEST_GenericDialog(): import sys - from PyQt5.QtGui import QApplication - from PyQt5.QtCore import QObject, SIGNAL, SLOT + from PyQt4.QtGui import QApplication + from PyQt4.QtCore import QObject, SIGNAL, SLOT app = QApplication(sys.argv) QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) diff --git a/src/GUI_PY/mytestdialog.py b/src/GUI_PY/mytestdialog.py index de3c8aaad..24d057640 100644 --- a/src/GUI_PY/mytestdialog.py +++ b/src/GUI_PY/mytestdialog.py @@ -71,7 +71,7 @@ class MyTestDialog(GenericDialog): return name -from PyQt5.QtCore import SIGNAL +from PyQt4.QtCore import SIGNAL class MyTestDialogWithSignals(MyTestDialog): """ This class is to illustrate the usage of the GenericDialog in the @@ -104,8 +104,8 @@ class MyTestDialogWithSignals(MyTestDialog): def TEST_MyTestDialog_modal(): import sys - from PyQt5.QtCore import QObject, SIGNAL, SLOT - from PyQt5.QtGui import QApplication + from PyQt4.QtCore import QObject, SIGNAL, SLOT + from PyQt4.QtGui import QApplication app = QApplication(sys.argv) QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) @@ -126,8 +126,8 @@ class DialogListener: def TEST_MyTestDialog_non_modal(): import sys - from PyQt5.QtCore import QObject, SIGNAL, SLOT - from PyQt5.QtGui import QApplication + from PyQt4.QtCore import QObject, SIGNAL, SLOT + from PyQt4.QtGui import QApplication app = QApplication(sys.argv) QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) diff --git a/src/GUI_PY/selectvars.py b/src/GUI_PY/selectvars.py index e80a77f87..412b6b82b 100644 --- a/src/GUI_PY/selectvars.py +++ b/src/GUI_PY/selectvars.py @@ -21,8 +21,8 @@ # import os -from PyQt5 import QtGui, QtCore -from PyQt5.QtCore import Qt +from PyQt4 import QtGui, QtCore +from PyQt4.QtCore import Qt import salome from salome.kernel.studyedit import getStudyEditor diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 402215d8c..00030bb0d 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -2012,8 +2012,11 @@ QWidget* LightApp_Application::createWindow( const int flag ) // Create OBSelector new LightApp_OBSelector( ob, mySelMgr ); - +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed); +#else ob->treeView()->header()->setSectionResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed); +#endif ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId); ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH); ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) ); diff --git a/src/OCCViewer/OCCViewer_ViewPort.cxx b/src/OCCViewer/OCCViewer_ViewPort.cxx index d4460d0c8..929d9c214 100755 --- a/src/OCCViewer/OCCViewer_ViewPort.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort.cxx @@ -41,7 +41,11 @@ #include #if !defined WIN32 +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include +#else #include +#endif #include #include #include @@ -114,15 +118,15 @@ static Colormap choose_cmap( Display *dpy, XVisualInfo *vi ) //#ifdef DEBUG //cout << "Choosing cmap for vID = " << vi->visualid << endl; //#endif - - /*if ( vi->visualid == XVisualIDFromVisual( (Visual*)QX11Info::appVisual() ) ) +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + if ( vi->visualid == XVisualIDFromVisual( (Visual*)QX11Info::appVisual() ) ) { #ifdef DEBUG // cout << "Using x11AppColormap" << endl; #endif return QX11Info::appColormap(); - }*/ - + } +#endif if ( mesa_gl ) { Atom hp_cmaps = XInternAtom( dpy, "_HP_RGB_SMOOTH_MAP_LIST", true ); diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index b77acd70d..119299fec 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -590,7 +590,11 @@ void OCCViewer_ViewPort3d::paintEvent( QPaintEvent* e ) mapView( activeView() ); #endif if ( !myWindow.IsNull() ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QApplication::syncX(); +#else QApplication::sync(); +#endif QRect rc = e->rect(); if ( !myPaintersRedrawing ) activeView()->Redraw( rc.x(), rc.y(), rc.width(), rc.height() ); @@ -609,7 +613,11 @@ void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e ) if ( !mapped( activeView() ) ) mapView( activeView() ); #endif - QApplication::sync(); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QApplication::syncX(); +#else + QApplication::sync(); +#endif if ( !activeView().IsNull() ) activeView()->MustBeResized(); } diff --git a/src/OCCViewer/OCCViewer_ViewSketcher.cxx b/src/OCCViewer/OCCViewer_ViewSketcher.cxx index fffd12e05..c9faa3a0c 100755 --- a/src/OCCViewer/OCCViewer_ViewSketcher.cxx +++ b/src/OCCViewer/OCCViewer_ViewSketcher.cxx @@ -298,7 +298,11 @@ void OCCViewer_RectSketcher::onSketch( SketchState state ) if ( state == Fin ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QApplication::syncX(); /* force rectangle redrawing */ +#else QApplication::sync(); /* force rectangle redrawing */ +#endif mypViewWindow->activateSketching( OCCViewer_ViewWindow::NoSketching ); } } @@ -515,7 +519,11 @@ void OCCViewer_PolygonSketcher::onSketch( SketchState state ) mypPolyRB->clearGeometry(); mypPolyRB->hide(); } +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QApplication::syncX(); +#else QApplication::sync(); +#endif mypViewWindow->activateSketching( OCCViewer_ViewWindow::NoSketching ); } } diff --git a/src/Plot2d/Plot2d_PlotItems.cxx b/src/Plot2d/Plot2d_PlotItems.cxx index 1031b089d..2cea87800 100644 --- a/src/Plot2d/Plot2d_PlotItems.cxx +++ b/src/Plot2d/Plot2d_PlotItems.cxx @@ -40,7 +40,9 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include +#endif const int SPACING = 10; const int SYMBOL_SIZE = 13; diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index c1b53f966..c54abfba7 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -58,7 +58,11 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include +#else #include +#endif #include #include #include @@ -78,7 +82,11 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include +#else #include +#endif #include #include diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index 67877c639..e5d7e85e9 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -46,8 +46,13 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include +#include +#else #include #include +#endif #include diff --git a/src/Qtx/QtxActionMgr.cxx b/src/Qtx/QtxActionMgr.cxx index b32f5cfc9..c7e640049 100644 --- a/src/Qtx/QtxActionMgr.cxx +++ b/src/Qtx/QtxActionMgr.cxx @@ -29,8 +29,8 @@ #include #include #ifndef QT_NO_DOM -#include -#include +#include +#include #include #endif diff --git a/src/Qtx/QtxDialog.cxx b/src/Qtx/QtxDialog.cxx index 22c364959..47a3a2867 100755 --- a/src/Qtx/QtxDialog.cxx +++ b/src/Qtx/QtxDialog.cxx @@ -1442,7 +1442,9 @@ void QtxDialog::reject() void QtxDialog::emitSignal() { QApplication::instance()->processEvents(); - +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QApplication::syncX(); +#endif int id = buttonId( (QAbstractButton*)mySender ); mySender = 0; diff --git a/src/Qtx/QtxLogoMgr.cxx b/src/Qtx/QtxLogoMgr.cxx index c2eadeb6a..0e83f7e92 100644 --- a/src/Qtx/QtxLogoMgr.cxx +++ b/src/Qtx/QtxLogoMgr.cxx @@ -98,7 +98,11 @@ bool QtxLogoMgr::LogoBox::eventFilter( QObject* o, QEvent* e ) if ( o != menuBar() ) return false; - if ( /*e->type() == QEvent::MenubarUpdated || */e->type() == QEvent::Resize ) +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + if ( e->type() == QEvent::MenubarUpdated || e->type() == QEvent::Resize ) +#else + if ( e->type() == QEvent::Resize ) +#endif updateCorner(); if ( e->type() == QEvent::ChildAdded || e->type() == QEvent::ChildRemoved ) diff --git a/src/Qtx/QtxPopupMgr.cxx b/src/Qtx/QtxPopupMgr.cxx index aed5f399a..fbeea8ffb 100644 --- a/src/Qtx/QtxPopupMgr.cxx +++ b/src/Qtx/QtxPopupMgr.cxx @@ -56,7 +56,11 @@ bool operator<( const QVariant& v1, const QVariant& v2 ) for ( ; anIt1 != aLast1 && anIt2 != aLast2; anIt1++, anIt2++ ) { if ( (*anIt1) != (*anIt2) ) +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return (*anIt1)<(*anIt2); +#else return (*anIt1)<=(*anIt2); +#endif } return anIt1 == aLast1 && anIt2 != aLast2; } @@ -65,7 +69,7 @@ bool operator<( const QVariant& v1, const QVariant& v2 ) } } return t1 < t2; -} +} /*! \class QtxPopupMgr::PopupCreator @@ -154,9 +158,8 @@ int QtxPopupMgr::PopupCreator::append( const QString& tag, const bool subMenu, } QString actLabel = strValue( attr, label ); - QKeySequence seq = QKeySequence( strValue( attr, accel ) ); QtxAction* newAct = new QtxAction( strValue( attr, tooltip ), set, actLabel, - seq[0], + QKeySequence( strValue( attr, accel ) )[0], myMgr ); newAct->setToolTip( strValue( attr, tooltip ) ); QString toggleact = strValue( attr, toggle ); diff --git a/src/Qtx/QtxResourceMgr.cxx b/src/Qtx/QtxResourceMgr.cxx index 529bfc8df..08c354261 100644 --- a/src/Qtx/QtxResourceMgr.cxx +++ b/src/Qtx/QtxResourceMgr.cxx @@ -36,9 +36,9 @@ #include #include #ifndef QT_NO_DOM -#include -#include -#include +#include +#include +#include #endif #include diff --git a/src/Qtx/QtxTreeView.cxx b/src/Qtx/QtxTreeView.cxx index 1257742f0..094d64ee4 100644 --- a/src/Qtx/QtxTreeView.cxx +++ b/src/Qtx/QtxTreeView.cxx @@ -107,10 +107,17 @@ void QtxTreeView::Header::contextMenuEvent( QContextMenuEvent* e ) QVariant appropriate = model()->headerData( i, orientation(), Qtx::AppropriateRole ); QIcon icon; if ( iconData.isValid() ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + if ( qVariantCanConvert( iconData ) ) + icon = qVariantValue( iconData ); + else if ( qVariantCanConvert( iconData ) ) + icon = qVariantValue( iconData ); +#else if ( iconData.canConvert( QMetaType::QIcon ) ) icon = iconData.value(); else if ( iconData.canConvert( QMetaType::QPixmap ) ) icon = iconData.value(); +#endif } if( ( !lab.isEmpty() || !icon.isNull() ) && appropriate.isValid() ? appropriate.toInt()==Qtx::Toggled : true ) @@ -136,7 +143,11 @@ void QtxTreeView::Header::contextMenuEvent( QContextMenuEvent* e ) } else if ( a && a == sortAction ) { setSortIndicatorShown( a->isChecked() ); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + setClickable( a->isChecked() ); +#else setSectionsClickable( a->isChecked() ); +#endif QtxTreeView* view = qobject_cast( parent() ); if ( view ) { view->emitSortingEnabled( a->isChecked() ); @@ -181,7 +192,11 @@ QtxTreeView::QtxTreeView( QWidget* parent ) : QTreeView( parent ) { setHeader( new Header( false, this ) ); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + header()->setMovable( true ); +#else header()->setSectionsMovable( true ); +#endif } /*! @@ -193,7 +208,11 @@ QtxTreeView::QtxTreeView( const bool enableSortMenu, QWidget* parent ) : QTreeView( parent ) { setHeader( new Header( enableSortMenu, this ) ); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + header()->setMovable( true ); +#else header()->setSectionsMovable( true ); +#endif } /*! diff --git a/src/Qtx/QtxWebBrowser.cxx b/src/Qtx/QtxWebBrowser.cxx index ef9928f81..1abd40bb2 100644 --- a/src/Qtx/QtxWebBrowser.cxx +++ b/src/Qtx/QtxWebBrowser.cxx @@ -43,7 +43,11 @@ #include #include #include -#include +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include +#else +#include +#endif #include namespace diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_GUILight.sip b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_GUILight.sip index d2bfb2253..1601b48f9 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_GUILight.sip +++ b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_GUILight.sip @@ -24,5 +24,7 @@ %Import QtGui/QtGuimod.sip %Import QtCore/QtCoremod.sip +%If (Qt_5_0_0 -) %Import QtWidgets/QtWidgetsmod.sip +%End %Import QtXmlmod.sip diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index 414b23bda..0ab24632c 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -30,7 +30,9 @@ %Import QtGui/QtGuimod.sip %Import QtCore/QtCoremod.sip +%If (Qt_5_0_0 -) %Import QtWidgets/QtWidgetsmod.sip +%End %Import QtXmlmod.sip %If (ENABLE_PLOT2D) diff --git a/src/SUIT/SUIT_FileDlg.cxx b/src/SUIT/SUIT_FileDlg.cxx index eec0f3f9c..51eaf1b78 100755 --- a/src/SUIT/SUIT_FileDlg.cxx +++ b/src/SUIT/SUIT_FileDlg.cxx @@ -131,8 +131,13 @@ SUIT_FileDlg::SUIT_FileDlg( QWidget* parent, bool open, bool showQuickDir, bool setWindowIcon( parent->windowIcon() ); // GDD +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + myUrls.insert(0,QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::ApplicationsLocation))); + myUrls.insert(0,QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation))); +#else myUrls.insert(0,QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation))); myUrls.insert(0,QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::HomeLocation))); +#endif setSidebarUrls(myUrls); // add quick directories widgets diff --git a/src/SUIT/SUIT_LicenseDlg.cxx b/src/SUIT/SUIT_LicenseDlg.cxx index 5f6ededea..550e9983b 100755 --- a/src/SUIT/SUIT_LicenseDlg.cxx +++ b/src/SUIT/SUIT_LicenseDlg.cxx @@ -25,7 +25,11 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include +#else #include +#endif //#include #include #include diff --git a/src/SUIT/SUIT_TreeModel.cxx b/src/SUIT/SUIT_TreeModel.cxx index 01b19f183..e6cd32fdb 100755 --- a/src/SUIT/SUIT_TreeModel.cxx +++ b/src/SUIT/SUIT_TreeModel.cxx @@ -515,7 +515,9 @@ void SUIT_TreeModel::registerColumn( const int group_id, const QString& name, co int n = myColumns.size(); myColumns.resize( n+1 ); myColumns[n] = inf; - //reset(); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + reset(); +#endif } } @@ -537,7 +539,9 @@ void SUIT_TreeModel::unregisterColumn( const int group_id, const QString& name ) myColumns[i].myIds.remove( group_id ); if ( myColumns[i].myIds.isEmpty() ) { myColumns.remove( i ); - //reset(); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + reset(); +#endif } break; } @@ -766,7 +770,9 @@ void SUIT_TreeModel::setRoot( SUIT_DataObject* r ) myRoot = r; //initialize(); - //reset(); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + reset(); +#endif emit modelUpdated(); } diff --git a/src/SUITApp/SUITApp.cxx b/src/SUITApp/SUITApp.cxx index 1e5edf1c1..9a8fac27d 100644 --- a/src/SUITApp/SUITApp.cxx +++ b/src/SUITApp/SUITApp.cxx @@ -187,9 +187,11 @@ int main( int argc, char* argv[] ) //Set a "native" graphic system in case if application runs on the remote host QString remote(::getenv("REMOTEHOST")); QString client(::getenv("SSH_CLIENT")); - /*if(remote.length() > 0 || client.length() > 0 ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + if(remote.length() > 0 || client.length() > 0 ) { QApplication::setGraphicsSystem(QLatin1String("native")); - }*/ + } +#endif SUITApp_Application app( argc, argv ); QString cfgAppName = getAppName( argList.isEmpty() ? QString() : argList.first() ); diff --git a/src/SUITApp/SUITApp_Application.cxx b/src/SUITApp/SUITApp_Application.cxx index 817d49884..592328fcd 100644 --- a/src/SUITApp/SUITApp_Application.cxx +++ b/src/SUITApp/SUITApp_Application.cxx @@ -43,13 +43,13 @@ SUITApp_Application::SUITApp_Application( int& argc, char** argv, SUIT_Exception #ifdef ENABLE_TESTRECORDER : TestApplication( argc, argv ), #else -//#ifndef WIN32 +#if !defined(WIN32) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) // san: Opening an X display and choosing a visual most suitable for 3D visualization // in order to make SALOME viewers work with non-native X servers - // : QApplication( (Display*)Qtx::getDisplay(), argc, argv, Qtx::getVisual() ), -//#else + : QApplication( (Display*)Qtx::getDisplay(), argc, argv, Qtx::getVisual() ), +#else : QApplication( argc, argv ), -//#endif +#endif #endif myExceptHandler( hand ) { @@ -58,7 +58,8 @@ myExceptHandler( hand ) /*! Constructor */ -/*SUITApp_Application::SUITApp_Application( int& argc, char** argv, Type type, SUIT_ExceptionHandler* hand ) +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +SUITApp_Application::SUITApp_Application( int& argc, char** argv, Type type, SUIT_ExceptionHandler* hand ) #ifdef ENABLE_TESTRECORDER : TestApplication( argc, argv ), #else @@ -67,7 +68,7 @@ myExceptHandler( hand ) myExceptHandler( hand ) { } -*/ +#endif /*! Sends event to receiver \return the value that is returned from the receiver's event handler diff --git a/src/SUITApp/SUITApp_Application.h b/src/SUITApp/SUITApp_Application.h index 73cf2077f..2db4b8169 100644 --- a/src/SUITApp/SUITApp_Application.h +++ b/src/SUITApp/SUITApp_Application.h @@ -51,8 +51,9 @@ class SUIT_ExceptionHandler; public: SUITApp_Application( int& argc, char** argv, SUIT_ExceptionHandler* = 0 ); - //SUITApp_Application( int& argc, char** argv, Type type, SUIT_ExceptionHandler* = 0 ); - +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + SUITApp_Application( int& argc, char** argv, Type type, SUIT_ExceptionHandler* = 0 ); +#endif virtual bool notify( QObject* receiver, QEvent* e ); SUIT_ExceptionHandler* handler() const; diff --git a/src/SVTK/SVTK_RenderWindowInteractor.cxx b/src/SVTK/SVTK_RenderWindowInteractor.cxx index 61258a22e..a8f5428cf 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.cxx +++ b/src/SVTK/SVTK_RenderWindowInteractor.cxx @@ -439,24 +439,24 @@ QVTK_RenderWindowInteractor #endif } -/* +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #ifdef WIN32 /*! To handle native Win32 events (from such devices as SpaceMouse) */ -/*bool QVTK_RenderWindowInteractor::winEvent( MSG* msg, long* result ) +bool QVTK_RenderWindowInteractor::winEvent( MSG* msg, long* result ) { // TODO: Implement event handling for SpaceMouse return QWidget::winEvent( msg, result); } #else -*/ + /*! To handle native X11 events (from such devices as SpaceMouse) */ -/*bool +bool QVTK_RenderWindowInteractor ::x11Event( XEvent *xEvent ) { @@ -485,7 +485,8 @@ QVTK_RenderWindowInteractor return QWidget::x11Event( xEvent ); } -#endif */ +#endif +#endif /*! Constructor */ diff --git a/src/SVTK/SVTK_RenderWindowInteractor.h b/src/SVTK/SVTK_RenderWindowInteractor.h index 4e4e64e32..0aded2b66 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.h +++ b/src/SVTK/SVTK_RenderWindowInteractor.h @@ -121,12 +121,14 @@ class SVTK_EXPORT QVTK_RenderWindowInteractor: public QWidget virtual void focusInEvent( QFocusEvent* ); virtual void focusOutEvent( QFocusEvent* ); -/* //! To handle native events (from such devices as SpaceMouse) + //! To handle native events (from such devices as SpaceMouse) +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #ifdef WIN32 virtual bool winEvent( MSG*, long* ); #else virtual bool x11Event( XEvent *e ); -#endif */ +#endif +#endif vtkSmartPointer myRenderWindow; vtkSmartPointer myDevice; }; diff --git a/src/SalomeApp/SalomeApp_ListView.cxx b/src/SalomeApp/SalomeApp_ListView.cxx index f02808298..4ba39a4ef 100644 --- a/src/SalomeApp/SalomeApp_ListView.cxx +++ b/src/SalomeApp/SalomeApp_ListView.cxx @@ -84,7 +84,11 @@ SalomeApp_ListView::SalomeApp_ListView( QWidget* parent ) setRootIsDecorated(false); setAllColumnsShowFocus(false); // header()->setClickEnabled(false); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + header()->setMovable(false); +#else header()->setSectionsMovable(false); +#endif myEditedItem = 0; myEdit = 0; diff --git a/src/SalomeApp/pluginsdemo/CMakeLists.txt b/src/SalomeApp/pluginsdemo/CMakeLists.txt index b77a3478d..f8ec9d6fb 100755 --- a/src/SalomeApp/pluginsdemo/CMakeLists.txt +++ b/src/SalomeApp/pluginsdemo/CMakeLists.txt @@ -28,7 +28,7 @@ # --- scripts --- # scripts / static -# TODO: process UIC files via PyQt5 pyuic tool, see UsePyQt5.cmake +# TODO: process UIC files via PyQt pyuic tool, see UsePyQt.cmake SET(_plugins_SCRIPTS minmax_dialog.py minmax_plugin.py diff --git a/src/SalomeApp/pluginsdemo/minmax_dialog.py b/src/SalomeApp/pluginsdemo/minmax_dialog.py index 832000efe..b5c5db667 100644 --- a/src/SalomeApp/pluginsdemo/minmax_dialog.py +++ b/src/SalomeApp/pluginsdemo/minmax_dialog.py @@ -21,11 +21,11 @@ # Form implementation generated from reading ui file 'minmax.ui' # # Created: Thu Mar 1 15:23:57 2012 -# by: PyQt5 UI code generator 5.5.0 +# by: PyQt4 UI code generator 4.8.1 # # WARNING! All changes made in this file will be lost! -from PyQt5 import QtCore, QtGui +from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/src/SalomeApp/pluginsdemo/minmax_plugin.py b/src/SalomeApp/pluginsdemo/minmax_plugin.py index 80d84ccb0..adc759426 100644 --- a/src/SalomeApp/pluginsdemo/minmax_plugin.py +++ b/src/SalomeApp/pluginsdemo/minmax_plugin.py @@ -25,10 +25,10 @@ def minmax(context): studyId = context.studyId sg = context.sg - from PyQt5.QtGui import QDialog - from PyQt5.QtGui import QMessageBox - from PyQt5.QtCore import Qt - from PyQt5.QtCore import SIGNAL + from PyQt4.QtGui import QDialog + from PyQt4.QtGui import QMessageBox + from PyQt4.QtCore import Qt + from PyQt4.QtCore import SIGNAL from minmax_dialog import Ui_Dialog diff --git a/src/SalomeApp/pluginsdemo/tubedialog.py b/src/SalomeApp/pluginsdemo/tubedialog.py index 0b63b2583..9d1e8f5cb 100644 --- a/src/SalomeApp/pluginsdemo/tubedialog.py +++ b/src/SalomeApp/pluginsdemo/tubedialog.py @@ -19,8 +19,8 @@ # Author : Guillaume Boulant (EDF) import sys -from PyQt5 import QtGui -from PyQt5 import QtCore +from PyQt4 import QtGui +from PyQt4 import QtCore from tubedialog_ui import TubeDialog_UI diff --git a/src/SalomeApp/pluginsdemo/tubedialog_ui.py b/src/SalomeApp/pluginsdemo/tubedialog_ui.py index 98e9563b2..571e6c992 100644 --- a/src/SalomeApp/pluginsdemo/tubedialog_ui.py +++ b/src/SalomeApp/pluginsdemo/tubedialog_ui.py @@ -20,8 +20,8 @@ # Author : Guillaume Boulant (EDF) import sys -from PyQt5 import QtGui -from PyQt5 import QtCore +from PyQt4 import QtGui +from PyQt4 import QtCore class TubeDialog_UI(QtGui.QDialog): diff --git a/src/SalomeApp/salome_pluginsmanager.py b/src/SalomeApp/salome_pluginsmanager.py index 79da22b02..10bf174fd 100644 --- a/src/SalomeApp/salome_pluginsmanager.py +++ b/src/SalomeApp/salome_pluginsmanager.py @@ -44,7 +44,7 @@ name salome_plugins.py (example follows):: import salome_pluginsmanager def about(context): - from PyQt5.QtGui import QMessageBox + from PyQt4.QtGui import QMessageBox QMessageBox.about(None, "About SALOME pluginmanager", "SALOME plugins manager in SALOME virtual application ") salome_pluginsmanager.AddFunction('About plugins','About SALOME pluginmanager',about) @@ -84,8 +84,8 @@ context attributes: """ import os,sys,traceback -from PyQt5 import QtGui -from PyQt5 import QtCore +from PyQt4 import QtGui +from PyQt4 import QtCore import salome diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 5f09b3615..3da27bc8b 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -97,8 +97,11 @@ * - stop Session ( must be idle ) * - get session state */ - +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +void MessageOutput( QtMsgType type, const char* msg ) +#else void MessageOutput( QtMsgType type, const QMessageLogContext &context, const QString &msg ) +#endif { switch ( type ) { @@ -106,10 +109,18 @@ void MessageOutput( QtMsgType type, const QMessageLogContext &context, const QSt //MESSAGE( "Debug: " << msg ); break; case QtWarningMsg: +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + MESSAGE( "Warning: " << msg ); +#else MESSAGE( "Warning: " << msg.toLatin1().data() ); +#endif break; case QtFatalMsg: +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + MESSAGE( "Fatal: " << msg ); +#else MESSAGE( "Fatal: " << msg.toLatin1().data() ); +#endif break; } } @@ -251,13 +262,13 @@ public: SALOME_QApplication( int& argc, char** argv ) : TestApplication( argc, argv ), myHandler ( 0 ) {} #else SALOME_QApplication( int& argc, char** argv ) -//#ifndef WIN32 +#if !defined WIN32 && QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // san: Opening an X display and choosing a visual most suitable for 3D visualization // in order to make SALOME viewers work with non-native X servers -// : QApplication( (Display*)Qtx::getDisplay(), argc, argv, Qtx::getVisual() ), -//#else + : QApplication( (Display*)Qtx::getDisplay(), argc, argv, Qtx::getVisual() ), +#else : QApplication( argc, argv ), -//#endif +#endif myHandler ( 0 ) {} #endif @@ -341,15 +352,20 @@ void shutdownServers( SALOME_NamingService* theNS ) int main( int argc, char **argv ) { // Install Qt debug messages handler +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + qInstallMsgHandler( MessageOutput ); +#else qInstallMessageHandler( MessageOutput ); +#endif //Set a "native" graphic system in case if application runs on the remote host QString remote(getenv("REMOTEHOST")); QString client(getenv("SSH_CLIENT")); - /*if(remote.length() > 0 || client.length() > 0 ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + if(remote.length() > 0 || client.length() > 0 ) { QApplication::setGraphicsSystem(QLatin1String("native")); - }*/ - + } +#endif // add $QTDIR/plugins to the pluins search path for image plugins QString qtdir = qgetenv( "QT_ROOT_DIR" ); if ( qtdir.isEmpty() ) diff --git a/src/Style/Style_Salome.cxx b/src/Style/Style_Salome.cxx index 7134bb735..57d00a918 100644 --- a/src/Style/Style_Salome.cxx +++ b/src/Style/Style_Salome.cxx @@ -61,7 +61,9 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include +#endif #define SHADOW 1 #define LINE_GR_MARGIN 10 @@ -204,7 +206,11 @@ Style_Model* Style_Salome::myModel = 0; Use Style_Salome::apply() static function to set SALOME style to the application. */ Style_Salome::Style_Salome() +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + : QWindowsStyle() +#else : QCommonStyle() +#endif { // initialize SALOME style resources Q_INIT_RESOURCE( Style ); @@ -324,7 +330,11 @@ Style_Model* Style_Salome::model() */ void Style_Salome::polish ( QApplication* app ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::polish( app ); +#else QCommonStyle::polish( app ); +#endif if ( checkDebugLevel(1) ) { return; @@ -346,7 +356,11 @@ void Style_Salome::polish ( QApplication* app ) void Style_Salome::polish ( QWidget* w ) { if ( checkDebugLevel(2) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::polish( w ); +#else QCommonStyle::polish( w ); +#endif return; } @@ -360,7 +374,11 @@ void Style_Salome::polish ( QWidget* w ) w->setAttribute( Qt::WA_Hover ); } - QCommonStyle::polish( w ); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::polish( w ); +#else + QCommonStyle::polish( w ); +#endif } /*! @@ -376,7 +394,11 @@ void Style_Salome::polish ( QWidget* w ) void Style_Salome::unpolish( QWidget* w ) { if ( checkDebugLevel(3) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::unpolish( w ); +#else QCommonStyle::unpolish( w ); +#endif return; } @@ -390,7 +412,11 @@ void Style_Salome::unpolish( QWidget* w ) w->setAttribute( Qt::WA_Hover, false ); } - QCommonStyle::unpolish( w ); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::unpolish( w ); +#else + QCommonStyle::unpolish( w ); +#endif } /*! @@ -404,7 +430,11 @@ void Style_Salome::drawComplexControl( ComplexControl cc, const QStyleOptionComp QPainter* p, const QWidget* w ) const { if ( checkDebugLevel(4) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawComplexControl( cc, opt, p, w ); +#else QCommonStyle::drawComplexControl( cc, opt, p, w ); +#endif return; } @@ -556,7 +586,11 @@ void Style_Salome::drawComplexControl( ComplexControl cc, const QStyleOptionComp if ((slider->subControls & SC_SliderGroove) && groove.isValid()) { QStyleOptionSlider tmpSlider = *slider; tmpSlider.subControls = SC_SliderGroove; +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawComplexControl(cc, &tmpSlider, p, w); +#else QCommonStyle::drawComplexControl(cc, &tmpSlider, p, w); +#endif } if (slider->subControls & SC_SliderTickmarks) { QStyleOptionSlider tmpSlider = *slider; @@ -627,7 +661,11 @@ void Style_Salome::drawComplexControl( ComplexControl cc, const QStyleOptionComp if (w && ( qobject_cast(w->parentWidget() ) || ( toolbutton->state & State_AutoRaise && !( toolbutton->state & State_MouseOver ) ) ) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawComplexControl( cc, opt, p, w ); +#else QCommonStyle::drawComplexControl( cc, opt, p, w ); +#endif return; } int aMinDelta = (int)model()->widgetRounding( Style_Model::ButtonRadius ); @@ -709,7 +747,11 @@ void Style_Salome::drawComplexControl( ComplexControl cc, const QStyleOptionComp } } case CC_TitleBar: { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawComplexControl( cc, opt, p, w ); +#else QCommonStyle::drawComplexControl( cc, opt, p, w ); +#endif break; } case CC_GroupBox: @@ -759,11 +801,19 @@ void Style_Salome::drawComplexControl( ComplexControl cc, const QStyleOptionComp break; } case CC_Dial: { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawComplexControl( cc, opt, p, w ); +#else QCommonStyle::drawComplexControl( cc, opt, p, w ); +#endif break; } default: +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawComplexControl( cc, opt, p, w ); +#else QCommonStyle::drawComplexControl( cc, opt, p, w ); +#endif } } @@ -778,7 +828,11 @@ void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt, QPainter* p, const QWidget* w ) const { if ( checkDebugLevel(5) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawControl( ce, opt, p, w ); +#else QCommonStyle::drawControl( ce, opt, p, w ); +#endif return; } @@ -907,7 +961,11 @@ void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt, break; } case CE_Splitter: { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawControl( ce, opt, p, w ); +#else QCommonStyle::drawControl( ce, opt, p, w ); +#endif QRect r = opt->rect; bool horiz = r.width() > r.height(); int aLen = model()->splitHandleLength(); @@ -945,7 +1003,7 @@ void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt, aBrdTopCol, aBrdBotCol, isSelected, isLast, isHover ); p->restore(); } else - QCommonStyle::drawControl(ce, opt, p, w); + QCommonStyle::drawControl( ce, opt, p, w ); break; } case CE_TabBarTabLabel: @@ -964,10 +1022,18 @@ void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt, } QStyleOptionTab* copyTab = (QStyleOptionTab*)tab; copyTab->rect = oldRect; +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawControl( ce, copyTab, p, w ); +#else QCommonStyle::drawControl( ce, copyTab, p, w ); +#endif } else +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawControl( ce, opt, p, w ); +#else QCommonStyle::drawControl( ce, opt, p, w ); +#endif break; } case CE_MenuBarItem: @@ -1496,7 +1562,11 @@ void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt, break; } default: +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawControl( ce, opt, p, w ); +#else QCommonStyle::drawControl( ce, opt, p, w ); +#endif break; } } @@ -1512,7 +1582,11 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt, QPainter* p, const QWidget* w ) const { if ( checkDebugLevel(6) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawPrimitive( pe, opt, p, w ); +#else QCommonStyle::drawPrimitive( pe, opt, p, w ); +#endif return; } @@ -1552,7 +1626,11 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt, break; } else +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawPrimitive( pe, opt, p, w ); +#else QCommonStyle::drawPrimitive( pe, opt, p, w ); +#endif } break; case PE_FrameFocusRect: { @@ -1568,7 +1646,11 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt, aBrdTopCol, aBrdBotCol, false, false, isHover, true ); } else { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawPrimitive( pe, opt, p, w ); +#else QCommonStyle::drawPrimitive( pe, opt, p, w ); +#endif } break; } @@ -1832,7 +1914,11 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt, break; } case PE_Widget: { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawPrimitive( pe, opt, p, w ); +#else QCommonStyle::drawPrimitive( pe, opt, p, w ); +#endif if ( !w ) break; if( w->parent() && !qobject_cast((QWidget*)w) ) @@ -1846,7 +1932,11 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt, = qstyleoption_cast(opt)) { if (tbb->shape != QTabBar::RoundedNorth && tbb->shape != QTabBar::RoundedEast && tbb->shape != QTabBar::RoundedSouth && tbb->shape != QTabBar::RoundedWest) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawPrimitive( pe, opt, p, w ); +#else QCommonStyle::drawPrimitive( pe, opt, p, w ); +#endif break; } QRect aSelRect = tbb->selectedTabRect; @@ -1962,11 +2052,19 @@ void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt, aPal.setBrush( QPalette::AlternateBase, QBrush( gr_alt ) ); aWdg->setPalette( aPal ); } +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawPrimitive( pe, opt, p, w ); +#else QCommonStyle::drawPrimitive( pe, opt, p, w ); +#endif break; } default: +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QWindowsStyle::drawPrimitive( pe, opt, p, w ); +#else QCommonStyle::drawPrimitive( pe, opt, p, w ); +#endif } } @@ -1981,10 +2079,17 @@ int Style_Salome::pixelMetric( PixelMetric metric, const QStyleOption* opt, const QWidget* w ) const { if ( checkDebugLevel(7) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return QWindowsStyle::pixelMetric( metric, opt, w ); +#else return QCommonStyle::pixelMetric( metric, opt, w ); +#endif } - +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + int aRes = QWindowsStyle::pixelMetric( metric, opt, w ); +#else int aRes = QCommonStyle::pixelMetric( metric, opt, w ); +#endif switch( metric ) { case PM_SliderLength: { aRes += (int)((double)model()->sliderSize()/2); @@ -2021,10 +2126,17 @@ QSize Style_Salome::sizeFromContents( ContentsType ct, const QStyleOption* opt, const QSize& contentsSize, const QWidget* w ) const { if ( checkDebugLevel(8) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return QWindowsStyle::sizeFromContents( ct, opt,contentsSize, w ); +#else return QCommonStyle::sizeFromContents( ct, opt,contentsSize, w ); +#endif } - +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QSize sz = QWindowsStyle::sizeFromContents( ct, opt, contentsSize, w ); +#else QSize sz = QCommonStyle::sizeFromContents( ct, opt, contentsSize, w ); +#endif switch (ct) { case CT_TabBarTab: if (const QStyleOptionTab *tab = qstyleoption_cast(opt)) { @@ -2053,8 +2165,13 @@ QSize Style_Salome::sizeFromContents( ContentsType ct, const QStyleOption* opt, QRect res = QRect( 0, 0, sz.width(), sz.height() ); int aHalfRect = (int)Style_Tools::getMaxRect( res, (int)model()->widgetRounding( Style_Model::EditRadius )/2 ); // left value - QRect old_arrow = QCommonStyle::subControlRect( CC_ComboBox, cmb, +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QRect old_arrow = QWindowsStyle::subControlRect( CC_ComboBox, cmb, SC_ComboBoxArrow, w ); +#else + QRect old_arrow = QCommonStyle::subControlRect( CC_ComboBox, cmb, + SC_ComboBoxArrow, w ); +#endif int aDelta = res.height() - old_arrow.width(); // right value if ( cmb->editable ) aDelta += aHalfRect; // for right of line edit internal @@ -2078,7 +2195,11 @@ QPixmap Style_Salome::standardPixmap(StandardPixmap stPixmap, const QStyleOption const QWidget *w) const { if ( checkDebugLevel(9) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return QWindowsStyle::standardPixmap( stPixmap, opt, w ); +#else return QCommonStyle::standardPixmap( stPixmap, opt, w ); +#endif } switch ( stPixmap ) @@ -2093,7 +2214,11 @@ QPixmap Style_Salome::standardPixmap(StandardPixmap stPixmap, const QStyleOption case SP_TitleBarMinButton: return QPixmap( minimize_xpm ); default: +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return QWindowsStyle::standardPixmap( stPixmap, opt, w ); +#else return QCommonStyle::standardPixmap( stPixmap, opt, w ); +#endif } } @@ -2109,7 +2234,11 @@ QIcon Style_Salome::standardIconImplementation( StandardPixmap standardIcon, const QWidget* w ) const { if ( checkDebugLevel(10) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return QWindowsStyle::standardIconImplementation( standardIcon, opt, w ); +#else return QCommonStyle::standardIcon( standardIcon, opt, w ); +#endif } switch ( standardIcon ) @@ -2125,7 +2254,11 @@ QIcon Style_Salome::standardIconImplementation( StandardPixmap standardIcon, default: break; } +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return QWindowsStyle::standardIconImplementation( standardIcon, opt, w ); +#else return QCommonStyle::standardIcon( standardIcon, opt, w ); +#endif } /*! @@ -2141,10 +2274,17 @@ int Style_Salome::styleHint( StyleHint hint, const QStyleOption* opt, const QWid QStyleHintReturn* returnData ) const { if ( checkDebugLevel(11) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return QWindowsStyle::styleHint( hint, opt, w, returnData ); +#else return QCommonStyle::styleHint( hint, opt, w, returnData ); +#endif } - +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + int aRes = QWindowsStyle::styleHint( hint, opt, w, returnData ); +#else int aRes = QCommonStyle::styleHint( hint, opt, w, returnData ); +#endif switch( hint ) { case SH_Table_GridLineColor: { if ( opt ) @@ -2173,15 +2313,26 @@ QRect Style_Salome::subControlRect( ComplexControl cc, const QStyleOptionComplex SubControl sc, const QWidget* wid ) const { if ( checkDebugLevel(12) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return QWindowsStyle::subControlRect( cc, opt, sc, wid ); +#else return QCommonStyle::subControlRect( cc, opt, sc, wid ); +#endif } - +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QRect res = QWindowsStyle::subControlRect( cc, opt, sc, wid ); +#else QRect res = QCommonStyle::subControlRect( cc, opt, sc, wid ); +#endif switch ( cc ) { case CC_SpinBox: { int x = res.x(), w = res.width(), h = res.height(); if ( sc==SC_SpinBoxUp || sc==SC_SpinBoxDown ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QRect frame_r = QWindowsStyle::subControlRect( cc, opt, SC_SpinBoxFrame, wid ); +#else QRect frame_r = QCommonStyle::subControlRect( cc, opt, SC_SpinBoxFrame, wid ); +#endif h = frame_r.height(); res.setX( x+w-h ); res.setWidth( h ); @@ -2217,7 +2368,11 @@ QRect Style_Salome::subControlRect( ComplexControl cc, const QStyleOptionComplex } case CC_ScrollBar: if (const QStyleOptionSlider *scrollbar = qstyleoption_cast(opt)) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QRect slider_r = QWindowsStyle::subControlRect( cc, opt, SC_ScrollBarSlider, wid ); +#else QRect slider_r = QCommonStyle::subControlRect( cc, opt, SC_ScrollBarSlider, wid ); +#endif int aRect = Style_Tools::getMaxRect( slider_r, (int)model()->widgetRounding( Style_Model::ButtonRadius ) ); switch( sc ) { case SC_ScrollBarSubPage: // between top/left button and slider @@ -2271,17 +2426,30 @@ QRect Style_Salome::subElementRect( SubElement se, const QStyleOption* opt, const QWidget* wid ) const { if ( checkDebugLevel(13) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + return QWindowsStyle::subElementRect( se, opt, wid ); +#else return QCommonStyle::subElementRect( se, opt, wid ); +#endif } - +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QRect res = QWindowsStyle::subElementRect( se, opt, wid ); +#else QRect res = QCommonStyle::subElementRect( se, opt, wid ); +#endif int aHalfRect = (int)Style_Tools::getMaxRect( res, (int)model()->widgetRounding( Style_Model::EditRadius )/2 ); int w = res.width(), h = res.height(); switch ( se ) { case SE_ComboBoxFocusRect: { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + QRect old_r = QWindowsStyle::subControlRect( CC_ComboBox, + qstyleoption_cast( opt ), + SC_ComboBoxArrow, wid ); +#else QRect old_r = QCommonStyle::subControlRect( CC_ComboBox, qstyleoption_cast( opt ), SC_ComboBoxArrow, wid ); +#endif int old_w = old_r.width(); res.setWidth( w-h+old_w-2 ); break; diff --git a/src/Style/Style_Salome.h b/src/Style/Style_Salome.h index d11a4f6ea..47eb21dfb 100644 --- a/src/Style/Style_Salome.h +++ b/src/Style/Style_Salome.h @@ -24,9 +24,12 @@ #define STYLE_SALOME_H #include "Style.h" - +#include +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include +#else #include - +#endif class Style_Model; class QApplication; @@ -34,7 +37,12 @@ class QWidget; class QPainter; class QtxResourceMgr; -class STYLE_SALOME_EXPORT Style_Salome : public QCommonStyle +class STYLE_SALOME_EXPORT Style_Salome +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +: public QWindowsStyle +#else +: public QCommonStyle +#endif { Q_OBJECT diff --git a/src/VTKViewer/VTKViewer_RenderWindow.cxx b/src/VTKViewer/VTKViewer_RenderWindow.cxx index 18debd586..2200f144f 100755 --- a/src/VTKViewer/VTKViewer_RenderWindow.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindow.cxx @@ -32,7 +32,11 @@ #include #include #ifndef WIN32 +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#include +#else #include +#endif #include //#include //#include diff --git a/tools/dlgfactory/CMakeLists.txt b/tools/dlgfactory/CMakeLists.txt index 83e6bd93d..d49b88bf1 100755 --- a/tools/dlgfactory/CMakeLists.txt +++ b/tools/dlgfactory/CMakeLists.txt @@ -55,8 +55,16 @@ SET(GenericDialog_HEADERS SET(GenericDialog_FORMS GenericDialog.ui ) - -ADD_DEFINITIONS(${Qt5Widgets_DEFINITIONS}) + +IF (NOT SALOME_BUILD_WITH_QT5) + SET(_QT_DEFINITIONS ${QT_DEFINITIONS}) + SET(_QT_LIBRARIES ${QT_LIBRARIES}) +ELSE() + SET(_QT_DEFINITIONS ${Qt5Widgets_DEFINITIONS}) + SET(_QT_LIBRARIES ${Qt5Widgets_LIBRARIES}) +ENDIF() + +ADD_DEFINITIONS(${_QT_DEFINITIONS}) ADD_CUSTOM_COMMAND( OUTPUT QDialogTest.cxx QDialogTest.h QDialogTest.ui COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dlgfactory.py -s -n QDialogTest -t qdialog @@ -90,7 +98,8 @@ ADD_EXECUTABLE(qtester ${qtester_SOURCES} ${qtester_FORMS_HEADERS} QDialogTest.cxx ) -TARGET_LINK_LIBRARIES(qtester ${Qt5Widgets_LIBRARIES}) + +TARGET_LINK_LIBRARIES(qtester ${_QT_LIBRARIES}) ADD_EXECUTABLE(gtester ${gtester_SOURCES} ${gtester_HEADERS_MOC} @@ -99,6 +108,6 @@ ADD_EXECUTABLE(gtester ${gtester_SOURCES} ${GenericDialog_FORMS_HEADERS} GDialogTest.cxx ) -TARGET_LINK_LIBRARIES(gtester ${Qt5Widgets_LIBRARIES}) +TARGET_LINK_LIBRARIES(gtester ${_QT_LIBRARIES}) INSTALL(TARGETS qtester gtester DESTINATION ${SALOME_INSTALL_BINS})