diff --git a/CMakeLists.txt b/CMakeLists.txt index dc1472f15..f003bcb60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,6 +130,11 @@ cmake_dependent_option(VGAWONDER "ATI VGA Wonder (ATI-18800)" cmake_dependent_option(VNC "VNC renderer" OFF "DEV_BRANCH" OFF) cmake_dependent_option(XL24 "ATI VGA Wonder XL24 (ATI-28800-6)" ON "DEV_BRANCH" OFF) +# Ditto but for Qt +if (QT) + option(USE_QT6 "Use Qt6 instead of Qt5" OFF) +endif() + # Determine the build type set(RELEASE_BUILD OFF) set(BETA_BUILD OFF) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2a933454..765a714e6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -75,22 +75,31 @@ if(APPLE) # Force using the newest library if it's installed by homebrew set(CMAKE_FIND_FRAMEWORK LAST) - # setting our compilation target to macOS 10.13 High Sierra - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13") + # setting our compilation target to macOS 10.15 Catalina if targetting Qt6, macOS 10.13 High Sierra otherwise + if (USE_QT6) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15") + else() + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13") + endif() endif() if(QT) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) + if (USE_QT6) + set(QT_MAJOR 6) + else() + set(QT_MAJOR 5) + endif() # if we want to use qt5-static to eliminate need for bundling qt dlls (windows) #set(QT_STATIC ON) # needed to build with qt5-static if both qt5 and qt5-static are installed #set(CMAKE_PREFIX_PATH "path/to/qt5-static") - find_package(Qt5 COMPONENTS Core Widgets REQUIRED) - find_package(Qt5LinguistTools REQUIRED) + find_package(Qt${QT_MAJOR} COMPONENTS Core Widgets OpenGL REQUIRED) + find_package(Qt${QT_MAJOR}LinguistTools REQUIRED) endif() find_package(Freetype REQUIRED) @@ -178,7 +187,7 @@ if(APPLE) if (QT) # needed for Qt packaging # get the macdeployqt path - get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION) + get_target_property(_qmake_executable Qt${QT_MAJOR}::qmake IMPORTED_LOCATION) get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${_qt_bin_dir}") diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index edfc2b198..53dabe65b 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -125,22 +125,23 @@ endif() target_link_libraries( plat PRIVATE - Qt5::Widgets - Qt5::Gui + Qt${QT_MAJOR}::Widgets + Qt${QT_MAJOR}::Gui Threads::Threads ) target_link_libraries( ui PRIVATE - Qt5::Widgets - Qt5::Gui + Qt${QT_MAJOR}::Widgets + Qt${QT_MAJOR}::Gui + Qt${QT_MAJOR}::OpenGL Threads::Threads ) # needed for static builds if (WIN32) - qt_import_plugins(plat INCLUDE Qt5::QWindowsIntegrationPlugin Qt5::QICOPlugin QWindowsVistaStylePlugin) + qt_import_plugins(plat INCLUDE Qt${QT_MAJOR}::QWindowsIntegrationPlugin Qt${QT_MAJOR}::QICOPlugin QWindowsVistaStylePlugin) endif() if (UNIX AND NOT APPLE) @@ -165,13 +166,13 @@ if (UNIX AND NOT APPLE) set(WL_SOURCE_VAR) ecm_add_wayland_client_protocol(WL_SOURCE_VAR PROTOCOL ${CMAKE_SOURCE_DIR}/wl_protocols/relative-pointer-unstable-v1.xml BASENAME relative-pointer-unstable-v1) ecm_add_wayland_client_protocol(WL_SOURCE_VAR PROTOCOL ${CMAKE_SOURCE_DIR}/wl_protocols/pointer-constraints-unstable-v1.xml BASENAME pointer-constraints-unstable-v1) - target_include_directories(ui PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${Qt5Gui_PRIVATE_INCLUDE_DIRS}) + target_include_directories(ui PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${Qt${QT_MAJOR}Gui_PRIVATE_INCLUDE_DIRS}) target_sources(ui PRIVATE ${WL_SOURCE_VAR} wl_mouse.cpp) target_compile_definitions(ui PRIVATE WAYLAND) endif() endif() endif() endif() -qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} 86box_en.ts 86box_en-GB.ts 86box_de.ts 86box_es.ts 86box_fi.ts 86box_fr.ts 86box_hr.ts 86box_hu.ts 86box_it.ts 86box_ja.ts 86box_ko.ts 86box_pt-BR.ts 86box_pt-PT.ts 86box_ru.ts 86box_sl.ts 86box_tr.ts 86box_zh.ts) +qt_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} 86box_en.ts 86box_en-GB.ts 86box_de.ts 86box_es.ts 86box_fi.ts 86box_fr.ts 86box_hr.ts 86box_hu.ts 86box_it.ts 86box_ja.ts 86box_ko.ts 86box_pt-BR.ts 86box_pt-PT.ts 86box_ru.ts 86box_sl.ts 86box_tr.ts 86box_zh.ts) configure_file(qt_translations.qrc ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) target_sources(ui PRIVATE ${QM_FILES} ${CMAKE_CURRENT_BINARY_DIR}/qt_translations.qrc) diff --git a/src/qt/cocoa_mouse.hpp b/src/qt/cocoa_mouse.hpp index 6d481fd89..8db79d9e8 100644 --- a/src/qt/cocoa_mouse.hpp +++ b/src/qt/cocoa_mouse.hpp @@ -1,10 +1,16 @@ #include #include +#if QT_VERSION_MAJOR >= 6 +#define result_t qintptr +#else +#define result_t long +#endif + class CocoaEventFilter : public QAbstractNativeEventFilter { public: CocoaEventFilter() {}; ~CocoaEventFilter(); - virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; + virtual bool nativeEventFilter(const QByteArray &eventType, void *message, result_t *result) override; }; diff --git a/src/qt/macos_event_filter.mm b/src/qt/macos_event_filter.mm index a3200aa8e..0ea799f99 100644 --- a/src/qt/macos_event_filter.mm +++ b/src/qt/macos_event_filter.mm @@ -31,7 +31,7 @@ CocoaEventFilter::~CocoaEventFilter() } -bool CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result) +bool CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, result_t *result) { if (mouse_capture) { diff --git a/src/qt/qt_hardwarerenderer.hpp b/src/qt/qt_hardwarerenderer.hpp index 4fb132da6..2a453ab49 100644 --- a/src/qt/qt_hardwarerenderer.hpp +++ b/src/qt/qt_hardwarerenderer.hpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -12,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 227029a91..d19f7fd7e 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -337,6 +337,7 @@ void MainWindow::showEvent(QShowEvent *event) { scrnsz_x = window_w; scrnsz_y = window_h; } + if (settings_only) QTimer::singleShot(0, this, [this] () { ui->actionSettings->trigger(); }); } void MainWindow::on_actionKeyboard_requires_capture_triggered() { @@ -1060,8 +1061,7 @@ void MainWindow::on_actionHardware_Renderer_OpenGL_ES_triggered() { void MainWindow::focusInEvent(QFocusEvent* event) { - if (settings_only) ui->actionSettings->trigger(); - else this->grabKeyboard(); + this->grabKeyboard(); } void MainWindow::focusOutEvent(QFocusEvent* event) diff --git a/src/qt/qt_platform.cpp b/src/qt/qt_platform.cpp index f94b13e86..70fbc1517 100644 --- a/src/qt/qt_platform.cpp +++ b/src/qt/qt_platform.cpp @@ -108,7 +108,7 @@ void plat_get_exe_name(char *s, int size) { QByteArray exepath_temp = QCoreApplication::applicationDirPath().toLocal8Bit(); - memcpy(s, exepath_temp.data(), std::min(exepath_temp.size(),size)); + memcpy(s, exepath_temp.data(), std::min((qsizetype)exepath_temp.size(),(qsizetype)size)); plat_path_slash(s); } diff --git a/src/qt/qt_renderercomon.hpp b/src/qt/qt_renderercomon.hpp index cf05a7321..063d6f1bc 100644 --- a/src/qt/qt_renderercomon.hpp +++ b/src/qt/qt_renderercomon.hpp @@ -2,6 +2,7 @@ #include #include +#include class QWidget; diff --git a/src/qt/qt_winrawinputfilter.hpp b/src/qt/qt_winrawinputfilter.hpp index 167b14912..7a73a2eca 100644 --- a/src/qt/qt_winrawinputfilter.hpp +++ b/src/qt/qt_winrawinputfilter.hpp @@ -40,6 +40,13 @@ #include +#if QT_VERSION_MAJOR >= 6 +#define result_t qintptr +#else +#define result_t long +#endif + + class WindowsRawInputFilter : public QObject, public QAbstractNativeEventFilter { Q_OBJECT @@ -47,7 +54,7 @@ class WindowsRawInputFilter : public QObject, public QAbstractNativeEventFilter public: static std::unique_ptr Register(QMainWindow *window); - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; + bool nativeEventFilter(const QByteArray &eventType, void *message, result_t *result) override; ~WindowsRawInputFilter(); @@ -72,4 +79,4 @@ private: void keyboard_getkeymap(); }; -#endif \ No newline at end of file +#endif