diff options
author | Nadia Holmquist Pedersen <nadia@nhp.sh> | 2021-04-24 15:30:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-24 13:30:10 +0000 |
commit | 0834fc1533d2f871ec6c62dff5ca8548adc25959 (patch) | |
tree | 0ab28cfdddc1a3ee919cf81e9963ba412dcc423e | |
parent | def272fac4151b6fe5d76d73c5af3bc9bc8df9e1 (diff) |
Add support for building with Qt6 (#865)
Co-authored-by: WaluigiWare64 <68647953+WaluigiWare64@users.noreply.github.com>
-rw-r--r-- | src/frontend/qt_sdl/CMakeLists.txt | 45 | ||||
-rw-r--r-- | src/frontend/qt_sdl/CheatsDialog.cpp | 5 | ||||
-rw-r--r-- | src/frontend/qt_sdl/VideoSettingsDialog.cpp | 2 |
3 files changed, 40 insertions, 12 deletions
diff --git a/src/frontend/qt_sdl/CMakeLists.txt b/src/frontend/qt_sdl/CMakeLists.txt index b4da103..36fc577 100644 --- a/src/frontend/qt_sdl/CMakeLists.txt +++ b/src/frontend/qt_sdl/CMakeLists.txt @@ -32,20 +32,36 @@ SET(SOURCES_QT_SDL ../../../melon.qrc ) +option(USE_QT6 "Build using Qt 6 instead of 5" OFF) + if (WIN32) set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -i <SOURCE> -o <OBJECT>") endif() -if (BUILD_STATIC AND QT5_STATIC_DIR) - set(QT5_STATIC_BASE ${QT5_STATIC_DIR}/lib/cmake/Qt5) - set(Qt5_DIR ${QT5_STATIC_BASE}) - set(Qt5Core_DIR ${QT5_STATIC_BASE}Core) - set(Qt5Gui_DIR ${QT5_STATIC_BASE}Gui) - set(Qt5Widgets_DIR ${QT5_STATIC_BASE}Widgets) +if (USE_QT6) + if (BUILD_STATIC AND QT6_STATIC_DIR) + set(QT6_STATIC_BASE ${QT6_STATIC_DIR}/lib/cmake/Qt6) + set(Qt6_DIR ${QT6_STATIC_BASE}) + set(Qt6Core_DIR ${QT6_STATIC_BASE}Core) + set(Qt6Gui_DIR ${QT6_STATIC_BASE}Gui) + set(Qt6Widgets_DIR ${QT6_STATIC_BASE}Widgets) + set(Qt6OpenGL_DIR ${QT6_STATIC_BASE}OpenGL) + set(Qt6OpenGLWidgets_DIR ${QT6_STATIC_BASE}OpenGLWidgets) + endif() + find_package(Qt6 COMPONENTS Core Gui Widgets OpenGL OpenGLWidgets REQUIRED) + set(QT_LINK_LIBS Qt6::Core Qt6::Gui Qt6::Widgets Qt6::OpenGL Qt6::OpenGLWidgets) +else() + if (BUILD_STATIC AND QT5_STATIC_DIR) + set(QT5_STATIC_BASE ${QT5_STATIC_DIR}/lib/cmake/Qt5) + set(Qt5_DIR ${QT5_STATIC_BASE}) + set(Qt5Core_DIR ${QT5_STATIC_BASE}Core) + set(Qt5Gui_DIR ${QT5_STATIC_BASE}Gui) + set(Qt5Widgets_DIR ${QT5_STATIC_BASE}Widgets) + endif() + find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED) + set(QT_LINK_LIBS Qt5::Core Qt5::Gui Qt5::Widgets) endif() -find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED) - set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) @@ -87,7 +103,7 @@ endif() if (UNIX) option(PORTABLE "Make a portable build that looks for its configuration in the current directory" OFF) - target_link_libraries(melonDS Qt5::Core Qt5::Gui Qt5::Widgets) + target_link_libraries(melonDS ${QT_LINK_LIBS}) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") target_link_libraries(melonDS dl) endif() @@ -98,9 +114,9 @@ elseif (WIN32) target_link_libraries(melonDS comctl32 d2d1 dwrite uxtheme ws2_32 iphlpapi gdi32) if (BUILD_STATIC) - target_link_libraries(melonDS imm32 winmm version setupapi -static Qt5::Core Qt5::Gui Qt5::Widgets zstd) + target_link_libraries(melonDS imm32 winmm version setupapi -static z zstd ${QT_LINK_LIBS}) else() - target_link_libraries(melonDS Qt5::Core Qt5::Gui Qt5::Widgets) + target_link_libraries(melonDS ${QT_LINK_LIBS}) endif() endif() @@ -119,6 +135,13 @@ if (APPLE) target_sources(melonDS PRIVATE "${CMAKE_SOURCE_DIR}/melon.icns") set_source_files_properties("${CMAKE_SOURCE_DIR}/melon.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + # Qt 6 requires macOS 10.15 if building on 10.15 or greater + if(CMAKE_SYSTEM_VERSION VERSION_GREATER "10.14") + if (USE_QT6) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE) + endif() + endif() + option(MACOS_BUNDLE_LIBS "Bundle libraries with the app on macOS" OFF) option(MACOS_BUILD_DMG "Build DMG image of the macOS application bundle" OFF) diff --git a/src/frontend/qt_sdl/CheatsDialog.cpp b/src/frontend/qt_sdl/CheatsDialog.cpp index 8ba05d7..84e2a7b 100644 --- a/src/frontend/qt_sdl/CheatsDialog.cpp +++ b/src/frontend/qt_sdl/CheatsDialog.cpp @@ -17,6 +17,7 @@ */ #include <stdio.h> +#include <QtGlobal> #include <QFileDialog> #include <QMessageBox> @@ -319,7 +320,11 @@ void CheatsDialog::on_txtCode_textChanged() u32 codelen = 0; QString text = ui->txtCode->document()->toPlainText(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + QStringList lines = text.split('\n', Qt::SkipEmptyParts); +#else QStringList lines = text.split('\n', QString::SkipEmptyParts); +#endif for (QStringList::iterator it = lines.begin(); it != lines.end(); it++) { QString line = *it; diff --git a/src/frontend/qt_sdl/VideoSettingsDialog.cpp b/src/frontend/qt_sdl/VideoSettingsDialog.cpp index 68a281e..0ea6f15 100644 --- a/src/frontend/qt_sdl/VideoSettingsDialog.cpp +++ b/src/frontend/qt_sdl/VideoSettingsDialog.cpp @@ -47,7 +47,7 @@ VideoSettingsDialog::VideoSettingsDialog(QWidget* parent) : QDialog(parent), ui( grp3DRenderer = new QButtonGroup(this); grp3DRenderer->addButton(ui->rb3DSoftware, 0); grp3DRenderer->addButton(ui->rb3DOpenGL, 1); - connect(grp3DRenderer, SIGNAL(buttonClicked(int)), this, SLOT(onChange3DRenderer(int))); + connect(grp3DRenderer, SIGNAL(idClicked(int)), this, SLOT(onChange3DRenderer(int))); grp3DRenderer->button(Config::_3DRenderer)->setChecked(true); #ifndef OGLRENDERER_ENABLED |