From 61a5c6125deb1fceb126add5ca5fa6c345613297 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Mon, 22 Jun 2020 12:17:06 +0200 Subject: [PATCH] #5480: Drop Qt4 support and require Qt 5.12 or later. --- .gitlab-ci.yml | 2 +- CHANGELOG.md | 1 + CI/before_script.linux.sh | 1 - CI/before_script.msvc.sh | 6 +-- CI/before_script.osx.sh | 1 - CMakeLists.txt | 37 +++---------------- apps/launcher/CMakeLists.txt | 22 ++--------- apps/launcher/graphicspage.cpp | 19 ---------- apps/launcher/main.cpp | 12 ------ apps/opencs/CMakeLists.txt | 27 ++------------ apps/opencs/model/prefs/shortcutmanager.cpp | 4 -- apps/opencs/view/doc/newgame.cpp | 7 ---- apps/opencs/view/doc/startup.cpp | 8 ---- apps/opencs/view/doc/view.cpp | 7 ---- apps/opencs/view/prefs/dialogue.cpp | 12 ------ apps/opencs/view/render/scenewidget.cpp | 11 ++---- apps/opencs/view/render/worldspacewidget.cpp | 5 --- apps/opencs/view/tools/reporttable.cpp | 4 -- apps/opencs/view/widget/coloreditor.cpp | 7 ---- apps/opencs/view/widget/scenetoolrun.cpp | 5 --- .../view/widget/scenetoolshapebrush.cpp | 5 --- .../view/widget/scenetooltexturebrush.cpp | 5 --- apps/opencs/view/world/enumdelegate.cpp | 13 +------ apps/opencs/view/world/nestedtable.cpp | 4 -- apps/opencs/view/world/scriptedit.cpp | 10 ----- apps/opencs/view/world/scripterrortable.cpp | 5 --- apps/opencs/view/world/table.cpp | 4 -- apps/wizard/CMakeLists.txt | 26 ++----------- components/CMakeLists.txt | 18 ++------- extern/osgQt/CMakeLists.txt | 7 +--- extern/osgQt/GraphicsWindowQt.cpp | 20 ++-------- 31 files changed, 32 insertions(+), 283 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 514bac1ad2..3d798845e9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,7 +13,7 @@ Debian: before_script: - export APT_CACHE_DIR=`pwd`/apt-cache && mkdir -pv $APT_CACHE_DIR - apt-get update -yq - - apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y cmake libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-iostreams-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev libsdl2-dev libqt4-dev libopenal-dev libopenscenegraph-3.4-dev libunshield-dev libtinyxml-dev libmygui-dev libbullet-dev + - apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y cmake libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-iostreams-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev libsdl2-dev libqt5opengl5-dev libopenal-dev libopenscenegraph-3.4-dev libunshield-dev libtinyxml-dev libmygui-dev libbullet-dev stage: build script: - cores_to_use=$((`nproc`-2)); if (( $cores_to_use < 1 )); then cores_to_use=1; fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 09dabf311f..56069bdc1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ Feature #5297: Add a search function to the "Datafiles" tab of the OpenMW launcher Feature #5362: Show the soul gems' trapped soul in count dialog Feature #5445: Handle NiLines + Task #5480: Drop Qt4 support 0.46.0 ------ diff --git a/CI/before_script.linux.sh b/CI/before_script.linux.sh index a1c04cf667..5ab7483065 100755 --- a/CI/before_script.linux.sh +++ b/CI/before_script.linux.sh @@ -27,7 +27,6 @@ ${ANALYZE} cmake \ -DBUILD_NIFTEST=${BUILD_OPENMW_CS} \ -DBUILD_UNITTESTS=1 \ -DUSE_SYSTEM_TINYXML=1 \ - -DDESIRED_QT_VERSION=5 \ -DCMAKE_INSTALL_PREFIX=/usr \ -DBINDIR=/usr/games \ -DCMAKE_BUILD_TYPE="None" \ diff --git a/CI/before_script.msvc.sh b/CI/before_script.msvc.sh index 79885255f2..78acaead6c 100644 --- a/CI/before_script.msvc.sh +++ b/CI/before_script.msvc.sh @@ -776,8 +776,7 @@ fi fi cd $QT_SDK - add_cmake_opts -DDESIRED_QT_VERSION=5 \ - -DQT_QMAKE_EXECUTABLE="${QT_SDK}/bin/qmake.exe" \ + add_cmake_opts -DQT_QMAKE_EXECUTABLE="${QT_SDK}/bin/qmake.exe" \ -DCMAKE_PREFIX_PATH="$QT_SDK" if [ $CONFIGURATION == "Debug" ]; then SUFFIX="d" @@ -789,8 +788,7 @@ fi echo Done. else QT_SDK="C:/Qt/5.13/msvc2017${SUFFIX}" - add_cmake_opts -DDESIRED_QT_VERSION=5 \ - -DQT_QMAKE_EXECUTABLE="${QT_SDK}/bin/qmake.exe" \ + add_cmake_opts -DQT_QMAKE_EXECUTABLE="${QT_SDK}/bin/qmake.exe" \ -DCMAKE_PREFIX_PATH="$QT_SDK" if [ $CONFIGURATION == "Debug" ]; then SUFFIX="d" diff --git a/CI/before_script.osx.sh b/CI/before_script.osx.sh index 9fae97af61..01d9d2b80a 100755 --- a/CI/before_script.osx.sh +++ b/CI/before_script.osx.sh @@ -17,7 +17,6 @@ cmake \ -D CMAKE_OSX_SYSROOT="macosx10.14" \ -D CMAKE_BUILD_TYPE=Release \ -D OPENMW_OSX_DEPLOYMENT=TRUE \ --D DESIRED_QT_VERSION=5 \ -D BUILD_ESMTOOL=FALSE \ -G"Unix Makefiles" \ .. diff --git a/CMakeLists.txt b/CMakeLists.txt index 5db93ddd89..edd07bf95e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,11 +19,6 @@ else() set(USE_QT TRUE) endif() -if (USE_QT) - set(DESIRED_QT_VERSION 4 CACHE STRING "The QT version OpenMW should use (4 or 5)") - set_property(CACHE DESIRED_QT_VERSION PROPERTY STRINGS 4 5) -endif() - # set the minimum required version across the board cmake_minimum_required(VERSION 3.1.0) @@ -153,18 +148,12 @@ endif() find_package(OpenGL REQUIRED) if (USE_QT) - message(STATUS "Using Qt${DESIRED_QT_VERSION}") - - if (DESIRED_QT_VERSION MATCHES 4) - find_package(Qt4 REQUIRED COMPONENTS QtCore QtGui QtNetwork QtOpenGL) - else() - find_package(Qt5Widgets REQUIRED) - find_package(Qt5Core REQUIRED) - find_package(Qt5Network REQUIRED) - find_package(Qt5OpenGL REQUIRED) + find_package(Qt5Core 5.12 REQUIRED) + find_package(Qt5Widgets REQUIRED) + find_package(Qt5Network REQUIRED) + find_package(Qt5OpenGL REQUIRED) # Instruct CMake to run moc automatically when needed. #set(CMAKE_AUTOMOC ON) - endif() endif() # Sound setup @@ -291,17 +280,6 @@ if(OSG_STATIC) list(APPEND OPENSCENEGRAPH_LIBRARIES ${OSGPlugins_LIBRARIES}) endif() -if(QT_STATIC) - if(WIN32) - if(DESIRED_QT_VERSION MATCHES 4) - # QtCore needs WSAAsyncSelect from Ws2_32.lib - set(QT_QTCORE_LIBRARY ${QT_QTCORE_LIBRARY} Ws2_32.lib) - message("QT_QTCORE_LIBRARY: ${QT_QTCORE_LIBRARY}") - endif() - endif() -endif() - - set(BOOST_COMPONENTS system filesystem program_options iostreams) if(WIN32) set(BOOST_COMPONENTS ${BOOST_COMPONENTS} locale) @@ -517,11 +495,6 @@ if(WIN32) INSTALL(FILES "${OpenMW_BINARY_DIR}/Debug/gamecontrollerdb.txt" DESTINATION "." CONFIGURATIONS Debug) INSTALL(FILES "${OpenMW_BINARY_DIR}/Release/gamecontrollerdb.txt" DESTINATION "." CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel) - IF(DESIRED_QT_VERSION MATCHES 5) - INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/Debug/platforms" DESTINATION "." CONFIGURATIONS Debug) - INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/Release/platforms" DESTINATION "." CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel) - ENDIF() - INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/Debug/resources" DESTINATION "." CONFIGURATIONS Debug) INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/Release/resources" DESTINATION "." CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel) @@ -785,7 +758,7 @@ if (WIN32) endif() # Apple bundling -if (OPENMW_OSX_DEPLOYMENT AND APPLE AND DESIRED_QT_VERSION MATCHES 5) +if (OPENMW_OSX_DEPLOYMENT AND APPLE) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13 AND CMAKE_VERSION VERSION_LESS 3.13.4) message(FATAL_ERROR "macOS packaging is broken in early CMake 3.13 releases, see https://gitlab.com/OpenMW/openmw/issues/4767. Please use at least 3.13.4 or an older version like 3.12.4") endif () diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index bfc08a7d64..329d06a570 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -70,16 +70,9 @@ if(WIN32) set(QT_USE_QTMAIN TRUE) endif(WIN32) -if (DESIRED_QT_VERSION MATCHES 4) - include(${QT_USE_FILE}) - QT4_ADD_RESOURCES(RCC_SRCS ${CMAKE_SOURCE_DIR}/files/launcher/launcher.qrc) - QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC}) - QT4_WRAP_UI(UI_HDRS ${LAUNCHER_UI}) -else() - QT5_ADD_RESOURCES(RCC_SRCS ${CMAKE_SOURCE_DIR}/files/launcher/launcher.qrc) - QT5_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC}) - QT5_WRAP_UI(UI_HDRS ${LAUNCHER_UI}) -endif() +QT5_ADD_RESOURCES(RCC_SRCS ${CMAKE_SOURCE_DIR}/files/launcher/launcher.qrc) +QT5_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC}) +QT5_WRAP_UI(UI_HDRS ${LAUNCHER_UI}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) if(NOT WIN32) @@ -105,14 +98,7 @@ target_link_libraries(openmw-launcher components ) -if (DESIRED_QT_VERSION MATCHES 4) - target_link_libraries(openmw-launcher ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY}) - if(WIN32) - target_link_libraries(openmw-launcher ${QT_QTMAIN_LIBRARY}) - endif(WIN32) -else() - target_link_libraries(openmw-launcher Qt5::Widgets Qt5::Core) -endif() +target_link_libraries(openmw-launcher Qt5::Widgets Qt5::Core) if (BUILD_WITH_CODE_COVERAGE) add_definitions (--coverage) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index d48e627e19..45c093beed 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -3,10 +3,7 @@ #include #include #include - -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include -#endif #ifdef MAC_OS_X_VERSION_MIN_REQUIRED #undef MAC_OS_X_VERSION_MIN_REQUIRED @@ -54,13 +51,11 @@ Launcher::GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, Settings: bool Launcher::GraphicsPage::setupSDL() { -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) bool sdlConnectSuccessful = initSDL(); if (!sdlConnectSuccessful) { return false; } -#endif int displays = SDL_GetNumVideoDisplays(); @@ -81,10 +76,8 @@ bool Launcher::GraphicsPage::setupSDL() screenComboBox->addItem(QString(tr("Screen ")) + QString::number(i + 1)); } -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) // Disconnect from SDL processes quitSDL(); -#endif return true; } @@ -323,7 +316,6 @@ QRect Launcher::GraphicsPage::getMaximumResolution() { QRect max; -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) for (QScreen* screen : QGuiApplication::screens()) { QRect res = screen->geometry(); @@ -332,17 +324,6 @@ QRect Launcher::GraphicsPage::getMaximumResolution() if (res.height() > max.height()) max.setHeight(res.height()); } -#else - int screens = QApplication::desktop()->screenCount(); - for (int i = 0; i < screens; ++i) - { - QRect res = QApplication::desktop()->screenGeometry(i); - if (res.width() > max.width()) - max.setWidth(res.width()); - if (res.height() > max.height()) - max.setHeight(res.height()); - } -#endif return max; } diff --git a/apps/launcher/main.cpp b/apps/launcher/main.cpp index cf720f8b80..f15abafce0 100644 --- a/apps/launcher/main.cpp +++ b/apps/launcher/main.cpp @@ -13,18 +13,11 @@ #endif // MAC_OS_X_VERSION_MIN_REQUIRED #include "maindialog.hpp" -#include "sdlinit.hpp" int main(int argc, char *argv[]) { try { -// Note: we should init SDL2 before Qt4 to avoid crashes on Linux, -// but we should init SDL2 after Qt5 to avoid input issues on MacOS X. -#if QT_VERSION < QT_VERSION_CHECK(5,0,0) - initSDL(); -#endif - QApplication app(argc, argv); // Internationalization @@ -50,11 +43,6 @@ int main(int argc, char *argv[]) int exitCode = app.exec(); -#if QT_VERSION < QT_VERSION_CHECK(5,0,0) - // Disconnect from SDL processes - quitSDL(); -#endif - return exitCode; } catch (std::exception& e) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 5dc2fb26f5..401e7896de 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -149,16 +149,9 @@ if(WIN32) set(QT_USE_QTMAIN TRUE) endif(WIN32) -if (DESIRED_QT_VERSION MATCHES 4) - include(${QT_USE_FILE}) - qt4_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI}) - qt4_wrap_cpp(OPENCS_MOC_SRC ${OPENCS_HDR_QT}) - qt4_add_resources(OPENCS_RES_SRC ${OPENCS_RES}) -else() - qt5_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI}) - qt5_wrap_cpp(OPENCS_MOC_SRC ${OPENCS_HDR_QT}) - qt5_add_resources(OPENCS_RES_SRC ${OPENCS_RES}) -endif() +qt5_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI}) +qt5_wrap_cpp(OPENCS_MOC_SRC ${OPENCS_HDR_QT}) +qt5_add_resources(OPENCS_RES_SRC ${OPENCS_RES}) # for compiled .ui files include_directories(${CMAKE_CURRENT_BINARY_DIR}) @@ -236,19 +229,7 @@ target_link_libraries(openmw-cs components ) -if (DESIRED_QT_VERSION MATCHES 4) - target_link_libraries(openmw-cs - ${QT_QTGUI_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${QT_QTNETWORK_LIBRARY} - ${QT_QTOPENGL_LIBRARY}) - - if (WIN32) - target_link_libraries(openmw-cs ${QT_QTMAIN_LIBRARY}) - endif() -else() - target_link_libraries(openmw-cs Qt5::Widgets Qt5::Core Qt5::Network Qt5::OpenGL) -endif() +target_link_libraries(openmw-cs Qt5::Widgets Qt5::Core Qt5::Network Qt5::OpenGL) if (WIN32) target_link_libraries(openmw-cs ${Boost_LOCALE_LIBRARY}) diff --git a/apps/opencs/model/prefs/shortcutmanager.cpp b/apps/opencs/model/prefs/shortcutmanager.cpp index c4b46958d7..f39492c6c7 100644 --- a/apps/opencs/model/prefs/shortcutmanager.cpp +++ b/apps/opencs/model/prefs/shortcutmanager.cpp @@ -685,7 +685,6 @@ namespace CSMPrefs std::make_pair((int)Qt::Key_ContrastAdjust , "ContrastAdjust"), std::make_pair((int)Qt::Key_LaunchG , "LaunchG"), std::make_pair((int)Qt::Key_LaunchH , "LaunchH"), -#if QT_VERSION >= QT_VERSION_CHECK(5,7,0) std::make_pair((int)Qt::Key_TouchpadToggle , "TouchpadToggle"), std::make_pair((int)Qt::Key_TouchpadOn , "TouchpadOn"), std::make_pair((int)Qt::Key_TouchpadOff , "TouchpadOff"), @@ -706,7 +705,6 @@ namespace CSMPrefs std::make_pair((int)Qt::Key_Find , "Find"), std::make_pair((int)Qt::Key_Undo , "Undo"), std::make_pair((int)Qt::Key_Redo , "Redo"), -#endif std::make_pair((int)Qt::Key_AltGr , "AltGr"), std::make_pair((int)Qt::Key_Multi_key , "Multi_key"), std::make_pair((int)Qt::Key_Kanji , "Kanji"), @@ -770,9 +768,7 @@ namespace CSMPrefs std::make_pair((int)Qt::Key_Sleep , "Sleep"), std::make_pair((int)Qt::Key_Play , "Play"), std::make_pair((int)Qt::Key_Zoom , "Zoom"), -#if QT_VERSION >= QT_VERSION_CHECK(5,7,0) std::make_pair((int)Qt::Key_Exit , "Exit"), -#endif std::make_pair((int)Qt::Key_Context1 , "Context1"), std::make_pair((int)Qt::Key_Context2 , "Context2"), std::make_pair((int)Qt::Key_Context3 , "Context3"), diff --git a/apps/opencs/view/doc/newgame.cpp b/apps/opencs/view/doc/newgame.cpp index 8e976c68f9..7b247652ed 100644 --- a/apps/opencs/view/doc/newgame.cpp +++ b/apps/opencs/view/doc/newgame.cpp @@ -5,10 +5,7 @@ #include #include #include - -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include -#endif #include "filewidget.hpp" #include "adjusterwidget.hpp" @@ -50,11 +47,7 @@ CSVDoc::NewGameDialogue::NewGameDialogue() connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)), mAdjusterWidget, SLOT (setName (const QString&, bool))); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) QRect scr = QGuiApplication::primaryScreen()->geometry(); -#else - QRect scr = QApplication::desktop()->screenGeometry(); -#endif QRect rect = geometry(); move (scr.center().x() - rect.center().x(), scr.center().y() - rect.center().y()); } diff --git a/apps/opencs/view/doc/startup.cpp b/apps/opencs/view/doc/startup.cpp index beb2cf7d81..3a1950a6e3 100644 --- a/apps/opencs/view/doc/startup.cpp +++ b/apps/opencs/view/doc/startup.cpp @@ -9,10 +9,7 @@ #include #include #include - -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include -#endif QPushButton *CSVDoc::StartupDialogue::addButton (const QString& label, const QIcon& icon) { @@ -123,12 +120,7 @@ CSVDoc::StartupDialogue::StartupDialogue() : mWidth (0), mColumn (2) setLayout (layout); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) QRect scr = QGuiApplication::primaryScreen()->geometry(); -#else - QRect scr = QApplication::desktop()->screenGeometry(); -#endif - QRect rect = geometry(); move (scr.center().x() - rect.center().x(), scr.center().y() - rect.center().y()); } diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index ce04f6adaf..ac7c8ebf97 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -14,10 +14,7 @@ #include #include #include - -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include -#endif #include "../../model/doc/document.hpp" #include "../../model/prefs/state.hpp" @@ -1071,11 +1068,7 @@ void CSVDoc::View::updateWidth(bool isGrowLimit, int minSubViewWidth) if (isGrowLimit) rect = dw->screenGeometry(this); else -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) rect = QGuiApplication::screens().at(dw->screenNumber(this))->geometry(); -#else - rect = dw->screenGeometry(dw->screen(dw->screenNumber(this))); -#endif if (!mScrollbarOnly && mScroll && mSubViews.size() > 1) { diff --git a/apps/opencs/view/prefs/dialogue.cpp b/apps/opencs/view/prefs/dialogue.cpp index 853031ccd3..7e41fcf822 100644 --- a/apps/opencs/view/prefs/dialogue.cpp +++ b/apps/opencs/view/prefs/dialogue.cpp @@ -1,4 +1,3 @@ - #include "dialogue.hpp" #include @@ -7,10 +6,7 @@ #include #include #include - -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include -#endif #include @@ -39,11 +35,7 @@ void CSVPrefs::Dialogue::buildCategorySelector (QSplitter *main) { QString label = QString::fromUtf8 (iter->second.getKey().c_str()); -#if QT_VERSION >= QT_VERSION_CHECK(5,11,0) maxWidth = std::max (maxWidth, metrics.horizontalAdvance (label)); -#else - maxWidth = std::max (maxWidth, metrics.width (label)); -#endif list->addItem (label); } @@ -116,11 +108,7 @@ void CSVPrefs::Dialogue::show() } else { -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) QRect scr = QGuiApplication::primaryScreen()->geometry(); -#else - QRect scr = QApplication::desktop()->screenGeometry(); -#endif // otherwise place at the centre of the screen QPoint screenCenter = scr.center(); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index e50d7b2cd3..07131cb7b6 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -143,14 +143,9 @@ void RenderWidget::toggleRenderStats() CompositeViewer::CompositeViewer() : mSimulationTime(0.0) { -#if QT_VERSION >= 0x050000 - // Qt5 is currently crashing and reporting "Cannot make QOpenGLContext current in a different thread" when the viewer is run multi-threaded, this is regression from Qt4 - osgViewer::ViewerBase::ThreadingModel threadingModel = osgViewer::ViewerBase::SingleThreaded; -#else - osgViewer::ViewerBase::ThreadingModel threadingModel = osgViewer::ViewerBase::DrawThreadPerContext; -#endif - - setThreadingModel(threadingModel); + // TODO: Upgrade osgQt to support osgViewer::ViewerBase::DrawThreadPerContext + // https://gitlab.com/OpenMW/openmw/-/issues/5481 + setThreadingModel(osgViewer::ViewerBase::SingleThreaded); #if OSG_VERSION_GREATER_OR_EQUAL(3,5,5) setUseConfigureAffinity(false); diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 8e54b9a81a..32f4a8ef33 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -646,13 +646,8 @@ void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event) if (mDragging) { -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) mDragX = event->localPos().x(); mDragY = height() - event->localPos().y(); -#else - mDragX = event->posF().x(); - mDragY = height() - event->posF().y(); -#endif } } else diff --git a/apps/opencs/view/tools/reporttable.cpp b/apps/opencs/view/tools/reporttable.cpp index a970af1681..69caba5471 100644 --- a/apps/opencs/view/tools/reporttable.cpp +++ b/apps/opencs/view/tools/reporttable.cpp @@ -144,11 +144,7 @@ CSVTools::ReportTable::ReportTable (CSMDoc::Document& document, : CSVWorld::DragRecordTable (document, parent), mModel (document.getReport (id)), mRefreshAction (0), mRefreshState (refreshState) { -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) horizontalHeader()->setSectionResizeMode (QHeaderView::Interactive); -#else - horizontalHeader()->setResizeMode (QHeaderView::Interactive); -#endif horizontalHeader()->setStretchLastSection (true); verticalHeader()->hide(); setSortingEnabled (true); diff --git a/apps/opencs/view/widget/coloreditor.cpp b/apps/opencs/view/widget/coloreditor.cpp index cd19e54a31..1cc649313b 100644 --- a/apps/opencs/view/widget/coloreditor.cpp +++ b/apps/opencs/view/widget/coloreditor.cpp @@ -5,10 +5,7 @@ #include #include #include - -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include -#endif #include "colorpickerpopup.hpp" @@ -99,11 +96,7 @@ QPoint CSVWidget::ColorEditor::calculatePopupPosition() { QRect editorGeometry = geometry(); QRect popupGeometry = mColorPicker->geometry(); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) QRect screenGeometry = QGuiApplication::primaryScreen()->geometry(); -#else - QRect screenGeometry = QApplication::desktop()->screenGeometry(); -#endif // Center the popup horizontally relative to the editor int localPopupX = (editorGeometry.width() - popupGeometry.width()) / 2; diff --git a/apps/opencs/view/widget/scenetoolrun.cpp b/apps/opencs/view/widget/scenetoolrun.cpp index 1e2d44e7a1..b532820367 100644 --- a/apps/opencs/view/widget/scenetoolrun.cpp +++ b/apps/opencs/view/widget/scenetoolrun.cpp @@ -64,13 +64,8 @@ CSVWidget::SceneToolRun::SceneToolRun (SceneToolbar *parent, const QString& tool mTable->setShowGrid (false); mTable->verticalHeader()->hide(); mTable->horizontalHeader()->hide(); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) mTable->horizontalHeader()->setSectionResizeMode (0, QHeaderView::Stretch); mTable->horizontalHeader()->setSectionResizeMode (1, QHeaderView::ResizeToContents); -#else - mTable->horizontalHeader()->setResizeMode (0, QHeaderView::Stretch); - mTable->horizontalHeader()->setResizeMode (1, QHeaderView::ResizeToContents); -#endif mTable->setSelectionMode (QAbstractItemView::NoSelection); layout->addWidget (mTable); diff --git a/apps/opencs/view/widget/scenetoolshapebrush.cpp b/apps/opencs/view/widget/scenetoolshapebrush.cpp index e4647d600d..4b2d20004b 100644 --- a/apps/opencs/view/widget/scenetoolshapebrush.cpp +++ b/apps/opencs/view/widget/scenetoolshapebrush.cpp @@ -180,13 +180,8 @@ CSVWidget::SceneToolShapeBrush::SceneToolShapeBrush (SceneToolbar *parent, const mTable->setShowGrid (true); mTable->verticalHeader()->hide(); mTable->horizontalHeader()->hide(); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) mTable->horizontalHeader()->setSectionResizeMode (0, QHeaderView::Stretch); mTable->horizontalHeader()->setSectionResizeMode (1, QHeaderView::Stretch); -#else - mTable->horizontalHeader()->setResizeMode (0, QHeaderView::Stretch); - mTable->horizontalHeader()->setResizeMode (1, QHeaderView::Stretch); -#endif mTable->setSelectionMode (QAbstractItemView::NoSelection); layout->addWidget (mTable); diff --git a/apps/opencs/view/widget/scenetooltexturebrush.cpp b/apps/opencs/view/widget/scenetooltexturebrush.cpp index 35937f1a67..272a5de42e 100644 --- a/apps/opencs/view/widget/scenetooltexturebrush.cpp +++ b/apps/opencs/view/widget/scenetooltexturebrush.cpp @@ -243,13 +243,8 @@ CSVWidget::SceneToolTextureBrush::SceneToolTextureBrush (SceneToolbar *parent, c mTable->setShowGrid (true); mTable->verticalHeader()->hide(); mTable->horizontalHeader()->hide(); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) mTable->horizontalHeader()->setSectionResizeMode (0, QHeaderView::Stretch); mTable->horizontalHeader()->setSectionResizeMode (1, QHeaderView::Stretch); -#else - mTable->horizontalHeader()->setResizeMode (0, QHeaderView::Stretch); - mTable->horizontalHeader()->setResizeMode (1, QHeaderView::Stretch); -#endif mTable->setSelectionMode (QAbstractItemView::NoSelection); layout->addWidget (mTable); diff --git a/apps/opencs/view/world/enumdelegate.cpp b/apps/opencs/view/world/enumdelegate.cpp index 0f920db944..eb1d631056 100644 --- a/apps/opencs/view/world/enumdelegate.cpp +++ b/apps/opencs/view/world/enumdelegate.cpp @@ -108,13 +108,8 @@ void CSVWorld::EnumDelegate::paint (QPainter *painter, const QStyleOptionViewIte const QModelIndex& index) const { int valueIndex = getValueIndex(index); - if (valueIndex != -1) - { -#if QT_VERSION >= QT_VERSION_CHECK(5,7,0) + if (valueIndex != - QStyleOptionViewItem itemOption(option); -#else - QStyleOptionViewItemV4 itemOption(option); -#endif itemOption.text = mValues.at(valueIndex).second; QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &itemOption, painter); } @@ -134,13 +129,7 @@ QSize CSVWorld::EnumDelegate::sizeHint(const QStyleOptionViewItem &option, const itemOption.state = option.state; const QString &valueText = mValues.at(valueIndex).second; - -#if QT_VERSION >= QT_VERSION_CHECK(5,11,0) QSize valueSize = QSize(itemOption.fontMetrics.horizontalAdvance(valueText), itemOption.fontMetrics.height()); -#else - QSize valueSize = QSize(itemOption.fontMetrics.width(valueText), itemOption.fontMetrics.height()); -#endif - itemOption.currentText = valueText; return QApplication::style()->sizeFromContents(QStyle::CT_ComboBox, &itemOption, valueSize); } diff --git a/apps/opencs/view/world/nestedtable.cpp b/apps/opencs/view/world/nestedtable.cpp index 1b72211e8e..d52f7ca736 100644 --- a/apps/opencs/view/world/nestedtable.cpp +++ b/apps/opencs/view/world/nestedtable.cpp @@ -33,11 +33,7 @@ CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document, setSelectionBehavior (QAbstractItemView::SelectRows); setSelectionMode (QAbstractItemView::ExtendedSelection); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) horizontalHeader()->setSectionResizeMode (QHeaderView::Interactive); -#else - horizontalHeader()->setResizeMode (QHeaderView::Interactive); -#endif verticalHeader()->hide(); int columns = model->columnCount(QModelIndex()); diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 996e80da42..9083359d27 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -205,12 +205,7 @@ bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id) const void CSVWorld::ScriptEdit::setTabWidth() { // Set tab width to specified number of characters using current font. -#if QT_VERSION >= QT_VERSION_CHECK(5,11,0) setTabStopDistance(mTabCharCount * fontMetrics().horizontalAdvance(' ')); -#else - setTabStopWidth(mTabCharCount * fontMetrics().width(' ')); -#endif - } void CSVWorld::ScriptEdit::wrapLines(bool wrap) @@ -290,12 +285,7 @@ int CSVWorld::ScriptEdit::lineNumberAreaWidth() ++digits; } -#if QT_VERSION >= QT_VERSION_CHECK(5,11,0) int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits; -#else - int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits; -#endif - return space; } diff --git a/apps/opencs/view/world/scripterrortable.cpp b/apps/opencs/view/world/scripterrortable.cpp index ca7cbd1599..45809b28c6 100644 --- a/apps/opencs/view/world/scripterrortable.cpp +++ b/apps/opencs/view/world/scripterrortable.cpp @@ -83,13 +83,8 @@ CSVWorld::ScriptErrorTable::ScriptErrorTable (const CSMDoc::Document& document, QStringList headers; headers << "Severity" << "Line" << "Description"; setHorizontalHeaderLabels (headers); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) horizontalHeader()->setSectionResizeMode (0, QHeaderView::ResizeToContents); horizontalHeader()->setSectionResizeMode (1, QHeaderView::ResizeToContents); -#else - horizontalHeader()->setResizeMode (0, QHeaderView::ResizeToContents); - horizontalHeader()->setResizeMode (1, QHeaderView::ResizeToContents); -#endif horizontalHeader()->setStretchLastSection (true); verticalHeader()->hide(); setColumnHidden (3, true); diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index e2bc87a725..dcf143a66d 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -262,11 +262,7 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, mDispatcher = new CSMWorld::CommandDispatcher (document, id, this); setModel (mProxyModel); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) horizontalHeader()->setSectionResizeMode (QHeaderView::Interactive); -#else - horizontalHeader()->setResizeMode (QHeaderView::Interactive); -#endif verticalHeader()->hide(); setSelectionBehavior (QAbstractItemView::SelectRows); setSelectionMode (QAbstractItemView::ExtendedSelection); diff --git a/apps/wizard/CMakeLists.txt b/apps/wizard/CMakeLists.txt index 8d97bbcbfa..10e06d1ff0 100644 --- a/apps/wizard/CMakeLists.txt +++ b/apps/wizard/CMakeLists.txt @@ -79,16 +79,9 @@ if(WIN32) set(QT_USE_QTMAIN TRUE) endif(WIN32) -if (DESIRED_QT_VERSION MATCHES 4) - include(${QT_USE_FILE}) - QT4_ADD_RESOURCES(RCC_SRCS ${CMAKE_SOURCE_DIR}/files/wizard/wizard.qrc) - QT4_WRAP_CPP(MOC_SRCS ${WIZARD_HEADER_MOC}) - QT4_WRAP_UI(UI_HDRS ${WIZARD_UI}) -else() - QT5_ADD_RESOURCES(RCC_SRCS ${CMAKE_SOURCE_DIR}/files/wizard/wizard.qrc) - QT5_WRAP_CPP(MOC_SRCS ${WIZARD_HEADER_MOC}) - QT5_WRAP_UI(UI_HDRS ${WIZARD_UI}) -endif() +QT5_ADD_RESOURCES(RCC_SRCS ${CMAKE_SOURCE_DIR}/files/wizard/wizard.qrc) +QT5_WRAP_CPP(MOC_SRCS ${WIZARD_HEADER_MOC}) +QT5_WRAP_UI(UI_HDRS ${WIZARD_UI}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) @@ -109,23 +102,12 @@ target_link_libraries(openmw-wizard components ) -if (DESIRED_QT_VERSION MATCHES 4) - target_link_libraries(openmw-wizard - ${QT_QTGUI_LIBRARY} - ${QT_QTCORE_LIBRARY}) - - if (WIN32) - target_link_libraries(openmw-wizard ${QT_QTMAIN_LIBRARY}) - endif() -else() - target_link_libraries(openmw-wizard Qt5::Widgets Qt5::Core) -endif() +target_link_libraries(openmw-wizard Qt5::Widgets Qt5::Core) if (OPENMW_USE_UNSHIELD) target_link_libraries(openmw-wizard ${LIBUNSHIELD_LIBRARIES}) endif() - if(DPKG_PROGRAM) INSTALL(TARGETS openmw-wizard RUNTIME DESTINATION games COMPONENT openmw-wizard) endif() diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index d5ab8d8fe2..1d4a84ce1f 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -200,14 +200,8 @@ if (USE_QT) helpviewer ) - if (DESIRED_QT_VERSION MATCHES 4) - include(${QT_USE_FILE}) - QT4_WRAP_UI(ESM_UI_HDR ${ESM_UI}) - QT4_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES}) - else() - QT5_WRAP_UI(ESM_UI_HDR ${ESM_UI}) - QT5_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES}) - endif() + QT5_WRAP_UI(ESM_UI_HDR ${ESM_UI}) + QT5_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES}) endif() if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -252,13 +246,7 @@ if (WIN32) endif() if (USE_QT) - if (DESIRED_QT_VERSION MATCHES 4) - target_link_libraries(components - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY}) - else() - target_link_libraries(components Qt5::Widgets Qt5::Core) - endif() + target_link_libraries(components Qt5::Widgets Qt5::Core) endif() if (GIT_CHECKOUT) diff --git a/extern/osgQt/CMakeLists.txt b/extern/osgQt/CMakeLists.txt index 78a4e60344..6cf2dc9353 100644 --- a/extern/osgQt/CMakeLists.txt +++ b/extern/osgQt/CMakeLists.txt @@ -8,12 +8,7 @@ set(OSGQT_SOURCE_FILES add_library(${OSGQT_LIBRARY} STATIC ${OSGQT_SOURCE_FILES}) -if (DESIRED_QT_VERSION MATCHES 4) - include(${QT_USE_FILE}) - target_link_libraries(${OSGQT_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTOPENGL_LIBRARY}) -else() - target_link_libraries(${OSGQT_LIBRARY} Qt5::Core Qt5::OpenGL) -endif() +target_link_libraries(${OSGQT_LIBRARY} Qt5::Core Qt5::OpenGL) link_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/extern/osgQt/GraphicsWindowQt.cpp b/extern/osgQt/GraphicsWindowQt.cpp index aa9b4bbdb6..e7cc880850 100644 --- a/extern/osgQt/GraphicsWindowQt.cpp +++ b/extern/osgQt/GraphicsWindowQt.cpp @@ -17,18 +17,11 @@ #include #include #include - -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include -#endif using namespace osgQt; -#if (QT_VERSION < QT_VERSION_CHECK(5, 2, 0)) - #define GETDEVICEPIXELRATIO() 1.0 -#else - #define GETDEVICEPIXELRATIO() devicePixelRatio() -#endif +#define GETDEVICEPIXELRATIO() devicePixelRatio() GLWidget::GLWidget( QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f) : QGLWidget(parent, shareWidget, f), _gw( NULL ) @@ -119,13 +112,11 @@ bool GLWidget::event( QEvent* event ) enqueueDeferredEvent(QEvent::ParentChange); return true; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) else if (event->type() == QEvent::PlatformSurface && static_cast(event)->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) { if (_gw) _gw->close(); } -#endif // perform regular event handling return QGLWidget::event( event ); @@ -209,11 +200,7 @@ bool GraphicsWindowQt::init( QWidget* parent, const QGLWidget* shareWidget, Qt:: // WindowFlags Qt::WindowFlags flags = f | Qt::Window | Qt::CustomizeWindowHint; if ( _traits->windowDecoration ) - flags |= Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowSystemMenuHint -#if (QT_VERSION_CHECK(4, 5, 0) <= QT_VERSION) - | Qt::WindowCloseButtonHint -#endif - ; + flags |= Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; // create widget _widget = new GLWidget( traits2qglFormat( _traits.get() ), parent, shareWidget, flags ); @@ -527,11 +514,10 @@ bool GraphicsWindowQt::releaseContextImplementation() void GraphicsWindowQt::swapBuffersImplementation() { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) // QOpenGLContext complains if we swap on an non-exposed QWindow if (!_widget || !_widget->windowHandle()->isExposed()) return; -#endif + // FIXME: the processDeferredEvents should really be executed in a GUI (main) thread context but // I couln't find any reliable way to do this. For now, lets hope non of *GUI thread only operations* will // be executed in a QGLWidget::event handler. On the other hand, calling GUI only operations in the