From f647ca46203cb86a92d3e70b0814b479aa4175e3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 13 Jan 2021 03:50:39 -0500 Subject: [PATCH 1/5] DolphinQt: Replace usages of QLatin1Literal with QStringLiteral This literal was deprecated in 5.14.0. Not to mention it wasn't documented as part of the API either: see the 5.14.0 changelog here: https://code.qt.io/cgit/qt/qtbase.git/tree/dist/changes-5.14.0?h=v5.14.0 On Qt 6.0 this define is removed entirely. To stay forward compatible, we can make use of QStringLiteral instead. --- .../Core/DolphinQt/Debugger/NetworkWidget.cpp | 8 +++---- .../Core/DolphinQt/Debugger/ThreadWidget.cpp | 24 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Source/Core/DolphinQt/Debugger/NetworkWidget.cpp b/Source/Core/DolphinQt/Debugger/NetworkWidget.cpp index 86af6b743f..6bf992335b 100644 --- a/Source/Core/DolphinQt/Debugger/NetworkWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/NetworkWidget.cpp @@ -40,9 +40,9 @@ QTableWidgetItem* GetSocketDomain(s32 host_fd) switch (sa.sa_family) { case 2: - return new QTableWidgetItem(QLatin1Literal("AF_INET")); + return new QTableWidgetItem(QStringLiteral("AF_INET")); case 23: - return new QTableWidgetItem(QLatin1Literal("AF_INET6")); + return new QTableWidgetItem(QStringLiteral("AF_INET6")); default: return new QTableWidgetItem(QString::number(sa.sa_family)); } @@ -63,9 +63,9 @@ QTableWidgetItem* GetSocketType(s32 host_fd) switch (so_type) { case 1: - return new QTableWidgetItem(QLatin1Literal("SOCK_STREAM")); + return new QTableWidgetItem(QStringLiteral("SOCK_STREAM")); case 2: - return new QTableWidgetItem(QLatin1Literal("SOCK_DGRAM")); + return new QTableWidgetItem(QStringLiteral("SOCK_DGRAM")); default: return new QTableWidgetItem(QString::number(so_type)); } diff --git a/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp b/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp index bf288f8b02..9d70a927ad 100644 --- a/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp @@ -131,10 +131,10 @@ void ThreadWidget::ShowContextMenu(QTableWidget* table) QLineEdit* ThreadWidget::CreateLineEdit() const { - QLineEdit* line_edit = new QLineEdit(QLatin1Literal("00000000")); + QLineEdit* line_edit = new QLineEdit(QStringLiteral("00000000")); line_edit->setReadOnly(true); line_edit->setFixedWidth( - line_edit->fontMetrics().boundingRect(QLatin1Literal(" 00000000 ")).width()); + line_edit->fontMetrics().boundingRect(QStringLiteral(" 00000000 ")).width()); return line_edit; } @@ -374,39 +374,39 @@ void ThreadWidget::UpdateThreadContext(const Common::Debug::PartialContext& cont switch (i) { case 8: - m_context_table->setItem(i, 6, new QTableWidgetItem(QLatin1Literal("CR"))); + m_context_table->setItem(i, 6, new QTableWidgetItem(QStringLiteral("CR"))); m_context_table->setItem(i, 7, new QTableWidgetItem(format_hex(context.cr))); break; case 9: - m_context_table->setItem(i, 6, new QTableWidgetItem(QLatin1Literal("LR"))); + m_context_table->setItem(i, 6, new QTableWidgetItem(QStringLiteral("LR"))); m_context_table->setItem(i, 7, new QTableWidgetItem(format_hex(context.lr))); break; case 10: - m_context_table->setItem(i, 6, new QTableWidgetItem(QLatin1Literal("CTR"))); + m_context_table->setItem(i, 6, new QTableWidgetItem(QStringLiteral("CTR"))); m_context_table->setItem(i, 7, new QTableWidgetItem(format_hex(context.ctr))); break; case 11: - m_context_table->setItem(i, 6, new QTableWidgetItem(QLatin1Literal("XER"))); + m_context_table->setItem(i, 6, new QTableWidgetItem(QStringLiteral("XER"))); m_context_table->setItem(i, 7, new QTableWidgetItem(format_hex(context.xer))); break; case 12: - m_context_table->setItem(i, 6, new QTableWidgetItem(QLatin1Literal("FPSCR"))); + m_context_table->setItem(i, 6, new QTableWidgetItem(QStringLiteral("FPSCR"))); m_context_table->setItem(i, 7, new QTableWidgetItem(format_hex(context.fpscr))); break; case 13: - m_context_table->setItem(i, 6, new QTableWidgetItem(QLatin1Literal("SRR0"))); + m_context_table->setItem(i, 6, new QTableWidgetItem(QStringLiteral("SRR0"))); m_context_table->setItem(i, 7, new QTableWidgetItem(format_hex(context.srr0))); break; case 14: - m_context_table->setItem(i, 6, new QTableWidgetItem(QLatin1Literal("SRR1"))); + m_context_table->setItem(i, 6, new QTableWidgetItem(QStringLiteral("SRR1"))); m_context_table->setItem(i, 7, new QTableWidgetItem(format_hex(context.srr1))); break; case 15: - m_context_table->setItem(i, 6, new QTableWidgetItem(QLatin1Literal("DUMMY"))); + m_context_table->setItem(i, 6, new QTableWidgetItem(QStringLiteral("DUMMY"))); m_context_table->setItem(i, 7, new QTableWidgetItem(format_hex(context.dummy))); break; case 16: - m_context_table->setItem(i, 6, new QTableWidgetItem(QLatin1Literal("STATE"))); + m_context_table->setItem(i, 6, new QTableWidgetItem(QStringLiteral("STATE"))); m_context_table->setItem(i, 7, new QTableWidgetItem(format_hex(context.state))); break; default: @@ -454,7 +454,7 @@ void ThreadWidget::UpdateThreadCallstack(const Common::Debug::PartialContext& co } else { - m_callstack_table->setItem(i, 2, new QTableWidgetItem(QLatin1Literal("--------"))); + m_callstack_table->setItem(i, 2, new QTableWidgetItem(QStringLiteral("--------"))); } sp = PowerPC::HostRead_U32(sp); m_callstack_table->setItem(i, 1, new QTableWidgetItem(format_hex(sp))); From 765a1b3c094963e6ff7e6688eb41eb0a0727b9d2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 13 Jan 2021 03:55:52 -0500 Subject: [PATCH 2/5] DolphinQt: Explicitly include where applicable An indirect inclusion scenario that breaks on Qt 6.0 --- Source/Core/DolphinQt/Debugger/RegisterWidget.cpp | 1 + Source/Core/DolphinQt/MenuBar.cpp | 1 + Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp b/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp index d41d938cc3..2cda7fc1e2 100644 --- a/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp @@ -6,6 +6,7 @@ #include +#include #include #include #include diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index b1f6d40169..c5f9f6761b 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include diff --git a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp index c8b19678b3..9b05c37e26 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp +++ b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp @@ -5,6 +5,7 @@ #include "DolphinQt/NetPlay/NetPlayDialog.h" #include +#include #include #include #include From 46ca371ef3b6cfa8e31dcae2f9298a91b1fdc31e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 13 Jan 2021 04:06:05 -0500 Subject: [PATCH 3/5] DolphinQt: Migrate QRegExp over to QRegularExpression Qt 5.0 introduced QRegularExpression to replace QRegExp. In Qt 6.0, QRegExp is removed entirely in favor of it. --- Source/Core/DolphinQt/Config/GameConfigEdit.cpp | 7 ++++--- .../Core/DolphinQt/Config/Mapping/MappingCommon.cpp | 6 +++--- Source/Core/DolphinQt/GameList/GameListModel.cpp | 13 +++++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Source/Core/DolphinQt/Config/GameConfigEdit.cpp b/Source/Core/DolphinQt/Config/GameConfigEdit.cpp index b4ca822d1d..396d466657 100644 --- a/Source/Core/DolphinQt/Config/GameConfigEdit.cpp +++ b/Source/Core/DolphinQt/Config/GameConfigEdit.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -161,7 +162,7 @@ void GameConfigEdit::AddBoolOption(QMenu* menu, const QString& name, const QStri void GameConfigEdit::SetOption(const QString& section, const QString& key, const QString& value) { auto section_cursor = - m_edit->document()->find(QRegExp(QStringLiteral("^\\[%1\\]").arg(section)), 0); + m_edit->document()->find(QRegularExpression(QStringLiteral("^\\[%1\\]").arg(section)), 0); // Check if the section this belongs in can be found if (section_cursor.isNull()) @@ -170,8 +171,8 @@ void GameConfigEdit::SetOption(const QString& section, const QString& key, const } else { - auto value_cursor = - m_edit->document()->find(QRegExp(QStringLiteral("^%1 = .*").arg(key)), section_cursor); + auto value_cursor = m_edit->document()->find( + QRegularExpression(QStringLiteral("^%1 = .*").arg(key)), section_cursor); const QString new_line = QStringLiteral("%1 = %2").arg(key).arg(value); diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp index eb61963300..3678cceb89 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingCommon.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -51,8 +51,8 @@ QString GetExpressionForControl(const QString& control_name, if (quote == Quote::On) { - QRegExp reg(QStringLiteral("[a-zA-Z]+")); - if (!reg.exactMatch(expr)) + const QRegularExpression reg(QStringLiteral("[a-zA-Z]+")); + if (!reg.match(expr).hasMatch()) expr = QStringLiteral("`%1`").arg(expr); } diff --git a/Source/Core/DolphinQt/GameList/GameListModel.cpp b/Source/Core/DolphinQt/GameList/GameListModel.cpp index d470bf3b37..ee3031fb47 100644 --- a/Source/Core/DolphinQt/GameList/GameListModel.cpp +++ b/Source/Core/DolphinQt/GameList/GameListModel.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "Core/ConfigManager.h" @@ -96,7 +97,8 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const const int disc_nr = game.GetDiscNumber() + 1; if (disc_nr > 1) { - if (!name.contains(QRegExp(QStringLiteral("disc ?%1").arg(disc_nr), Qt::CaseInsensitive))) + if (!name.contains(QRegularExpression(QStringLiteral("disc ?%1").arg(disc_nr), + QRegularExpression::CaseInsensitiveOption))) { name.append(tr(" (Disc %1)").arg(disc_nr)); } @@ -107,11 +109,14 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const { constexpr int MAX_NUMBER_LENGTH = 10; - QRegExp rx(QStringLiteral("\\d+")); + const QRegularExpression rx(QStringLiteral("\\d+")); + QRegularExpressionMatch match; int pos = 0; - while ((pos = rx.indexIn(name, pos)) != -1) + while ((match = rx.match(name, pos)).hasMatch()) { - name.replace(pos, rx.matchedLength(), rx.cap().rightJustified(MAX_NUMBER_LENGTH)); + pos = match.capturedStart(); + name.replace(pos, match.capturedLength(), + match.captured().rightJustified(MAX_NUMBER_LENGTH)); pos += MAX_NUMBER_LENGTH; } } From 892154f7eadfa1d7807b8d07c3a864b7d1aba127 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 13 Jan 2021 04:33:01 -0500 Subject: [PATCH 4/5] DolphinQt: Resolve deprecated usage of margin() This function has been marked as obsolete. In Qt 6.0 it's removed entirely, so we must use getContentsMargin() explicitly instead (margin() would do this for us). Ditto for setMargin(), in which case we use setContentsMargin instead. setMargin() would just pass its argument to all four parameters of setContentsMargin(), so we can do the same. --- Source/Core/DolphinQt/MainWindow.cpp | 2 +- Source/Core/DolphinQt/QtUtils/FlowLayout.cpp | 6 +++++- Source/Core/DolphinQt/QtUtils/WrapInScrollArea.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 8bd3988f45..20572d88b2 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -654,7 +654,7 @@ void MainWindow::ConnectStack() layout->addWidget(m_game_list); layout->addWidget(m_search_bar); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); connect(m_search_bar, &SearchBar::Search, m_game_list, &GameList::SetSearchTerm); diff --git a/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp b/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp index bd481ea624..e986f2f382 100644 --- a/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp +++ b/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp @@ -151,7 +151,11 @@ QSize FlowLayout::minimumSize() const for (const auto& item : m_item_list) size = size.expandedTo(item->minimumSize()); - size += QSize(2 * margin(), 2 * margin()); + // Any direction's margin works, as they all set the same within the constructor. + int margin = 0; + getContentsMargins(&margin, nullptr, nullptr, nullptr); + + size += QSize(2 * margin, 2 * margin); return size; } diff --git a/Source/Core/DolphinQt/QtUtils/WrapInScrollArea.cpp b/Source/Core/DolphinQt/QtUtils/WrapInScrollArea.cpp index 11758dd47a..20810fcec3 100644 --- a/Source/Core/DolphinQt/QtUtils/WrapInScrollArea.cpp +++ b/Source/Core/DolphinQt/QtUtils/WrapInScrollArea.cpp @@ -48,7 +48,7 @@ void WrapInScrollArea(QWidget* parent, QLayout* wrapped_layout, QWidget* to_resi auto* scroll_layout = new QVBoxLayout; scroll_layout->addWidget(scroll_area); - scroll_layout->setMargin(0); + scroll_layout->setContentsMargins(0, 0, 0, 0); parent->setLayout(scroll_layout); } From 5b4fced2ba3513fae23e7c23d01ed475bd6c0620 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 13 Jan 2021 04:41:52 -0500 Subject: [PATCH 5/5] DolphinQt: Resolve deprecated usages of setTime_t and toTime_t These have been replaced with setSecsSinceEpoch() and toSecsSinceEpoch(), respectively within Qt 5.8, so we can migrate over to them. --- Source/Core/DolphinQt/Settings/AdvancedPane.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinQt/Settings/AdvancedPane.cpp b/Source/Core/DolphinQt/Settings/AdvancedPane.cpp index 9a7da926e2..3e203950c5 100644 --- a/Source/Core/DolphinQt/Settings/AdvancedPane.cpp +++ b/Source/Core/DolphinQt/Settings/AdvancedPane.cpp @@ -221,10 +221,10 @@ void AdvancedPane::ConnectLayout() }); QDateTime initial_date_time; - initial_date_time.setTime_t(SConfig::GetInstance().m_customRTCValue); + initial_date_time.setSecsSinceEpoch(SConfig::GetInstance().m_customRTCValue); m_custom_rtc_datetime->setDateTime(initial_date_time); connect(m_custom_rtc_datetime, &QDateTimeEdit::dateTimeChanged, [this](QDateTime date_time) { - SConfig::GetInstance().m_customRTCValue = date_time.toTime_t(); + SConfig::GetInstance().m_customRTCValue = static_cast(date_time.toSecsSinceEpoch()); Update(); }); }