From 97157eaf5cf51b05a268abb8755254b809487e49 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 19 Apr 2023 09:25:59 -0700 Subject: [PATCH 1/3] DolphinQt: use new style of addAction API --- Source/Core/DolphinQt/MenuBar.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index 07391cb65b..917935ec50 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -191,7 +191,11 @@ void MenuBar::OnDebugModeToggled(bool enabled) void MenuBar::AddFileMenu() { QMenu* file_menu = addMenu(tr("&File")); +#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) + m_open_action = file_menu->addAction(tr("&Open..."), QKeySequence::Open, this, &MenuBar::Open); +#else m_open_action = file_menu->addAction(tr("&Open..."), this, &MenuBar::Open, QKeySequence::Open); +#endif file_menu->addSeparator(); @@ -501,14 +505,23 @@ void MenuBar::AddViewMenu() connect(&Settings::Instance(), &Settings::GameListRefreshStarted, purge_action, [purge_action] { purge_action->setEnabled(true); }); view_menu->addSeparator(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) + view_menu->addAction(tr("Search"), QKeySequence::Find, this, &MenuBar::ShowSearch); +#else view_menu->addAction(tr("Search"), this, &MenuBar::ShowSearch, QKeySequence::Find); +#endif } void MenuBar::AddOptionsMenu() { QMenu* options_menu = addMenu(tr("&Options")); +#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) + options_menu->addAction(tr("Co&nfiguration"), QKeySequence::Preferences, this, + &MenuBar::Configure); +#else options_menu->addAction(tr("Co&nfiguration"), this, &MenuBar::Configure, QKeySequence::Preferences); +#endif options_menu->addSeparator(); options_menu->addAction(tr("&Graphics Settings"), this, &MenuBar::ConfigureGraphics); options_menu->addAction(tr("&Audio Settings"), this, &MenuBar::ConfigureAudio); From ce9413e5494b7025a2f73f54f7438a756fcecf82 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 19 Apr 2023 12:05:24 -0700 Subject: [PATCH 2/3] cmake: drop qt5 --- Source/Core/DolphinQt/CMakeLists.txt | 49 ++++++++-------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 1ef8c0cb64..8b3f72f580 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -13,16 +13,10 @@ endif() set(CMAKE_AUTOMOC ON) -# For some reason the method in Qt6 documentation is not working (at least on ubuntu jammy) -# When Qt5 and Qt6 are given in same NAMES entry, only Qt5 is ever found. -find_package(QT NAMES Qt6 COMPONENTS Core Gui Widgets) -if(NOT QT_DIR) - find_package(QT NAMES Qt5 COMPONENTS Core Gui Widgets) -endif() -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets) -message(STATUS "Found Qt version ${QT_VERSION}") +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) +message(STATUS "Found Qt version ${Qt6_VERSION}") -set_property(TARGET Qt${QT_VERSION_MAJOR}::Core PROPERTY INTERFACE_COMPILE_FEATURES "") +set_property(TARGET Qt6::Core PROPERTY INTERFACE_COMPILE_FEATURES "") add_executable(dolphin-emu AboutDialog.cpp @@ -374,13 +368,13 @@ PRIVATE target_include_directories(dolphin-emu PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ${Qt${QT_VERSION_MAJOR}Gui_PRIVATE_INCLUDE_DIRS} + ${Qt6Gui_PRIVATE_INCLUDE_DIRS} ) target_link_libraries(dolphin-emu PRIVATE core - Qt${QT_VERSION_MAJOR}::Widgets + Qt6::Widgets uicommon imgui implot @@ -408,14 +402,9 @@ if (MSVC) # Qt 6.3.0 headers use std::aligned_storage instead of alignas target_compile_definitions(dolphin-emu PRIVATE _SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING) - if ("${QT_VERSION_MAJOR}" GREATER_EQUAL 6) - # Qt6 requires RTTI - remove_cxx_flag_from_target(dolphin-emu "/GR-") - target_compile_options(dolphin-emu PRIVATE "/GR") - else() - # Add precompiled header - target_link_libraries(audiocommon PRIVATE use_pch) - endif() + # Qt6 requires RTTI + remove_cxx_flag_from_target(dolphin-emu "/GR-") + target_compile_options(dolphin-emu PRIVATE "/GR") endif() if(WIN32) @@ -448,17 +437,10 @@ if(WIN32) ) # Delegate to Qt's official deployment binary on Windows to copy over the necessary Qt-specific libraries, etc. - get_target_property(MOC_EXECUTABLE_LOCATION Qt${QT_VERSION_MAJOR}::moc IMPORTED_LOCATION) + get_target_property(MOC_EXECUTABLE_LOCATION Qt6::moc IMPORTED_LOCATION) get_filename_component(QT_BINARY_DIRECTORY "${MOC_EXECUTABLE_LOCATION}" DIRECTORY) find_program(WINDEPLOYQT_EXE windeployqt HINTS "${QT_BINARY_DIRECTORY}") - if ("${QT_VERSION_MAJOR}" LESS 6) - set(NO_ANGLE_PARAM "--no-angle") - else() - # parameter no longer exists in Qt6 - set(NO_ANGLE_PARAM "") - endif() - # Note: We set the PATH for the duration of this command so that the # deployment application is able to locate the Qt libraries to copy. # if the necessary paths aren't already set beforehand. @@ -481,7 +463,6 @@ if(WIN32) --no-translations --no-compiler-runtime --no-system-d3d-compiler - "${NO_ANGLE_PARAM}" --no-opengl-sw "$" ) @@ -560,18 +541,16 @@ if(APPLE) target_sources(dolphin-emu PRIVATE "${CMAKE_SOURCE_DIR}/Data/Dolphin.icns") set_source_files_properties("${CMAKE_SOURCE_DIR}/Data/Dolphin.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources) - # Plugins have to be manually included with Qt 6 - if (QT_VERSION_MAJOR EQUAL 6) - find_package(Qt6QMacStylePlugin REQUIRED PATHS ${Qt6Widgets_DIR}) - find_package(Qt6QCocoaIntegrationPlugin REQUIRED PATHS ${Qt6Gui_DIR}) - endif() + # Manually include plugins + find_package(Qt6QMacStylePlugin REQUIRED PATHS ${Qt6Widgets_DIR}) + find_package(Qt6QCocoaIntegrationPlugin REQUIRED PATHS ${Qt6Gui_DIR}) # Copy Qt plugins into the bundle - get_target_property(qtcocoa_location Qt${QT_VERSION_MAJOR}::QCocoaIntegrationPlugin LOCATION) + get_target_property(qtcocoa_location Qt6::QCocoaIntegrationPlugin LOCATION) target_sources(dolphin-emu PRIVATE "${qtcocoa_location}") set_source_files_properties("${qtcocoa_location}" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/platforms) - get_target_property(qtmacstyle_location Qt${QT_VERSION_MAJOR}::QMacStylePlugin LOCATION) + get_target_property(qtmacstyle_location Qt6::QMacStylePlugin LOCATION) target_sources(dolphin-emu PRIVATE "${qtmacstyle_location}") set_source_files_properties("${qtmacstyle_location}" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/styles) From 258cf0ff289edb7960cf78b35417fa9c5fa4ecf7 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Wed, 19 Apr 2023 12:48:20 -0700 Subject: [PATCH 3/3] DolphinQt: assume QT_VERSION_CHECK >= 6.0.0 --- .../Config/ToolTipControls/BalloonTip.cpp | 14 +------------- .../Config/ToolTipControls/ToolTipWidget.h | 4 ---- .../Core/DolphinQt/Debugger/MemoryViewWidget.cpp | 4 ---- Source/Core/DolphinQt/GBAWidget.cpp | 7 +------ 4 files changed, 2 insertions(+), 27 deletions(-) diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/BalloonTip.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/BalloonTip.cpp index 7f5516bbd2..ccec65c374 100644 --- a/Source/Core/DolphinQt/Config/ToolTipControls/BalloonTip.cpp +++ b/Source/Core/DolphinQt/Config/ToolTipControls/BalloonTip.cpp @@ -16,12 +16,7 @@ #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) #include -#else -#include -#include -#endif #if defined(__APPLE__) #include @@ -105,11 +100,7 @@ BalloonTip::BalloonTip(PrivateTag, const QIcon& icon, QString title, QString mes message_label->setTextFormat(Qt::RichText); message_label->setAlignment(Qt::AlignTop | Qt::AlignLeft); -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - const int limit = QApplication::desktop()->availableGeometry(message_label).width() / 3; -#else const int limit = message_label->screen()->availableGeometry().width() / 3; -#endif message_label->setMaximumWidth(limit); message_label->setSizePolicy(QSizePolicy::Policy::MinimumExpanding, QSizePolicy::Policy::MinimumExpanding); @@ -136,14 +127,11 @@ void BalloonTip::UpdateBoundsAndRedraw(const QPoint& pos, ShowArrow show_arrow) { m_show_arrow = show_arrow == ShowArrow::Yes; -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - const QRect screen_rect = QApplication::desktop()->screenGeometry(pos); -#else QScreen* screen = QGuiApplication::screenAt(pos); if (!screen) screen = QGuiApplication::primaryScreen(); const QRect screen_rect = screen->geometry(); -#endif + QSize sh = sizeHint(); // The look should resemble the default tooltip style set in Settings::SetCurrentUserStyle() const int border = 1; diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h index 6e3658e8bb..1f7c574345 100644 --- a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h @@ -22,11 +22,7 @@ public: void SetDescription(QString description) { m_description = std::move(description); } private: -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - void enterEvent(QEvent* event) override -#else void enterEvent(QEnterEvent* event) override -#endif { if (m_timer_id) return; diff --git a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp index 41b406536b..80a4cdd7f4 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp @@ -212,11 +212,7 @@ void MemoryViewWidget::UpdateFont() // BoundingRect is too unpredictable, a custom one would be needed for each view type. Different // fonts have wildly different spacing between two characters and horizontalAdvance includes // spacing. -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) m_font_width = fm.horizontalAdvance(QLatin1Char('0')); -#else - m_font_width = fm.width(QLatin1Char('0')); -#endif m_table->setFont(Settings::Instance().GetDebugFont()); CreateTable(); diff --git a/Source/Core/DolphinQt/GBAWidget.cpp b/Source/Core/DolphinQt/GBAWidget.cpp index eb868440e5..6805321df5 100644 --- a/Source/Core/DolphinQt/GBAWidget.cpp +++ b/Source/Core/DolphinQt/GBAWidget.cpp @@ -514,12 +514,7 @@ void GBAWidget::mouseMoveEvent(QMouseEvent* event) { if (!m_moving) return; - auto event_pos = -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - event->globalPosition().toPoint(); -#else - event->globalPos(); -#endif + auto event_pos = event->globalPosition().toPoint(); move(event_pos - m_move_pos - (geometry().topLeft() - pos())); }