Merge pull request #11775 from shuffle2/qtnext2

qt: raise min version to 6
This commit is contained in:
Mai 2023-04-25 15:23:32 -04:00 committed by GitHub
commit 71a56d9e04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 62 deletions

View File

@ -13,16 +13,10 @@ endif()
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
# For some reason the method in Qt6 documentation is not working (at least on ubuntu jammy) find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
# When Qt5 and Qt6 are given in same NAMES entry, only Qt5 is ever found. message(STATUS "Found Qt version ${Qt6_VERSION}")
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}")
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 add_executable(dolphin-emu
AboutDialog.cpp AboutDialog.cpp
@ -374,13 +368,13 @@ PRIVATE
target_include_directories(dolphin-emu target_include_directories(dolphin-emu
PRIVATE PRIVATE
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${Qt${QT_VERSION_MAJOR}Gui_PRIVATE_INCLUDE_DIRS} ${Qt6Gui_PRIVATE_INCLUDE_DIRS}
) )
target_link_libraries(dolphin-emu target_link_libraries(dolphin-emu
PRIVATE PRIVATE
core core
Qt${QT_VERSION_MAJOR}::Widgets Qt6::Widgets
uicommon uicommon
imgui imgui
implot implot
@ -408,14 +402,9 @@ if (MSVC)
# Qt 6.3.0 headers use std::aligned_storage instead of alignas # Qt 6.3.0 headers use std::aligned_storage instead of alignas
target_compile_definitions(dolphin-emu PRIVATE _SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING) target_compile_definitions(dolphin-emu PRIVATE _SILENCE_CXX23_ALIGNED_STORAGE_DEPRECATION_WARNING)
if ("${QT_VERSION_MAJOR}" GREATER_EQUAL 6)
# Qt6 requires RTTI # Qt6 requires RTTI
remove_cxx_flag_from_target(dolphin-emu "/GR-") remove_cxx_flag_from_target(dolphin-emu "/GR-")
target_compile_options(dolphin-emu PRIVATE "/GR") target_compile_options(dolphin-emu PRIVATE "/GR")
else()
# Add precompiled header
target_link_libraries(audiocommon PRIVATE use_pch)
endif()
endif() endif()
if(WIN32) 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. # 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) get_filename_component(QT_BINARY_DIRECTORY "${MOC_EXECUTABLE_LOCATION}" DIRECTORY)
find_program(WINDEPLOYQT_EXE windeployqt HINTS "${QT_BINARY_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 # 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. # deployment application is able to locate the Qt libraries to copy.
# if the necessary paths aren't already set beforehand. # if the necessary paths aren't already set beforehand.
@ -481,7 +463,6 @@ if(WIN32)
--no-translations --no-translations
--no-compiler-runtime --no-compiler-runtime
--no-system-d3d-compiler --no-system-d3d-compiler
"${NO_ANGLE_PARAM}"
--no-opengl-sw --no-opengl-sw
"$<TARGET_FILE:dolphin-emu>" "$<TARGET_FILE:dolphin-emu>"
) )
@ -560,18 +541,16 @@ if(APPLE)
target_sources(dolphin-emu PRIVATE "${CMAKE_SOURCE_DIR}/Data/Dolphin.icns") 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) set_source_files_properties("${CMAKE_SOURCE_DIR}/Data/Dolphin.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
# Plugins have to be manually included with Qt 6 # Manually include plugins
if (QT_VERSION_MAJOR EQUAL 6)
find_package(Qt6QMacStylePlugin REQUIRED PATHS ${Qt6Widgets_DIR}) find_package(Qt6QMacStylePlugin REQUIRED PATHS ${Qt6Widgets_DIR})
find_package(Qt6QCocoaIntegrationPlugin REQUIRED PATHS ${Qt6Gui_DIR}) find_package(Qt6QCocoaIntegrationPlugin REQUIRED PATHS ${Qt6Gui_DIR})
endif()
# Copy Qt plugins into the bundle # 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}") target_sources(dolphin-emu PRIVATE "${qtcocoa_location}")
set_source_files_properties("${qtcocoa_location}" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/platforms) 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}") target_sources(dolphin-emu PRIVATE "${qtmacstyle_location}")
set_source_files_properties("${qtmacstyle_location}" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/styles) set_source_files_properties("${qtmacstyle_location}" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/styles)

View File

@ -16,12 +16,7 @@
#include <QPushButton> #include <QPushButton>
#include <QStyle> #include <QStyle>
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
#include <QScreen> #include <QScreen>
#else
#include <QApplication>
#include <QDesktopWidget>
#endif
#if defined(__APPLE__) #if defined(__APPLE__)
#include <QToolTip> #include <QToolTip>
@ -105,11 +100,7 @@ BalloonTip::BalloonTip(PrivateTag, const QIcon& icon, QString title, QString mes
message_label->setTextFormat(Qt::RichText); message_label->setTextFormat(Qt::RichText);
message_label->setAlignment(Qt::AlignTop | Qt::AlignLeft); 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; const int limit = message_label->screen()->availableGeometry().width() / 3;
#endif
message_label->setMaximumWidth(limit); message_label->setMaximumWidth(limit);
message_label->setSizePolicy(QSizePolicy::Policy::MinimumExpanding, message_label->setSizePolicy(QSizePolicy::Policy::MinimumExpanding,
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; 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); QScreen* screen = QGuiApplication::screenAt(pos);
if (!screen) if (!screen)
screen = QGuiApplication::primaryScreen(); screen = QGuiApplication::primaryScreen();
const QRect screen_rect = screen->geometry(); const QRect screen_rect = screen->geometry();
#endif
QSize sh = sizeHint(); QSize sh = sizeHint();
// The look should resemble the default tooltip style set in Settings::SetCurrentUserStyle() // The look should resemble the default tooltip style set in Settings::SetCurrentUserStyle()
const int border = 1; const int border = 1;

View File

@ -22,11 +22,7 @@ public:
void SetDescription(QString description) { m_description = std::move(description); } void SetDescription(QString description) { m_description = std::move(description); }
private: private:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEvent* event) override
#else
void enterEvent(QEnterEvent* event) override void enterEvent(QEnterEvent* event) override
#endif
{ {
if (m_timer_id) if (m_timer_id)
return; return;

View File

@ -212,11 +212,7 @@ void MemoryViewWidget::UpdateFont()
// BoundingRect is too unpredictable, a custom one would be needed for each view type. Different // 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 // fonts have wildly different spacing between two characters and horizontalAdvance includes
// spacing. // spacing.
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
m_font_width = fm.horizontalAdvance(QLatin1Char('0')); m_font_width = fm.horizontalAdvance(QLatin1Char('0'));
#else
m_font_width = fm.width(QLatin1Char('0'));
#endif
m_table->setFont(Settings::Instance().GetDebugFont()); m_table->setFont(Settings::Instance().GetDebugFont());
CreateTable(); CreateTable();

View File

@ -514,12 +514,7 @@ void GBAWidget::mouseMoveEvent(QMouseEvent* event)
{ {
if (!m_moving) if (!m_moving)
return; return;
auto event_pos = auto event_pos = event->globalPosition().toPoint();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
event->globalPosition().toPoint();
#else
event->globalPos();
#endif
move(event_pos - m_move_pos - (geometry().topLeft() - pos())); move(event_pos - m_move_pos - (geometry().topLeft() - pos()));
} }

View File

@ -191,7 +191,11 @@ void MenuBar::OnDebugModeToggled(bool enabled)
void MenuBar::AddFileMenu() void MenuBar::AddFileMenu()
{ {
QMenu* file_menu = addMenu(tr("&File")); 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); m_open_action = file_menu->addAction(tr("&Open..."), this, &MenuBar::Open, QKeySequence::Open);
#endif
file_menu->addSeparator(); file_menu->addSeparator();
@ -501,14 +505,23 @@ void MenuBar::AddViewMenu()
connect(&Settings::Instance(), &Settings::GameListRefreshStarted, purge_action, connect(&Settings::Instance(), &Settings::GameListRefreshStarted, purge_action,
[purge_action] { purge_action->setEnabled(true); }); [purge_action] { purge_action->setEnabled(true); });
view_menu->addSeparator(); 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); view_menu->addAction(tr("Search"), this, &MenuBar::ShowSearch, QKeySequence::Find);
#endif
} }
void MenuBar::AddOptionsMenu() void MenuBar::AddOptionsMenu()
{ {
QMenu* options_menu = addMenu(tr("&Options")); 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, options_menu->addAction(tr("Co&nfiguration"), this, &MenuBar::Configure,
QKeySequence::Preferences); QKeySequence::Preferences);
#endif
options_menu->addSeparator(); options_menu->addSeparator();
options_menu->addAction(tr("&Graphics Settings"), this, &MenuBar::ConfigureGraphics); options_menu->addAction(tr("&Graphics Settings"), this, &MenuBar::ConfigureGraphics);
options_menu->addAction(tr("&Audio Settings"), this, &MenuBar::ConfigureAudio); options_menu->addAction(tr("&Audio Settings"), this, &MenuBar::ConfigureAudio);