From 6e1d8c52139d792088a00576afa9e6770c20b603 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 21 Oct 2024 00:29:52 +1000 Subject: [PATCH] Qt: Fix settings clear not resetting input profile --- src/core/settings.cpp | 5 +-- src/duckstation-qt/gamesummarywidget.cpp | 40 ++++++++++++++---------- src/duckstation-qt/gamesummarywidget.h | 2 ++ src/duckstation-qt/settingswindow.cpp | 10 ++++-- src/duckstation-qt/settingswindow.h | 2 ++ 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 1866f297a..3fb53b010 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -762,14 +762,11 @@ void Settings::Clear(SettingsInterface& si) si.ClearSection("PCDrv"); si.ClearSection("BIOS"); + si.ClearSection("ControllerPorts"); for (u32 i = 0; i < NUM_CONTROLLER_AND_CARD_PORTS; i++) si.ClearSection(Controller::GetSettingsSection(i).c_str()); si.ClearSection("MemoryCards"); - - // Can't wipe out this section, because input profiles. - si.DeleteValue("ControllerPorts", "MultitapMode"); - si.ClearSection("Cheevos"); si.ClearSection("Logging"); si.ClearSection("Debug"); diff --git a/src/duckstation-qt/gamesummarywidget.cpp b/src/duckstation-qt/gamesummarywidget.cpp index b7eddc74f..0f55ffdab 100644 --- a/src/duckstation-qt/gamesummarywidget.cpp +++ b/src/duckstation-qt/gamesummarywidget.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -72,6 +73,28 @@ GameSummaryWidget::GameSummaryWidget(const std::string& path, const std::string& GameSummaryWidget::~GameSummaryWidget() = default; +void GameSummaryWidget::reloadGameSettings() +{ + if (m_dialog->getBoolValue("ControllerPorts", "UseGameSettingsForController", std::nullopt).value_or(false)) + { + const QSignalBlocker sb(m_ui.inputProfile); + m_ui.inputProfile->setCurrentIndex(1); + } + else if (const std::optional profile_name = + m_dialog->getStringValue("ControllerPorts", "InputProfileName", std::nullopt); + profile_name.has_value() && !profile_name->empty()) + { + const QSignalBlocker sb(m_ui.inputProfile); + m_ui.inputProfile->setCurrentIndex(m_ui.inputProfile->findText(QString::fromStdString(profile_name.value()))); + } + else + { + const QSignalBlocker sb(m_ui.inputProfile); + m_ui.inputProfile->setCurrentIndex(0); + } + m_ui.editInputProfile->setEnabled(m_ui.inputProfile->currentIndex() >= 1); +} + void GameSummaryWidget::populateUi(const std::string& path, const std::string& serial, DiscRegion region, const GameDatabase::Entry* entry) { @@ -167,22 +190,7 @@ void GameSummaryWidget::populateUi(const std::string& path, const std::string& s for (const std::string& name : InputManager::GetInputProfileNames()) m_ui.inputProfile->addItem(QString::fromStdString(name)); - if (m_dialog->getBoolValue("ControllerPorts", "UseGameSettingsForController", std::nullopt).value_or(false)) - { - m_ui.inputProfile->setCurrentIndex(1); - } - else if (const std::optional profile_name = - m_dialog->getStringValue("ControllerPorts", "InputProfileName", std::nullopt); - profile_name.has_value() && !profile_name->empty()) - { - m_ui.inputProfile->setCurrentIndex(m_ui.inputProfile->findText(QString::fromStdString(profile_name.value()))); - } - else - { - m_ui.inputProfile->setCurrentIndex(0); - } - m_ui.editInputProfile->setEnabled(m_ui.inputProfile->currentIndex() >= 1); - + reloadGameSettings(); populateCustomAttributes(); populateTracksInfo(); updateWindowTitle(); diff --git a/src/duckstation-qt/gamesummarywidget.h b/src/duckstation-qt/gamesummarywidget.h index 5c221152c..f9866362e 100644 --- a/src/duckstation-qt/gamesummarywidget.h +++ b/src/duckstation-qt/gamesummarywidget.h @@ -24,6 +24,8 @@ public: const GameDatabase::Entry* entry, SettingsWindow* dialog, QWidget* parent); ~GameSummaryWidget(); + void reloadGameSettings(); + private Q_SLOTS: void onCompatibilityCommentsClicked(); void onInputProfileChanged(int index); diff --git a/src/duckstation-qt/settingswindow.cpp b/src/duckstation-qt/settingswindow.cpp index 5354d7a5e..571728624 100644 --- a/src/duckstation-qt/settingswindow.cpp +++ b/src/duckstation-qt/settingswindow.cpp @@ -55,8 +55,8 @@ SettingsWindow::SettingsWindow(const std::string& path, std::string serial, Game m_ui.setupUi(this); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - addWidget(new GameSummaryWidget(path, serial, region, entry, this, m_ui.settingsContainer), tr("Summary"), - QStringLiteral("file-list-line"), + addWidget(m_game_summary = new GameSummaryWidget(path, serial, region, entry, this, m_ui.settingsContainer), + tr("Summary"), QStringLiteral("file-list-line"), tr("Summary
This page shows information about the selected game, and allows you to " "validate your disc was dumped correctly.")); addPages(); @@ -209,7 +209,11 @@ void SettingsWindow::reloadPages() delete widget; } - m_ui.safeMode->disconnect(); + if (isPerGameSettings()) + { + m_game_summary->reloadGameSettings(); + m_ui.safeMode->disconnect(); + } addPages(); } diff --git a/src/duckstation-qt/settingswindow.h b/src/duckstation-qt/settingswindow.h index d979691b1..5cbeb3f71 100644 --- a/src/duckstation-qt/settingswindow.h +++ b/src/duckstation-qt/settingswindow.h @@ -23,6 +23,7 @@ enum class Trait : u32; struct Entry; } // namespace GameDatabase +class GameSummaryWidget; class InterfaceSettingsWidget; class BIOSSettingsWidget; class GameListSettingsWidget; @@ -136,6 +137,7 @@ private: std::unique_ptr m_sif; const GameDatabase::Entry* m_database_entry = nullptr; + GameSummaryWidget* m_game_summary = nullptr; InterfaceSettingsWidget* m_interface_settings = nullptr; BIOSSettingsWidget* m_bios_settings = nullptr; ConsoleSettingsWidget* m_console_settings = nullptr;