Merge pull request #13866 from JoshuaVandaele/reset-button-third-attempt

AdvancedPane: Add a button to restore default settings
This commit is contained in:
JMC47
2025-10-28 18:56:03 -04:00
committed by GitHub
28 changed files with 526 additions and 439 deletions
+2
View File
@@ -882,6 +882,7 @@ static void RebuildUserDirectories(unsigned int dir_index)
s_user_paths[D_GRAPHICSMOD_IDX] = s_user_paths[D_LOAD_IDX] + GRAPHICSMOD_DIR DIR_SEP;
s_user_paths[D_BANNERS_WIIROOT_IDX] = s_user_paths[D_LOAD_IDX] + WIIBANNERS_DIR DIR_SEP;
s_user_paths[D_FIRMWARE_IDX] = s_user_paths[D_LOAD_IDX] + FIRMWARE_DIR DIR_SEP;
s_user_paths[D_WIISYSCONF_IDX] = s_user_paths[D_WIIROOT_IDX] + WII_SYSCONF_DIR DIR_SEP;
s_user_paths[D_WIISDCARDSYNCFOLDER_IDX] = s_user_paths[D_LOAD_IDX] + WIISDSYNC_DIR DIR_SEP;
s_user_paths[F_DOLPHINCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + DOLPHIN_CONFIG;
s_user_paths[F_GCPADCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + GCPAD_CONFIG;
@@ -901,6 +902,7 @@ static void RebuildUserDirectories(unsigned int dir_index)
s_user_paths[F_FAKEVMEMDUMP_IDX] = s_user_paths[D_DUMP_IDX] + FAKEVMEM_DUMP;
s_user_paths[F_GCSRAM_IDX] = s_user_paths[D_GCUSER_IDX] + GC_SRAM;
s_user_paths[F_WIISDCARDIMAGE_IDX] = s_user_paths[D_LOAD_IDX] + WII_SD_CARD_IMAGE;
s_user_paths[F_WIISYSCONF_IDX] = s_user_paths[D_WIISYSCONF_IDX] + WII_SYSCONF;
s_user_paths[D_MEMORYWATCHER_IDX] = s_user_paths[D_USER_IDX] + MEMORYWATCHER_DIR DIR_SEP;
s_user_paths[F_MEMORYWATCHERLOCATIONS_IDX] =
+2
View File
@@ -71,6 +71,7 @@ enum
D_GBAUSER_IDX,
D_GBASAVES_IDX,
D_WIISDCARDSYNCFOLDER_IDX,
D_WIISYSCONF_IDX,
D_GPU_DRIVERS_EXTRACTED,
D_GPU_DRIVERS_TMP,
D_GPU_DRIVERS_HOOKS,
@@ -93,6 +94,7 @@ enum
F_MEMORYWATCHERLOCATIONS_IDX,
F_MEMORYWATCHERSOCKET_IDX,
F_WIISDCARDIMAGE_IDX,
F_WIISYSCONF_IDX,
F_DUALSHOCKUDPCLIENTCONFIG_IDX,
F_FREELOOKCONFIG_IDX,
F_GBABIOS_IDX,
+23
View File
@@ -102,6 +102,29 @@ void SConfig::LoadSettings()
Config::Load();
}
void SConfig::ResetAllSettings()
{
Config::ConfigChangeCallbackGuard config_guard;
File::Delete(File::GetUserPath(F_DOLPHINCONFIG_IDX));
File::Delete(File::GetUserPath(F_GFXCONFIG_IDX));
File::Delete(File::GetUserPath(F_LOGGERCONFIG_IDX));
File::Delete(File::GetUserPath(F_DUALSHOCKUDPCLIENTCONFIG_IDX));
File::Delete(File::GetUserPath(F_FREELOOKCONFIG_IDX));
File::Delete(File::GetUserPath(F_RETROACHIEVEMENTSCONFIG_IDX));
File::Delete(File::GetUserPath(F_WIISYSCONF_IDX));
for (Config::LayerType layer_type : Config::SEARCH_ORDER)
{
const std::shared_ptr<Config::Layer> layer = Config::GetLayer(layer_type);
if (!layer)
continue;
layer->DeleteAllKeys();
}
Config::OnConfigChanged();
}
const std::string SConfig::GetGameID() const
{
std::lock_guard<std::recursive_mutex> lock(m_metadata_lock);
+2
View File
@@ -110,6 +110,8 @@ struct SConfig
// Load settings
void LoadSettings();
static void ResetAllSettings();
// Return the permanent and somewhat globally used instance of this struct
static SConfig& GetInstance() { return (*m_Instance); }
static void Init();
+6
View File
@@ -68,6 +68,10 @@ add_executable(dolphin-emu
Config/ConfigControls/ConfigFloatSlider.h
Config/ConfigControls/ConfigSlider.cpp
Config/ConfigControls/ConfigSlider.h
Config/ConfigControls/ConfigText.cpp
Config/ConfigControls/ConfigText.h
Config/ConfigControls/ConfigUserPath.cpp
Config/ConfigControls/ConfigUserPath.h
Config/ControllerInterface/ControllerInterfaceWindow.cpp
Config/ControllerInterface/ControllerInterfaceWindow.h
Config/ControllerInterface/DualShockUDPClientAddServerDialog.cpp
@@ -307,6 +311,8 @@ add_executable(dolphin-emu
NANDRepairDialog.h
NKitWarningDialog.cpp
NKitWarningDialog.h
QtUtils/AnalyticsPrompt.cpp
QtUtils/AnalyticsPrompt.h
QtUtils/AspectRatioWidget.cpp
QtUtils/AspectRatioWidget.h
QtUtils/BlockUserInputFilter.cpp
@@ -25,6 +25,26 @@ void ConfigChoice::OnConfigChanged()
setCurrentIndex(ReadValue(m_setting));
}
ConfigChoiceU32::ConfigChoiceU32(const QStringList& options, const Config::Info<u32>& setting,
Config::Layer* layer)
: ConfigControl(setting.GetLocation(), layer), m_setting(setting)
{
addItems(options);
setCurrentIndex(ReadValue(setting));
connect(this, &QComboBox::currentIndexChanged, this, &ConfigChoiceU32::Update);
}
void ConfigChoiceU32::Update(int choice)
{
SaveValue(m_setting, (u32)choice);
}
void ConfigChoiceU32::OnConfigChanged()
{
setCurrentIndex(ReadValue(m_setting));
}
ConfigStringChoice::ConfigStringChoice(const std::vector<std::string>& options,
const Config::Info<std::string>& setting,
Config::Layer* layer)
@@ -28,6 +28,59 @@ private:
Config::Info<int> m_setting;
};
class ConfigChoiceU32 final : public ConfigControl<ToolTipComboBox>
{
Q_OBJECT
public:
ConfigChoiceU32(const QStringList& options, const Config::Info<u32>& setting,
Config::Layer* layer = nullptr);
protected:
void OnConfigChanged() override;
private:
void Update(int choice);
Config::Info<u32> m_setting;
};
template <typename T>
class ConfigChoiceMap final : public ConfigControl<ToolTipComboBox>
{
public:
ConfigChoiceMap(const std::vector<std::pair<QString, T>>& options, const Config::Info<T>& setting,
Config::Layer* layer = nullptr)
: ConfigControl<ToolTipComboBox>(setting.GetLocation(), layer), m_setting(setting),
m_options(options)
{
for (const auto& [option_text, option_data] : options)
addItem(option_text);
OnConfigChanged();
connect(this, &QComboBox::currentIndexChanged, this, &ConfigChoiceMap::Update);
}
protected:
void OnConfigChanged() override
{
const T value = ReadValue(m_setting);
const auto it = std::find_if(m_options.begin(), m_options.end(),
[&value](const auto& pair) { return pair.second == value; });
int index =
(it != m_options.end()) ? static_cast<int>(std::distance(m_options.begin(), it)) : -1;
const QSignalBlocker blocker(this);
setCurrentIndex(index);
}
private:
void Update(int choice) { SaveValue(m_setting, m_options[choice].second); }
const Config::Info<T> m_setting;
const std::vector<std::pair<QString, T>> m_options;
};
class ConfigStringChoice final : public ConfigControl<ToolTipComboBox>
{
Q_OBJECT
@@ -0,0 +1,39 @@
// Copyright 2025 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "DolphinQt/Config/ConfigControls/ConfigText.h"
#include <QLineEdit>
ConfigText::ConfigText(const Config::Info<std::string>& setting) : ConfigText(setting, nullptr)
{
}
ConfigText::ConfigText(const Config::Info<std::string>& setting, Config::Layer* layer)
: ConfigControl(setting.GetLocation(), layer), m_setting(setting)
{
setText(QString::fromStdString(ReadValue(setting)));
connect(this, &QLineEdit::editingFinished, this, &ConfigText::Update);
}
void ConfigText::SetTextAndUpdate(const QString& text)
{
if (text == this->text())
return;
setText(text);
Update();
}
void ConfigText::Update()
{
const std::string value = text().toStdString();
SaveValue(m_setting, value);
}
void ConfigText::OnConfigChanged()
{
setText(QString::fromStdString(ReadValue(m_setting)));
}
@@ -0,0 +1,28 @@
// Copyright 2025 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QLineEdit>
#include "DolphinQt/Config/ConfigControls/ConfigControl.h"
#include "Common/Config/ConfigInfo.h"
class ConfigText : public ConfigControl<QLineEdit>
{
Q_OBJECT
public:
ConfigText(const Config::Info<std::string>& setting);
ConfigText(const Config::Info<std::string>& setting, Config::Layer* layer);
void SetTextAndUpdate(const QString& text);
protected:
void OnConfigChanged() override;
const Config::Info<std::string> m_setting;
private:
void Update();
};
@@ -0,0 +1,59 @@
// Copyright 2025 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "DolphinQt/Config/ConfigControls/ConfigUserPath.h"
#include <QLineEdit>
#include <QString>
#include "Common/FileUtil.h"
#include "DolphinQt/Config/ConfigControls/ConfigText.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
ConfigUserPath::ConfigUserPath(const unsigned int dir_index,
const Config::Info<std::string>& setting)
: ConfigUserPath(dir_index, setting, nullptr)
{
}
ConfigUserPath::ConfigUserPath(const unsigned int dir_index,
const Config::Info<std::string>& setting, Config::Layer* layer)
: ConfigText(setting, layer), m_dir_index(dir_index)
{
OnConfigChanged();
connect(this, &QLineEdit::editingFinished, this, &ConfigUserPath::Update);
}
// Display the effective path: if Config has a value, use it; otherwise fall back to UserPath.
// Config values only serve to initialize UserPath at startup, an empty config meaning "use the
// current UserPath".
void ConfigUserPath::RefreshText()
{
const std::string config_value = ReadValue(m_setting);
const std::string userpath_value = File::GetUserPath(m_dir_index);
const QString text = QString::fromStdString(config_value.empty() ? userpath_value : config_value);
setText(text);
}
void ConfigUserPath::Update()
{
const QString new_text = text().trimmed();
if (new_text.isEmpty())
{
ModalMessageBox::warning(this, tr("Empty Value"),
tr("This field cannot be left empty. Please enter a value."));
RefreshText();
return;
}
const std::string value = new_text.toStdString();
File::SetUserPath(m_dir_index, value);
SaveValue(m_setting, value);
}
void ConfigUserPath::OnConfigChanged()
{
RefreshText();
}
@@ -0,0 +1,28 @@
// Copyright 2025 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QLineEdit>
#include "Common/Config/ConfigInfo.h"
#include "DolphinQt/Config/ConfigControls/ConfigText.h"
class ConfigUserPath final : public ConfigText
{
Q_OBJECT
public:
ConfigUserPath(const unsigned int dir_index, const Config::Info<std::string>& setting);
ConfigUserPath(const unsigned int dir_index, const Config::Info<std::string>& setting,
Config::Layer* layer);
protected:
void OnConfigChanged() override;
private:
void RefreshText();
void Update();
const unsigned int m_dir_index;
};
@@ -3,7 +3,6 @@
#include "DolphinQt/Config/FreeLookWidget.h"
#include <QCheckBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
@@ -15,9 +14,9 @@
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "DolphinQt/Config/ConfigControls/ConfigBool.h"
#include "DolphinQt/Config/ConfigControls/ConfigChoice.h"
#include "DolphinQt/Config/Mapping/MappingWindow.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h"
#include "DolphinQt/QtUtils/NonDefaultQPushButton.h"
#include "DolphinQt/Settings.h"
@@ -32,8 +31,7 @@ void FreeLookWidget::CreateLayout()
{
auto* layout = new QVBoxLayout();
m_enable_freelook = new ToolTipCheckBox(tr("Enable"));
m_enable_freelook->setChecked(Config::Get(Config::FREE_LOOK_ENABLED));
m_enable_freelook = new ConfigBool(tr("Enable"), Config::FREE_LOOK_ENABLED);
m_enable_freelook->SetDescription(
tr("Allows manipulation of the in-game camera.<br><br><dolphin_emphasis>If unsure, "
"leave this unchecked.</dolphin_emphasis>"));
@@ -67,8 +65,8 @@ void FreeLookWidget::CreateLayout()
description->setTextInteractionFlags(Qt::TextBrowserInteraction);
description->setOpenExternalLinks(true);
m_freelook_background_input = new QCheckBox(tr("Background Input"));
m_freelook_background_input->setChecked(Config::Get(Config::FREE_LOOK_BACKGROUND_INPUT));
m_freelook_background_input =
new ConfigBool(tr("Background Input"), Config::FREE_LOOK_BACKGROUND_INPUT);
auto* hlayout = new QHBoxLayout();
hlayout->addWidget(new QLabel(tr("Camera 1")));
@@ -87,8 +85,6 @@ void FreeLookWidget::ConnectWidgets()
{
connect(m_freelook_controller_configure_button, &QPushButton::clicked, this,
&FreeLookWidget::OnFreeLookControllerConfigured);
connect(m_enable_freelook, &QCheckBox::clicked, this, &FreeLookWidget::SaveSettings);
connect(m_freelook_background_input, &QCheckBox::clicked, this, &FreeLookWidget::SaveSettings);
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] {
const QSignalBlocker blocker(this);
LoadSettings();
@@ -109,7 +105,6 @@ void FreeLookWidget::OnFreeLookControllerConfigured()
void FreeLookWidget::LoadSettings()
{
const bool checked = Config::Get(Config::FREE_LOOK_ENABLED);
m_enable_freelook->setChecked(checked);
#ifdef USE_RETRO_ACHIEVEMENTS
const bool hardcore = AchievementManager::GetInstance().IsHardcoreModeActive();
m_enable_freelook->setEnabled(!hardcore);
@@ -118,14 +113,3 @@ void FreeLookWidget::LoadSettings()
m_freelook_controller_configure_button->setEnabled(checked);
m_freelook_background_input->setEnabled(checked);
}
void FreeLookWidget::SaveSettings()
{
const bool checked = m_enable_freelook->isChecked();
Config::SetBaseOrCurrent(Config::FREE_LOOK_ENABLED, checked);
Config::SetBaseOrCurrent(Config::FREE_LOOK_BACKGROUND_INPUT,
m_freelook_background_input->isChecked());
m_freelook_control_type->setEnabled(checked);
m_freelook_controller_configure_button->setEnabled(checked);
m_freelook_background_input->setEnabled(checked);
}
@@ -5,6 +5,7 @@
#include <QWidget>
class ConfigBool;
class ConfigChoice;
class QCheckBox;
class QPushButton;
@@ -24,7 +25,7 @@ private:
void LoadSettings();
void SaveSettings();
ToolTipCheckBox* m_enable_freelook;
ConfigBool* m_enable_freelook;
ConfigChoice* m_freelook_control_type;
QPushButton* m_freelook_controller_configure_button;
QCheckBox* m_freelook_background_input;
+6
View File
@@ -64,6 +64,8 @@
<ClCompile Include="Config\ConfigControls\ConfigRadio.cpp" />
<ClCompile Include="Config\ConfigControls\ConfigFloatSlider.cpp" />
<ClCompile Include="Config\ConfigControls\ConfigSlider.cpp" />
<ClCompile Include="Config\ConfigControls\ConfigText.cpp" />
<ClCompile Include="Config\ConfigControls\ConfigUserPath.cpp" />
<ClCompile Include="Config\ControllerInterface\ControllerInterfaceWindow.cpp" />
<ClCompile Include="Config\ControllerInterface\DualShockUDPClientAddServerDialog.cpp" />
<ClCompile Include="Config\ControllerInterface\DualShockUDPClientWidget.cpp" />
@@ -189,6 +191,7 @@
<ClCompile Include="pch_qt.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="QtUtils\AnalyticsPrompt.cpp" />
<ClCompile Include="QtUtils\AspectRatioWidget.cpp" />
<ClCompile Include="QtUtils\BlockUserInputFilter.cpp" />
<ClCompile Include="QtUtils\ClearLayoutRecursively.cpp" />
@@ -294,6 +297,8 @@
<QtMoc Include="Config\ConfigControls\ConfigRadio.h" />
<QtMoc Include="Config\ConfigControls\ConfigFloatSlider.h" />
<QtMoc Include="Config\ConfigControls\ConfigSlider.h" />
<QtMoc Include="Config\ConfigControls\ConfigText.h" />
<QtMoc Include="Config\ConfigControls\ConfigUserPath.h" />
<QtMoc Include="Config\ControllerInterface\ControllerInterfaceWindow.h" />
<QtMoc Include="Config\ControllerInterface\DualShockUDPClientAddServerDialog.h" />
<QtMoc Include="Config\ControllerInterface\DualShockUDPClientWidget.h" />
@@ -408,6 +413,7 @@
<QtMoc Include="NetPlay\PadMappingDialog.h" />
<QtMoc Include="NANDRepairDialog.h" />
<QtMoc Include="NKitWarningDialog.h" />
<QtMoc Include="QtUtils\AnalyticsPrompt.h" />
<QtMoc Include="QtUtils\AspectRatioWidget.h" />
<QtMoc Include="QtUtils\BlockUserInputFilter.h" />
<QtMoc Include="QtUtils\DoubleClickEventFilter.h" />
+9 -32
View File
@@ -33,6 +33,7 @@
#include "DolphinQt/Host.h"
#include "DolphinQt/MainWindow.h"
#include "DolphinQt/QtUtils/AnalyticsPrompt.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/RunOnObject.h"
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
@@ -269,40 +270,16 @@ int main(int argc, char* argv[])
// the dialog is only shown after the application is ready, as only then it is guaranteed that
// the main window has been placed in its final position.
auto* const connection_context = new QObject(&win);
QObject::connect(
qApp, &QGuiApplication::applicationStateChanged, connection_context,
[connection_context, &win](const Qt::ApplicationState state) {
if (state != Qt::ApplicationState::ApplicationActive)
return;
QObject::connect(qApp, &QGuiApplication::applicationStateChanged, connection_context,
[connection_context, &win](const Qt::ApplicationState state) {
if (state != Qt::ApplicationState::ApplicationActive)
return;
// Severe the connection after the first run.
delete connection_context;
// Severe the connection after the first run.
delete connection_context;
ModalMessageBox analytics_prompt(&win);
analytics_prompt.setIcon(QMessageBox::Question);
analytics_prompt.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
analytics_prompt.setWindowTitle(QObject::tr("Allow Usage Statistics Reporting"));
analytics_prompt.setText(QObject::tr(
"Do you authorize Dolphin to report information to Dolphin's developers?"));
analytics_prompt.setInformativeText(
QObject::tr("If authorized, Dolphin can collect data on its performance, "
"feature usage, and configuration, as well as data on your system's "
"hardware and operating system.\n\n"
"No private data is ever collected. This data helps us understand "
"how people and emulated games use Dolphin and prioritize our "
"efforts. It also helps us identify rare configurations that are "
"causing bugs, performance and stability issues.\n"
"This authorization can be revoked at any time through Dolphin's "
"settings."));
const int answer = analytics_prompt.exec();
Config::SetBase(Config::MAIN_ANALYTICS_PERMISSION_ASKED, true);
Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes);
DolphinAnalytics::Instance().ReloadConfig();
});
ShowAnalyticsPrompt(&win);
});
}
#endif
@@ -0,0 +1,41 @@
// Copyright 2025 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "DolphinQt/QtUtils/AnalyticsPrompt.h"
#include <QMessageBox>
#include <QObject>
#include <QWidget>
#include "Core/Config/MainSettings.h"
#include "Core/DolphinAnalytics.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/Settings.h"
void ShowAnalyticsPrompt(QWidget* parent)
{
ModalMessageBox analytics_prompt(parent);
analytics_prompt.setIcon(QMessageBox::Question);
analytics_prompt.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
analytics_prompt.setWindowTitle(QObject::tr("Allow Usage Statistics Reporting"));
analytics_prompt.setText(
QObject::tr("Do you authorize Dolphin to report information to Dolphin's developers?"));
analytics_prompt.setInformativeText(
QObject::tr("If authorized, Dolphin can collect data on its performance, "
"feature usage, and configuration, as well as data on your system's "
"hardware and operating system.\n\n"
"No private data is ever collected. This data helps us understand "
"how people and emulated games use Dolphin and prioritize our "
"efforts. It also helps us identify rare configurations that are "
"causing bugs, performance and stability issues.\n"
"This authorization can be revoked at any time through Dolphin's "
"settings."));
const int answer = analytics_prompt.exec();
Config::SetBase(Config::MAIN_ANALYTICS_PERMISSION_ASKED, true);
Settings::Instance().SetAnalyticsEnabled(answer == QMessageBox::Yes);
DolphinAnalytics::Instance().ReloadConfig();
}
@@ -0,0 +1,8 @@
// Copyright 2025 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QWidget>
void ShowAnalyticsPrompt(QWidget* parent);
-6
View File
@@ -773,10 +773,7 @@ bool Settings::IsSDCardInserted() const
void Settings::SetSDCardInserted(bool inserted)
{
if (IsSDCardInserted() != inserted)
{
Config::SetBaseOrCurrent(Config::MAIN_WII_SD_CARD, inserted);
emit SDCardInsertionChanged(inserted);
}
}
bool Settings::IsUSBKeyboardConnected() const
@@ -787,10 +784,7 @@ bool Settings::IsUSBKeyboardConnected() const
void Settings::SetUSBKeyboardConnected(bool connected)
{
if (IsUSBKeyboardConnected() != connected)
{
Config::SetBaseOrCurrent(Config::MAIN_WII_KEYBOARD, connected);
emit USBKeyboardConnectionChanged(connected);
}
}
bool Settings::IsWiiSpeakMuted() const
-2
View File
@@ -223,8 +223,6 @@ signals:
void AnalyticsToggled(bool enabled);
void ReleaseDevices();
void DevicesChanged();
void SDCardInsertionChanged(bool inserted);
void USBKeyboardConnectionChanged(bool connected);
void WiiSpeakMuteChanged(bool muted);
void EnableGfxModsChanged(bool enabled);
+49 -19
View File
@@ -4,7 +4,6 @@
#include "DolphinQt/Settings/AdvancedPane.h"
#include <QCheckBox>
#include <QComboBox>
#include <QDateTimeEdit>
#include <QFontMetrics>
#include <QFormLayout>
@@ -17,6 +16,9 @@
#include <QVBoxLayout>
#include <cmath>
#include "Common/Config/Config.h"
#include "Common/Config/Enums.h"
#include "Common/FileUtil.h"
#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
@@ -26,12 +28,18 @@
#include "Core/System.h"
#include "DolphinQt/Config/ConfigControls/ConfigBool.h"
#include "DolphinQt/Config/ConfigControls/ConfigChoice.h"
#include "DolphinQt/Config/ConfigControls/ConfigFloatSlider.h"
#include "DolphinQt/Config/ConfigControls/ConfigSlider.h"
#include "DolphinQt/QtUtils/AnalyticsPrompt.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/NonDefaultQPushButton.h"
#include "DolphinQt/QtUtils/QtUtils.h"
#include "DolphinQt/QtUtils/SignalBlocking.h"
#include "DolphinQt/Settings.h"
#include "UICommon/UICommon.h"
static const std::map<PowerPC::CPUCore, const char*> CPU_CORE_NAMES = {
{PowerPC::CPUCore::Interpreter, QT_TR_NOOP("Interpreter (slowest)")},
{PowerPC::CPUCore::CachedInterpreter, QT_TR_NOOP("Cached Interpreter (slower)")},
@@ -64,12 +72,12 @@ void AdvancedPane::CreateLayout()
cpu_emulation_engine_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
cpu_options_group_layout->addLayout(cpu_emulation_engine_layout);
m_cpu_emulation_engine_combobox = new QComboBox(this);
cpu_emulation_engine_layout->addRow(tr("CPU Emulation Engine:"), m_cpu_emulation_engine_combobox);
std::vector<std::pair<QString, PowerPC::CPUCore>> emulation_engine_choices;
for (PowerPC::CPUCore cpu_core : PowerPC::AvailableCPUCores())
{
m_cpu_emulation_engine_combobox->addItem(tr(CPU_CORE_NAMES.at(cpu_core)));
}
emulation_engine_choices.emplace_back(tr(CPU_CORE_NAMES.at(cpu_core)), cpu_core);
m_cpu_emulation_engine_combobox =
new ConfigChoiceMap<PowerPC::CPUCore>(emulation_engine_choices, Config::MAIN_CPU_CORE);
cpu_emulation_engine_layout->addRow(tr("CPU Emulation Engine:"), m_cpu_emulation_engine_combobox);
m_enable_mmu_checkbox = new ConfigBool(tr("Enable MMU"), Config::MAIN_MMU);
m_enable_mmu_checkbox->SetDescription(
@@ -284,17 +292,20 @@ void AdvancedPane::CreateLayout()
"your current system time."
"<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>"));
auto* reset_group = new QGroupBox(tr("Reset Dolphin Settings"));
reset_group->setLayout(new QVBoxLayout());
main_layout->addWidget(reset_group);
m_reset_button = new NonDefaultQPushButton(tr("Reset All Settings"));
connect(m_reset_button, &QPushButton::clicked, this, &AdvancedPane::OnResetButtonClicked);
reset_group->layout()->addWidget(m_reset_button);
main_layout->addStretch(1);
}
void AdvancedPane::ConnectLayout()
{
connect(m_cpu_emulation_engine_combobox, &QComboBox::currentIndexChanged, [](int index) {
const auto cpu_cores = PowerPC::AvailableCPUCores();
if (index >= 0 && static_cast<size_t>(index) < cpu_cores.size())
Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, cpu_cores[index]);
});
m_ram_override_checkbox->setChecked(Config::Get(Config::MAIN_RAM_OVERRIDE_ENABLE));
connect(m_ram_override_checkbox, &QCheckBox::toggled, [this](bool enable_ram_override) {
Config::SetBaseOrCurrent(Config::MAIN_RAM_OVERRIDE_ENABLE, enable_ram_override);
@@ -317,13 +328,6 @@ void AdvancedPane::Update()
const bool enable_custom_rtc_widgets =
Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE) && is_uninitialized;
const auto available_cpu_cores = PowerPC::AvailableCPUCores();
const auto cpu_core = Config::Get(Config::MAIN_CPU_CORE);
for (size_t i = 0; i < available_cpu_cores.size(); ++i)
{
if (available_cpu_cores[i] == cpu_core)
m_cpu_emulation_engine_combobox->setCurrentIndex(int(i));
}
m_cpu_emulation_engine_combobox->setEnabled(is_uninitialized);
m_enable_mmu_checkbox->setEnabled(is_uninitialized);
m_pause_on_panic_checkbox->setEnabled(is_uninitialized);
@@ -366,4 +370,30 @@ void AdvancedPane::Update()
initial_date_time.setSecsSinceEpoch(Config::Get(Config::MAIN_CUSTOM_RTC_VALUE));
m_custom_rtc_datetime->setEnabled(enable_custom_rtc_widgets);
SignalBlocking(m_custom_rtc_datetime)->setDateTime(initial_date_time);
m_reset_button->setEnabled(is_uninitialized);
}
void AdvancedPane::OnResetButtonClicked()
{
if (ModalMessageBox::question(
this, tr("Reset Dolphin Settings"),
tr("Are you sure you want to restore all Dolphin settings to their default "
"values? This action cannot be undone!\n"
"All customizations or changes you have made will be lost.\n\n"
"Do you want to proceed?"),
ModalMessageBox::StandardButtons(ModalMessageBox::Yes | ModalMessageBox::No),
ModalMessageBox::No, Qt::WindowModality::WindowModal) == ModalMessageBox::No)
{
return;
}
SConfig::ResetAllSettings();
UICommon::SetUserDirectory(File::GetUserPath(D_USER_IDX));
emit Settings::Instance().ConfigChanged();
#if defined(USE_ANALYTICS) && USE_ANALYTICS
ShowAnalyticsPrompt(this);
#endif
}

Some files were not shown because too many files have changed in this diff Show More