DolphinQt/CheatSearchWidget: Remember state of Hex checkboxes across sessions.

This commit is contained in:
Admiral H. Curtiss 2022-03-25 09:33:17 +01:00
parent 4957b2edb9
commit 48c4ebeee0
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB

View File

@ -19,6 +19,7 @@
#include <QLineEdit>
#include <QMenu>
#include <QPushButton>
#include <QSettings>
#include <QSignalBlocker>
#include <QString>
#include <QTableWidget>
@ -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_ptr<Cheats::CheatSearchSessionB
UpdateGuiTable();
}
CheatSearchWidget::~CheatSearchWidget() = default;
CheatSearchWidget::~CheatSearchWidget()
{
auto& settings = Settings::GetQSettings();
settings.setValue(QStringLiteral("cheatsearchwidget/displayhex"),
m_display_values_in_hex_checkbox->isChecked());
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);