From 9272fedf935c4d594cab5bae622ffc04930ee711 Mon Sep 17 00:00:00 2001 From: rnv Date: Fri, 10 Jun 2016 11:24:31 +0300 Subject: [PATCH] Porting to the Qt-5.6.0 third-party product. --- CMakeLists.txt | 7 + adm_local/cmake_files/FindSalomeQt5.cmake | 35 ++++- src/CMakeLists.txt | 4 +- src/LightApp/LightApp_Application.cxx | 14 +- src/Qtx/CMakeLists.txt | 10 +- src/Qtx/QtxWebBrowser.cxx | 71 +++++++-- src/Qtx/QtxWebBrowser.h | 9 +- src/Style/Style_Salome.cxx | 182 ++-------------------- src/Style/Style_Salome.h | 10 +- 9 files changed, 139 insertions(+), 203 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e834cbe4..dee2009f4 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,6 +157,13 @@ IF(NOT SALOME_BUILD_WITH_QT5) ELSE() FIND_PACKAGE(SalomeQt5 REQUIRED) SET(QT_SALOME_VERSION 5) + # Check that WebEngine component was found + IF(Qt5WebEngine_FOUND) + SET(SALOME_QT5HAVE_WEBENGINE TRUE) + ELSE() + MESSAGE("Qt5WebEngine is not found, SALOME internal help browser will be unavailable !") + ADD_DEFINITIONS("-DDISABLE_QTXWEBBROWSER") + ENDIF() ENDIF() # PyQt diff --git a/adm_local/cmake_files/FindSalomeQt5.cmake b/adm_local/cmake_files/FindSalomeQt5.cmake index 31168f3ad..8e723d0f4 100644 --- a/adm_local/cmake_files/FindSalomeQt5.cmake +++ b/adm_local/cmake_files/FindSalomeQt5.cmake @@ -26,18 +26,38 @@ # Qt5_FIND_COMPONENTS variable is set here to prevent ParaView to reset list of Qt5 modules, # just to avoid extra dependencies -SET(Qt5_FIND_COMPONENTS Core Gui Widgets Network Xml OpenGL PrintSupport WebKit WebKitWidgets Help Test Sql Sensors Positioning Quick Qml Multimedia MultimediaWidgets WebChannel UiTools) - -IF(NOT WIN32) - LIST(APPEND Qt5_FIND_COMPONENTS X11Extras) -ENDIF() SET(QT_INCLUDES) SET(QT_DEFINITIONS) SET(QT_LIBRARIES) +# Find Qt5Core to get Qt version +SET(Qt5_FIND_COMPONENTS QtCore) +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(Qt5Core Qt5Core_INCLUDE_DIRS 1 ENVVAR QT5_ROOT_DIR) +IF(Qt5Core_FOUND) + LIST(APPEND QT_INCLUDES ${Qt5Core_INCLUDE_DIRS}) + LIST(APPEND QT_DEFINITIONS ${Qt5Core_DEFINITIONS}) + LIST(APPEND QT_LIBRARIES ${Qt5Core_LIBRARIES}) + SET(QT_VERSION "${Qt5Core_VERSION}") +ENDIF() + +SET(Qt5_FIND_COMPONENTS Gui Widgets Network Xml OpenGL PrintSupport Help Test Sql Sensors Positioning Quick Qml Multimedia MultimediaWidgets WebChannel UiTools) -FOREACH(_Qt5_COMPONENT ${Qt5_FIND_COMPONENTS}) - SET(_Qt5_COMPONENT Qt5${_Qt5_COMPONENT}) +IF ("${QT_VERSION}" VERSION_LESS "5.6.0") + LIST(APPEND Qt5_FIND_COMPONENTS WebKit WebKitWidgets) +ELSE() + LIST(APPEND Qt5_OPTIONAL_COMPONENTS WebEngine WebEngineWidgets) +ENDIF() + +IF(NOT WIN32) + LIST(APPEND Qt5_FIND_COMPONENTS X11Extras) +ENDIF() + +FOREACH(_Qt5_COMPONENT_ ${Qt5_FIND_COMPONENTS} ${Qt5_OPTIONAL_COMPONENTS}) + SET(_Qt5_COMPONENT Qt5${_Qt5_COMPONENT_}) + LIST(FIND Qt5_OPTIONAL_COMPONENTS ${_Qt5_COMPONENT_} idx) + IF(${idx} GREATER -1) + SET(Salome${_Qt5_COMPONENT}_FIND_QUIETLY TRUE) + ENDIF() SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(${_Qt5_COMPONENT} ${_Qt5_COMPONENT}_INCLUDE_DIRS 1 ENVVAR QT5_ROOT_DIR) LIST(APPEND QT_INCLUDES ${${_Qt5_COMPONENT}_INCLUDE_DIRS}) LIST(APPEND QT_DEFINITIONS ${${_Qt5_COMPONENT}_DEFINITIONS}) @@ -64,7 +84,6 @@ IF(Qt5Core_FOUND) SALOME_ACCUMULATE_HEADERS(QT_INCLUDES) SALOME_ACCUMULATE_ENVIRONMENT(PATH ${LINGUIST_PATH}) SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${Qt5Core_LIBRARIES}) - SET(QT_VERSION "${Qt5Core_VERSION}") GET_FILENAME_COMPONENT(Qt5_DIR ${Qt5Core_DIR} PATH) FILE(TO_NATIVE_PATH "${Qt5_DIR}/Qt5" Qt5_DIR) SET(SalomeQt5_COMPONENTS ${Qt5_FIND_COMPONENTS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 17fd52a98..b63a606a5 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,7 +22,9 @@ ## ADD_SUBDIRECTORY(CASCatch) ADD_SUBDIRECTORY(Qtx) -ADD_SUBDIRECTORY(HelpBrowser) +IF(SALOME_BUILD_WITH_QT5 AND SALOME_QT5HAVE_WEBENGINE) + ADD_SUBDIRECTORY(HelpBrowser) +ENDIF() ADD_SUBDIRECTORY(Style) ADD_SUBDIRECTORY(DDS) ADD_SUBDIRECTORY(QDS) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index b9ec2df18..7efcde84a 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -442,9 +442,10 @@ void LightApp_Application::start() /*!Closeapplication.*/ void LightApp_Application::closeApplication() { +#ifndef DISABLE_QTXWEBBROWSER QProcess::startDetached( "HelpBrowser", QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) ); - +#endif CAM_Application::closeApplication(); } @@ -1133,8 +1134,12 @@ void LightApp_Application::onHelpContentsModule() anApp.append( quote ); #endif QString aParams = resMgr->stringValue("ExternalBrowser", "parameters"); +#if DISABLE_QTXWEBBROWSER + bool useExtBrowser = true; +#else bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ); - +#endif + if( useExtBrowser ) { if ( !anApp.isEmpty() ) { RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile ); @@ -2263,7 +2268,12 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) // ... "Study properties" group <> // ... "Help browser" group <> +#ifndef DISABLE_QTXWEBBROWSER int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser"); +#else + int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab ); +#endif + #ifdef WIN32 QString platform = "winapplication"; #else diff --git a/src/Qtx/CMakeLists.txt b/src/Qtx/CMakeLists.txt index 96dc1f8df..176385a6a 100755 --- a/src/Qtx/CMakeLists.txt +++ b/src/Qtx/CMakeLists.txt @@ -75,13 +75,16 @@ SET(_moc_HEADERS QtxToolTip.h QtxTreeView.h QtxValidator.h - QtxWebBrowser.h QtxWorkspace.h QtxWorkspaceAction.h QtxWorkstack.h QtxWorkstackAction.h ) +IF(SALOME_BUILD_WITH_QT5 AND SALOME_QT5HAVE_WEBENGINE) + SET(_moc_HEADERS ${_moc_HEADERS} QtxWebBrowser.h) +ENDIF() + # obsolete files: not migrated to Qt4 # _moc_HEADERS << QtxListBox.h QtxTable.h # TODO: migrate or remove? @@ -165,13 +168,16 @@ SET(_other_SOURCES QtxTranslator.cxx QtxTreeView.cxx QtxValidator.cxx - QtxWebBrowser.cxx QtxWorkspace.cxx QtxWorkspaceAction.cxx QtxWorkstack.cxx QtxWorkstackAction.cxx ) +IF(SALOME_BUILD_WITH_QT5 AND SALOME_QT5HAVE_WEBENGINE) + SET(_other_SOURCES ${_other_SOURCES} QtxWebBrowser.cxx) +ENDIF() + # obsolete files: not migrated to Qt4 # _other_SOURCES << QtxListBox.cxx QtxTable.cxx # TODO: migrate or remove? diff --git a/src/Qtx/QtxWebBrowser.cxx b/src/Qtx/QtxWebBrowser.cxx index 213fe4f86..140289998 100644 --- a/src/Qtx/QtxWebBrowser.cxx +++ b/src/Qtx/QtxWebBrowser.cxx @@ -43,9 +43,19 @@ #include #include #include -#include +#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) + #include +#else + #include +#endif #include +// RNV: +// Since from Qt 5.6.0 version was removed QtWebKit tool, +// QtxWebBroswer is ported on QtWebEngine. So if it is built with +// Qt5 (Qt-5.5.1, Qt-5.6.0 and newer), it uses QtWebEngine. +// But for Qt4 QtWebKit tool is used, to provide backward compatibility. + namespace { bool isLocalFile( const QUrl& url ) @@ -105,8 +115,12 @@ bool QtxWebBrowser::Searcher::find( const QString& text, QtxSearchTool* st ) { QWebPage::FindFlags fl = 0; if ( st->isCaseSensitive() ) fl = fl | QWebPage::FindCaseSensitively; +#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) if ( st->isSearchWrapped() ) fl = fl | QWebPage::FindWrapsAroundDocument; return myView->findText( text, fl ); +#else + myView->findText( text, fl, [this](bool found) { return found; }); +#endif } /*! @@ -132,8 +146,12 @@ bool QtxWebBrowser::Searcher::findPrevious( const QString& text, QtxSearchTool* { QWebPage::FindFlags fl = QWebPage::FindBackward; if ( st->isCaseSensitive() ) fl = fl | QWebPage::FindCaseSensitively; +#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) if ( st->isSearchWrapped() ) fl = fl | QWebPage::FindWrapsAroundDocument; return myView->findText( text, fl ); +#else + myView->findText( text, fl, [this](bool found) { return found; }); +#endif } /*! @@ -337,15 +355,22 @@ QtxWebBrowser::QtxWebBrowser( ) : QMainWindow( 0 ) myWebView->pageAction( QWebPage::Copy )->setShortcut( QKeySequence::Copy ); myWebView->addAction( myWebView->pageAction( QWebPage::Copy ) ); +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) myWebView->pageAction( QWebPage::OpenLinkInNewWindow )->setVisible( false ); +#endif myWebView->pageAction( QWebPage::Back )->setText( tr( "Go Back" ) ); myWebView->pageAction( QWebPage::Forward )->setText( tr( "Go Forward" ) ); myWebView->pageAction( QWebPage::Reload )->setText( tr( "Refresh" ) ); - +#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) myWebView->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks ); - +#endif + myFindPanel = new QtxSearchTool( frame, myWebView, - QtxSearchTool::Basic | QtxSearchTool::Case | QtxSearchTool::Wrap, +#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) + QtxSearchTool::Basic | QtxSearchTool::Case | QtxSearchTool::Wrap, +#else + QtxSearchTool::Basic | QtxSearchTool::Case, +#endif Qt::Horizontal ); myFindPanel->setFrameStyle( QFrame::NoFrame | QFrame::Plain ); myFindPanel->setActivators( QtxSearchTool::SlashKey ); @@ -390,16 +415,26 @@ QtxWebBrowser::QtxWebBrowser( ) : QMainWindow( 0 ) main->setSpacing( 3 ); connect( myWebView, SIGNAL( titleChanged( QString ) ), SLOT( adjustTitle() ) ); - connect( myWebView, SIGNAL( loadFinished( bool ) ), SLOT( finished( bool ) ) ); - connect( myWebView, SIGNAL( linkClicked( QUrl ) ), SLOT( linkClicked( QUrl ) ) ); - connect( myWebView->page(), SIGNAL( linkHovered( QString, QString, QString ) ), - SLOT( linkHovered( QString, QString, QString ) ) ); + connect( myWebView, SIGNAL( loadFinished( bool ) ), SLOT( finished( bool ) ) ); + connect( myWebView->pageAction( QWebPage::DownloadLinkToDisk ), SIGNAL( triggered() ), SLOT( linkAction() ) ); +#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) + //QtWebKit case: + connect( myWebView, SIGNAL( linkClicked( QUrl ) ), SLOT( linkClicked( QUrl ) ) ); + connect( myWebView->page(), SIGNAL( linkHovered( QString, QString, QString ) ), + SLOT( linkHovered( QString, QString, QString ) ) ); disconnect( myWebView->pageAction( QWebPage::OpenLink ), 0, 0, 0 ); connect( myWebView->pageAction( QWebPage::OpenLink ), SIGNAL( triggered() ), SLOT( linkAction() ) ); - +#else + //QtWebEngine (Qt-5.6.0) case: + connect( myWebView->page(), SIGNAL( linkHovered( QString ) ), + SLOT( linkHovered( QString ) ) ); + disconnect( myWebView->pageAction( QWebPage::OpenLinkInThisWindow ), 0, 0, 0 ); + connect( myWebView->pageAction( QWebPage::OpenLinkInThisWindow ), SIGNAL( triggered() ), + SLOT( linkAction() ) ); +#endif setCentralWidget( frame ); setFocusProxy( myWebView ); setWindowIcon( QPixmap( ":/images/appicon.png" ) ); @@ -488,9 +523,13 @@ void QtxWebBrowser::about() */ void QtxWebBrowser::linkClicked( const QUrl& url ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) myWebView->page()->setLinkDelegationPolicy( QWebPage::DontDelegateLinks ); +#endif myWebView->load( url ); +#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) myWebView->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks ); +#endif } /*! @@ -500,7 +539,15 @@ void QtxWebBrowser::linkClicked( const QUrl& url ) \param content provides text within the link element, e.g., text inside an HTML anchor tag \internal */ + + void QtxWebBrowser::linkHovered( const QString& link, const QString& /*title*/, const QString& /*context*/ ) +{ + linkHovered(link); +} + +void QtxWebBrowser::linkHovered( const QString& link) + { QUrl url = link; if ( !link.isEmpty() && isLocalFile( url ) ) myLastUrl = url; @@ -543,7 +590,11 @@ void QtxWebBrowser::linkAction() if ( s == myWebView->pageAction( QWebPage::DownloadLinkToDisk ) ) { saveLink( myLastUrl.path() ); } - else if ( s == myWebView->pageAction( QWebPage::OpenLink ) ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) + if ( s == myWebView->pageAction( QWebPage::OpenLink ) ) { +#else + if ( s == myWebView->pageAction( QWebPage::OpenLinkInThisWindow ) ) { +#endif QString fileName = myLastUrl.path(); QString extension = QFileInfo( fileName ).suffix(); if ( extension != "html" && extension != "htm" ) { diff --git a/src/Qtx/QtxWebBrowser.h b/src/Qtx/QtxWebBrowser.h index 9b93ceb2b..fcbdccfa1 100644 --- a/src/Qtx/QtxWebBrowser.h +++ b/src/Qtx/QtxWebBrowser.h @@ -29,10 +29,16 @@ #include "Qtx.h" +#include #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) +#define QWebView QWebEngineView +#define QWebPage QWebEnginePage +#endif + class QButtonGroup; class QCheckBox; class QLabel; @@ -70,8 +76,9 @@ public Q_SLOTS: protected Q_SLOTS: virtual void about(); virtual void linkClicked( const QUrl& ); + virtual void linkHovered( const QString& ); virtual void linkHovered( const QString&, const QString&, const QString& ); - + private Q_SLOTS: void open(); void adjustTitle(); diff --git a/src/Style/Style_Salome.cxx b/src/Style/Style_Salome.cxx index de57552cf..65e934a86 100644 --- a/src/Style/Style_Salome.cxx +++ b/src/Style/Style_Salome.cxx @@ -201,12 +201,7 @@ 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 +Style_Salome::Style_Salome() : QWindowsStyle() { // initialize SALOME style resources Q_INIT_RESOURCE( Style ); @@ -326,12 +321,8 @@ 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; } @@ -352,11 +343,7 @@ 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; } @@ -369,12 +356,7 @@ void Style_Salome::polish ( QWidget* w ) qobject_cast(w) || qobject_cast(w) ) w->setAttribute( Qt::WA_Hover ); } - -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) QWindowsStyle::polish( w ); -#else - QCommonStyle::polish( w ); -#endif } /*! @@ -390,11 +372,7 @@ 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; } @@ -407,12 +385,7 @@ void Style_Salome::unpolish( QWidget* w ) qobject_cast(w) || qobject_cast(w) ) w->setAttribute( Qt::WA_Hover, false ); } - -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - QWindowsStyle::unpolish( w ); -#else - QCommonStyle::unpolish( w ); -#endif + QWindowsStyle::unpolish( w ); } /*! @@ -426,11 +399,7 @@ 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; } @@ -582,11 +551,7 @@ 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; @@ -657,11 +622,7 @@ 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 ); @@ -743,11 +704,7 @@ 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: @@ -797,19 +754,11 @@ 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 } } @@ -823,12 +772,8 @@ void Style_Salome::drawComplexControl( ComplexControl cc, const QStyleOptionComp 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 + if ( checkDebugLevel(5) ) { + QWindowsStyle::drawControl( ce, opt, p, w ); return; } @@ -957,11 +902,7 @@ 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 + QWindowsStyle::drawControl( ce, opt, p, w ); QRect r = opt->rect; bool horiz = r.width() > r.height(); int aLen = model()->splitHandleLength(); @@ -1018,18 +959,10 @@ 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: @@ -1558,11 +1491,7 @@ 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; } } @@ -1578,11 +1507,7 @@ 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; } @@ -1622,11 +1547,7 @@ 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: { @@ -1642,11 +1563,7 @@ 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; } @@ -1913,11 +1830,8 @@ 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) ) @@ -1931,11 +1845,7 @@ 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; @@ -2051,19 +1961,11 @@ 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 } } @@ -2078,17 +1980,9 @@ 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); @@ -2125,17 +2019,9 @@ 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)) { @@ -2164,13 +2050,9 @@ 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 -#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 @@ -2194,11 +2076,7 @@ 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 ) @@ -2213,11 +2091,7 @@ 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 } } @@ -2273,17 +2147,9 @@ 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 ) @@ -2312,26 +2178,14 @@ 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 ); @@ -2367,11 +2221,7 @@ 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 @@ -2425,30 +2275,18 @@ 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 846022e9d..ad2ad9066 100644 --- a/src/Style/Style_Salome.h +++ b/src/Style/Style_Salome.h @@ -23,12 +23,13 @@ #ifndef STYLE_SALOME_H #define STYLE_SALOME_H -#include "Style.h" #include +#include "Style.h" #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #include #else #include +#define QWindowsStyle QCommonStyle #endif class Style_Model; @@ -37,12 +38,7 @@ class QWidget; class QPainter; class QtxResourceMgr; -class STYLE_SALOME_EXPORT Style_Salome -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -: public QWindowsStyle -#else -: public QCommonStyle -#endif +class STYLE_SALOME_EXPORT Style_Salome : public QWindowsStyle { Q_OBJECT -- 2.39.2