Qt: Fix settings clear not resetting input profile

This commit is contained in:
Stenzek 2024-10-21 00:29:52 +10:00
parent a9bfe2642f
commit 6e1d8c5213
No known key found for this signature in database
5 changed files with 36 additions and 23 deletions

View File

@ -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");

View File

@ -18,6 +18,7 @@
#include <QtCore/QDateTime>
#include <QtCore/QFuture>
#include <QtCore/QSignalBlocker>
#include <QtCore/QStringBuilder>
#include <QtWidgets/QDialog>
#include <QtWidgets/QDialogButtonBox>
@ -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<std::string> 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<std::string> 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();

View File

@ -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);

View File

@ -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("<strong>Summary</strong><hr>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;
}
if (isPerGameSettings())
{
m_game_summary->reloadGameSettings();
m_ui.safeMode->disconnect();
}
addPages();
}

View File

@ -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<INISettingsInterface> 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;