From 48c4ebeee02c8c028e13925a0c020355dbb44e89 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Fri, 25 Mar 2022 09:33:17 +0100 Subject: [PATCH 1/3] DolphinQt/CheatSearchWidget: Remember state of Hex checkboxes across sessions. --- Source/Core/DolphinQt/CheatSearchWidget.cpp | 24 +++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinQt/CheatSearchWidget.cpp b/Source/Core/DolphinQt/CheatSearchWidget.cpp index 07409c6ad5..ccbd90f131 100644 --- a/Source/Core/DolphinQt/CheatSearchWidget.cpp +++ b/Source/Core/DolphinQt/CheatSearchWidget.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,7 @@ #include "DolphinQt/Config/CheatCodeEditor.h" #include "DolphinQt/Config/CheatWarningWidget.h" +#include "DolphinQt/Settings.h" #include "UICommon/GameFile.h" @@ -61,7 +63,17 @@ CheatSearchWidget::CheatSearchWidget(std::unique_ptrisChecked()); + if (m_session->IsIntegerType()) + { + settings.setValue(QStringLiteral("cheatsearchwidget/parsehex"), + m_parse_values_as_hex_checkbox->isChecked()); + } +} Q_DECLARE_METATYPE(Cheats::CompareType); Q_DECLARE_METATYPE(Cheats::FilterType); @@ -193,8 +205,14 @@ void CheatSearchWidget::CreateWidgets() m_given_value_text = new QLineEdit(); value_layout->addWidget(m_given_value_text); + auto& settings = Settings::GetQSettings(); m_parse_values_as_hex_checkbox = new QCheckBox(tr("Parse as Hex")); - value_layout->addWidget(m_parse_values_as_hex_checkbox); + if (m_session->IsIntegerType()) + { + m_parse_values_as_hex_checkbox->setChecked( + settings.value(QStringLiteral("cheatsearchwidget/parsehex")).toBool()); + value_layout->addWidget(m_parse_values_as_hex_checkbox); + } auto* button_layout = new QHBoxLayout(); m_next_scan_button = new QPushButton(tr("Search and Filter")); @@ -211,6 +229,8 @@ void CheatSearchWidget::CreateWidgets() m_info_label_2 = new QLabel(); m_display_values_in_hex_checkbox = new QCheckBox(tr("Display values in Hex")); + m_display_values_in_hex_checkbox->setChecked( + settings.value(QStringLiteral("cheatsearchwidget/displayhex")).toBool()); QVBoxLayout* layout = new QVBoxLayout(); layout->addWidget(session_info_label); From 7f2fed0f68b23e7a9ce5c8c2f99999325956fb47 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Fri, 25 Mar 2022 09:40:24 +0100 Subject: [PATCH 2/3] DolphinQt/CheatsManager: Don't leak closed cheat search tabs. --- Source/Core/DolphinQt/CheatsManager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt/CheatsManager.cpp b/Source/Core/DolphinQt/CheatsManager.cpp index 44620378f9..babea143ee 100644 --- a/Source/Core/DolphinQt/CheatsManager.cpp +++ b/Source/Core/DolphinQt/CheatsManager.cpp @@ -127,7 +127,9 @@ void CheatsManager::OnNewSessionCreated(const Cheats::CheatSearchSessionBase& se void CheatsManager::OnTabCloseRequested(int index) { - m_tab_widget->removeTab(index); + auto* w = m_tab_widget->widget(index); + if (w) + w->deleteLater(); } void CheatsManager::ConnectWidgets() From 1942629d9aa21729b0adf71ed65cab57a62b89a2 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Fri, 25 Mar 2022 09:48:16 +0100 Subject: [PATCH 3/3] DolphinQt/CheatSearchWidget: Drop whitespace when parsing integers and floats from the user. --- Source/Core/DolphinQt/CheatSearchWidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt/CheatSearchWidget.cpp b/Source/Core/DolphinQt/CheatSearchWidget.cpp index ccbd90f131..e07a5c4ecb 100644 --- a/Source/Core/DolphinQt/CheatSearchWidget.cpp +++ b/Source/Core/DolphinQt/CheatSearchWidget.cpp @@ -276,7 +276,10 @@ void CheatSearchWidget::OnNextScanClicked() m_session->SetCompareType(m_compare_type_dropdown->currentData().value()); if (filter_type == Cheats::FilterType::CompareAgainstSpecificValue) { - if (!m_session->SetValueFromString(m_given_value_text->text().toStdString(), + QString search_value = m_given_value_text->text(); + if (m_session->IsIntegerType() || m_session->IsFloatingType()) + search_value = search_value.simplified().remove(QLatin1Char(' ')); + if (!m_session->SetValueFromString(search_value.toStdString(), m_parse_values_as_hex_checkbox->isChecked())) { m_info_label_1->setText(tr("Failed to parse given value into target data type."));