summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2026-11-15 17:32:18 -0600
committerGitHub <noreply@github.com>2026-11-15 17:32:18 -0600
commit2d451da728fe0db49fe9319db511834d03b995c2 (patch)
tree807daa7cdd1243b38ee1e15683f8e12829bb930d /Source
parent545bf5d5cc3bb94463ed0f4519594f5075397786 (diff)
parent9ac2b284b9255ec7bde12a499ab3f137476967ee (diff)
Merge pull request #14276 from JoshuaVandaele/mo-config-controls
Use more ConfigControls
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DolphinQt/Settings.cpp15
-rw-r--r--Source/Core/DolphinQt/Settings.h5
-rw-r--r--Source/Core/DolphinQt/Settings/GeneralPane.cpp91
-rw-r--r--Source/Core/DolphinQt/Settings/GeneralPane.h9
-rw-r--r--Source/Core/UICommon/DiscordPresence.cpp15
-rw-r--r--Source/Core/UICommon/DiscordPresence.h2
6 files changed, 30 insertions, 107 deletions
diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp
index 618a2b5ced..5a99e5dd22 100644
--- a/Source/Core/DolphinQt/Settings.cpp
+++ b/Source/Core/DolphinQt/Settings.cpp
@@ -900,21 +900,6 @@ QString Settings::GetAutoUpdateTrack() const
return QString::fromStdString(Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK));
}
-void Settings::SetFallbackRegion(const DiscIO::Region& region)
-{
- if (region == GetFallbackRegion())
- return;
-
- Config::SetBase(Config::MAIN_FALLBACK_REGION, region);
-
- emit FallbackRegionChanged(region);
-}
-
-DiscIO::Region Settings::GetFallbackRegion() const
-{
- return Config::Get(Config::MAIN_FALLBACK_REGION);
-}
-
void Settings::SetAnalyticsEnabled(bool enabled)
{
if (enabled == IsAnalyticsEnabled())
diff --git a/Source/Core/DolphinQt/Settings.h b/Source/Core/DolphinQt/Settings.h
index 0c79020ff8..b8ac1bf433 100644
--- a/Source/Core/DolphinQt/Settings.h
+++ b/Source/Core/DolphinQt/Settings.h
@@ -183,10 +183,6 @@ public:
QString GetAutoUpdateTrack() const;
void SetAutoUpdateTrack(const QString& mode);
- // Fallback Region
- DiscIO::Region GetFallbackRegion() const;
- void SetFallbackRegion(const DiscIO::Region& region);
-
// Analytics
bool IsAnalyticsEnabled() const;
void SetAnalyticsEnabled(bool enabled);
@@ -227,7 +223,6 @@ signals:
void DebugFontChanged(const QFont& font);
void ShowDemangledNamesChanged(bool enabled);
void AutoUpdateTrackChanged(const QString& mode);
- void FallbackRegionChanged(const DiscIO::Region& region);
void AnalyticsToggled(bool enabled);
void ReleaseDevices();
void DevicesChanged();
diff --git a/Source/Core/DolphinQt/Settings/GeneralPane.cpp b/Source/Core/DolphinQt/Settings/GeneralPane.cpp
index c9a0a733b5..12a0ff9493 100644
--- a/Source/Core/DolphinQt/Settings/GeneralPane.cpp
+++ b/Source/Core/DolphinQt/Settings/GeneralPane.cpp
@@ -21,6 +21,7 @@
#include "Core/System.h"
#include "DolphinQt/Config/ConfigControls/ConfigBool.h"
+#include "DolphinQt/Config/ConfigControls/ConfigChoice.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h"
#include "DolphinQt/Config/ToolTipControls/ToolTipPushButton.h"
@@ -44,11 +45,6 @@ constexpr const char* AUTO_UPDATE_DISABLE_STRING = "";
constexpr const char* AUTO_UPDATE_RELEASE_STRING = "beta";
constexpr const char* AUTO_UPDATE_DEV_STRING = "dev";
-constexpr int FALLBACK_REGION_NTSCJ_INDEX = 0;
-constexpr int FALLBACK_REGION_NTSCU_INDEX = 1;
-constexpr int FALLBACK_REGION_PAL_INDEX = 2;
-constexpr int FALLBACK_REGION_NTSCK_INDEX = 3;
-
GeneralPane::GeneralPane(QWidget* parent) : QWidget(parent)
{
CreateLayout();
@@ -104,7 +100,7 @@ void GeneralPane::ConnectLayout()
connect(m_checkbox_cheats, &QCheckBox::toggled, &Settings::Instance(),
&Settings::EnableCheatsChanged);
#ifdef USE_DISCORD_PRESENCE
- connect(m_checkbox_discord_presence, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
+ connect(m_checkbox_discord_presence, &QCheckBox::toggled, this, &Discord::SetDiscordPresence);
#endif
if (AutoUpdateChecker::SystemSupportsAutoUpdates())
@@ -115,15 +111,8 @@ void GeneralPane::ConnectLayout()
&GeneralPane::LoadConfig);
}
- // Advanced
- connect(m_combobox_speedlimit, &QComboBox::currentIndexChanged, [this] {
- Config::SetBaseOrCurrent(Config::MAIN_EMULATION_SPEED,
- m_combobox_speedlimit->currentIndex() * 0.1f);
- });
-
connect(m_combobox_fallback_region, &QComboBox::currentIndexChanged, this,
&GeneralPane::OnSaveConfig);
- connect(&Settings::Instance(), &Settings::FallbackRegionChanged, this, &GeneralPane::LoadConfig);
#if defined(USE_ANALYTICS) && USE_ANALYTICS
connect(&Settings::Instance(), &Settings::AnalyticsToggled, this, &GeneralPane::LoadConfig);
@@ -164,7 +153,8 @@ void GeneralPane::CreateBasic()
basic_group_layout->addWidget(m_checkbox_auto_disc_change);
#ifdef USE_DISCORD_PRESENCE
- m_checkbox_discord_presence = new ToolTipCheckBox(tr("Show Current Game on Discord"));
+ m_checkbox_discord_presence =
+ new ConfigBool(tr("Show Current Game on Discord"), Config::MAIN_USE_DISCORD_PRESENCE);
basic_group_layout->addWidget(m_checkbox_discord_presence);
#endif
@@ -173,9 +163,8 @@ void GeneralPane::CreateBasic()
speed_limit_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
basic_group_layout->addLayout(speed_limit_layout);
- m_combobox_speedlimit = new ToolTipComboBox();
-
- m_combobox_speedlimit->addItem(tr("Unlimited"));
+ std::vector<std::pair<QString, float>> speedlimit_choices{};
+ speedlimit_choices.emplace_back(tr("Unlimited"), 0.0f);
for (int i = 10; i <= 200; i += 10) // from 10% to 200%
{
QString str;
@@ -184,9 +173,13 @@ void GeneralPane::CreateBasic()
else
str = tr("%1% (Normal Speed)").arg(i);
- m_combobox_speedlimit->addItem(str);
+ const float value = static_cast<float>(i) / 100.0f;
+ speedlimit_choices.emplace_back(str, value);
}
+ m_combobox_speedlimit =
+ new ConfigChoiceMap<float>(speedlimit_choices, Config::MAIN_EMULATION_SPEED);
+
speed_limit_layout->addRow(tr("&Speed Limit:"), m_combobox_speedlimit);
}
@@ -225,11 +218,14 @@ void GeneralPane::CreateFallbackRegion()
fallback_region_dropdown_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
fallback_region_group_layout->addLayout(fallback_region_dropdown_layout);
- m_combobox_fallback_region = new ToolTipComboBox();
+ std::vector<std::pair<QString, DiscIO::Region>> fallback_choices{
+ {tr("NTSC-J"), DiscIO::Region::NTSC_J},
+ {tr("NTSC-U"), DiscIO::Region::NTSC_U},
+ {tr("PAL"), DiscIO::Region::PAL},
+ {tr("NTSC-K"), DiscIO::Region::NTSC_K},
+ };
+ m_combobox_fallback_region = new ConfigChoiceMap(fallback_choices, Config::MAIN_FALLBACK_REGION);
fallback_region_dropdown_layout->addRow(tr("Fallback Region:"), m_combobox_fallback_region);
-
- for (const QString& option : {tr("NTSC-J"), tr("NTSC-U"), tr("PAL"), tr("NTSC-K")})
- m_combobox_fallback_region->addItem(option);
}
#if defined(USE_ANALYTICS) && USE_ANALYTICS
@@ -269,26 +265,6 @@ void GeneralPane::LoadConfig()
SignalBlocking(m_checkbox_enable_analytics)
->setChecked(Settings::Instance().IsAnalyticsEnabled());
#endif
-
-#ifdef USE_DISCORD_PRESENCE
- SignalBlocking(m_checkbox_discord_presence)
- ->setChecked(Config::Get(Config::MAIN_USE_DISCORD_PRESENCE));
-#endif
- int selection = qRound(Config::Get(Config::MAIN_EMULATION_SPEED) * 10);
- if (selection < m_combobox_speedlimit->count())
- SignalBlocking(m_combobox_speedlimit)->setCurrentIndex(selection);
-
- const auto fallback = Settings::Instance().GetFallbackRegion();
- if (fallback == DiscIO::Region::NTSC_J)
- SignalBlocking(m_combobox_fallback_region)->setCurrentIndex(FALLBACK_REGION_NTSCJ_INDEX);
- else if (fallback == DiscIO::Region::NTSC_U)
- SignalBlocking(m_combobox_fallback_region)->setCurrentIndex(FALLBACK_REGION_NTSCU_INDEX);
- else if (fallback == DiscIO::Region::PAL)
- SignalBlocking(m_combobox_fallback_region)->setCurrentIndex(FALLBACK_REGION_PAL_INDEX);
- else if (fallback == DiscIO::Region::NTSC_K)
- SignalBlocking(m_combobox_fallback_region)->setCurrentIndex(FALLBACK_REGION_NTSCK_INDEX);
- else
- SignalBlocking(m_combobox_fallback_region)->setCurrentIndex(FALLBACK_REGION_NTSCJ_INDEX);
}
static QString UpdateTrackFromIndex(int index)
@@ -311,31 +287,6 @@ static QString UpdateTrackFromIndex(int index)
return value;
}
-static DiscIO::Region UpdateFallbackRegionFromIndex(int index)
-{
- DiscIO::Region value = DiscIO::Region::Unknown;
-
- switch (index)
- {
- case FALLBACK_REGION_NTSCJ_INDEX:
- value = DiscIO::Region::NTSC_J;
- break;
- case FALLBACK_REGION_NTSCU_INDEX:
- value = DiscIO::Region::NTSC_U;
- break;
- case FALLBACK_REGION_PAL_INDEX:
- value = DiscIO::Region::PAL;
- break;
- case FALLBACK_REGION_NTSCK_INDEX:
- value = DiscIO::Region::NTSC_K;
- break;
- default:
- value = DiscIO::Region::NTSC_J;
- }
-
- return value;
-}
-
void GeneralPane::OnSaveConfig()
{
Config::ConfigChangeCallbackGuard config_guard;
@@ -346,16 +297,10 @@ void GeneralPane::OnSaveConfig()
UpdateTrackFromIndex(m_combobox_update_track->currentIndex()));
}
-#ifdef USE_DISCORD_PRESENCE
- Discord::SetDiscordPresenceEnabled(m_checkbox_discord_presence->isChecked());
-#endif
-
#if defined(USE_ANALYTICS) && USE_ANALYTICS
Settings::Instance().SetAnalyticsEnabled(m_checkbox_enable_analytics->isChecked());
DolphinAnalytics::Instance().ReloadConfig();
#endif
- Settings::Instance().SetFallbackRegion(
- UpdateFallbackRegionFromIndex(m_combobox_fallback_region->currentIndex()));
}
#if defined(USE_ANALYTICS) && USE_ANALYTICS
diff --git a/Source/Core/DolphinQt/Settings/GeneralPane.h b/Source/Core/DolphinQt/Settings/GeneralPane.h
index b482172b09..6b9354c481 100644
--- a/Source/Core/DolphinQt/Settings/GeneralPane.h
+++ b/Source/Core/DolphinQt/Settings/GeneralPane.h
@@ -6,6 +6,8 @@
#include <QWidget>
class ConfigBool;
+template <typename T>
+class ConfigChoiceMap;
class QCheckBox;
class QComboBox;
class QLabel;
@@ -22,6 +24,11 @@ namespace Core
enum class State;
}
+namespace DiscIO
+{
+enum class Region;
+}
+
class GeneralPane final : public QWidget
{
Q_OBJECT
@@ -45,7 +52,7 @@ private:
QVBoxLayout* m_main_layout;
ToolTipComboBox* m_combobox_speedlimit;
ToolTipComboBox* m_combobox_update_track;
- ToolTipComboBox* m_combobox_fallback_region;
+ ConfigChoiceMap<DiscIO::Region>* m_combobox_fallback_region;
ConfigBool* m_checkbox_dualcore;
ConfigBool* m_checkbox_cheats;
ConfigBool* m_checkbox_load_games_into_memory;
diff --git a/Source/Core/UICommon/DiscordPresence.cpp b/Source/Core/UICommon/DiscordPresence.cpp
index 1be073a4ca..384687370b 100644
--- a/Source/Core/UICommon/DiscordPresence.cpp
+++ b/Source/Core/UICommon/DiscordPresence.cpp
@@ -304,26 +304,17 @@ std::string CreateSecretFromIPAddress(const std::string& ip_address, int port)
void Shutdown()
{
#ifdef USE_DISCORD_PRESENCE
- if (!Config::Get(Config::MAIN_USE_DISCORD_PRESENCE))
- return;
-
Discord_ClearPresence();
Discord_Shutdown();
#endif
}
-void SetDiscordPresenceEnabled(bool enabled)
+void SetDiscordPresence()
{
- if (Config::Get(Config::MAIN_USE_DISCORD_PRESENCE) == enabled)
- return;
-
- if (Config::Get(Config::MAIN_USE_DISCORD_PRESENCE))
- Discord::Shutdown();
-
- Config::SetBase(Config::MAIN_USE_DISCORD_PRESENCE, enabled);
-
if (Config::Get(Config::MAIN_USE_DISCORD_PRESENCE))
Discord::Init();
+ else
+ Discord::Shutdown();
}
} // namespace Discord
diff --git a/Source/Core/UICommon/DiscordPresence.h b/Source/Core/UICommon/DiscordPresence.h
index 59b8c6a6c8..7dc1e9e380 100644
--- a/Source/Core/UICommon/DiscordPresence.h
+++ b/Source/Core/UICommon/DiscordPresence.h
@@ -44,5 +44,5 @@ void UpdateDiscordPresence(int party_size = 0, SecretType type = SecretType::Emp
const bool reset_timer = false);
std::string CreateSecretFromIPAddress(const std::string& ip_address, int port);
void Shutdown();
-void SetDiscordPresenceEnabled(bool enabled);
+void SetDiscordPresence();
} // namespace Discord