mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-11-18 09:46:19 -06:00
Merge pull request #14276 from JoshuaVandaele/mo-config-controls
Use more ConfigControls
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user