mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-27 05:07:51 -05:00
Merge pull request #8522 from lat9nq/consolidate-settings
settings: Consolidate RangedSetting's with regular ones
This commit is contained in:
@ -133,7 +133,7 @@ void Config::Initialize(const std::string& config_name) {
|
||||
// Explicit std::string definition: Qt can't implicitly convert a std::string to a QVariant, nor
|
||||
// can it implicitly convert a QVariant back to a {std::,Q}string
|
||||
template <>
|
||||
void Config::ReadBasicSetting(Settings::BasicSetting<std::string>& setting) {
|
||||
void Config::ReadBasicSetting(Settings::Setting<std::string>& setting) {
|
||||
const QString name = QString::fromStdString(setting.GetLabel());
|
||||
const auto default_value = QString::fromStdString(setting.GetDefault());
|
||||
if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) {
|
||||
@ -144,7 +144,7 @@ void Config::ReadBasicSetting(Settings::BasicSetting<std::string>& setting) {
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
void Config::ReadBasicSetting(Settings::BasicSetting<Type>& setting) {
|
||||
void Config::ReadBasicSetting(Settings::Setting<Type>& setting) {
|
||||
const QString name = QString::fromStdString(setting.GetLabel());
|
||||
const Type default_value = setting.GetDefault();
|
||||
if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) {
|
||||
@ -157,7 +157,7 @@ void Config::ReadBasicSetting(Settings::BasicSetting<Type>& setting) {
|
||||
|
||||
// Explicit std::string definition: Qt can't implicitly convert a std::string to a QVariant
|
||||
template <>
|
||||
void Config::WriteBasicSetting(const Settings::BasicSetting<std::string>& setting) {
|
||||
void Config::WriteBasicSetting(const Settings::Setting<std::string>& setting) {
|
||||
const QString name = QString::fromStdString(setting.GetLabel());
|
||||
const std::string& value = setting.GetValue();
|
||||
qt_config->setValue(name + QStringLiteral("/default"), value == setting.GetDefault());
|
||||
@ -165,7 +165,7 @@ void Config::WriteBasicSetting(const Settings::BasicSetting<std::string>& settin
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
void Config::WriteBasicSetting(const Settings::BasicSetting<Type>& setting) {
|
||||
void Config::WriteBasicSetting(const Settings::Setting<Type>& setting) {
|
||||
const QString name = QString::fromStdString(setting.GetLabel());
|
||||
const Type value = setting.GetValue();
|
||||
qt_config->setValue(name + QStringLiteral("/default"), value == setting.GetDefault());
|
||||
@ -173,7 +173,7 @@ void Config::WriteBasicSetting(const Settings::BasicSetting<Type>& setting) {
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
void Config::WriteGlobalSetting(const Settings::Setting<Type>& setting) {
|
||||
void Config::WriteGlobalSetting(const Settings::SwitchableSetting<Type>& setting) {
|
||||
const QString name = QString::fromStdString(setting.GetLabel());
|
||||
const Type& value = setting.GetValue(global);
|
||||
if (!global) {
|
||||
@ -1422,7 +1422,7 @@ QVariant Config::ReadSetting(const QString& name, const QVariant& default_value)
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
void Config::ReadGlobalSetting(Settings::Setting<Type>& setting) {
|
||||
void Config::ReadGlobalSetting(Settings::SwitchableSetting<Type>& setting) {
|
||||
QString name = QString::fromStdString(setting.GetLabel());
|
||||
const bool use_global = qt_config->value(name + QStringLiteral("/use_global"), true).toBool();
|
||||
setting.SetGlobal(use_global);
|
||||
|
@ -160,7 +160,7 @@ private:
|
||||
* @param The setting
|
||||
*/
|
||||
template <typename Type>
|
||||
void ReadGlobalSetting(Settings::Setting<Type>& setting);
|
||||
void ReadGlobalSetting(Settings::SwitchableSetting<Type>& setting);
|
||||
|
||||
/**
|
||||
* Sets a value to the qt_config using the setting's label and default value. If the config is a
|
||||
@ -169,7 +169,7 @@ private:
|
||||
* @param The setting
|
||||
*/
|
||||
template <typename Type>
|
||||
void WriteGlobalSetting(const Settings::Setting<Type>& setting);
|
||||
void WriteGlobalSetting(const Settings::SwitchableSetting<Type>& setting);
|
||||
|
||||
/**
|
||||
* Reads a value from the qt_config using the setting's label and default value and applies the
|
||||
@ -178,14 +178,14 @@ private:
|
||||
* @param The setting
|
||||
*/
|
||||
template <typename Type>
|
||||
void ReadBasicSetting(Settings::BasicSetting<Type>& setting);
|
||||
void ReadBasicSetting(Settings::Setting<Type>& setting);
|
||||
|
||||
/** Sets a value from the setting in the qt_config using the setting's label and default value.
|
||||
*
|
||||
* @param The setting
|
||||
*/
|
||||
template <typename Type>
|
||||
void WriteBasicSetting(const Settings::BasicSetting<Type>& setting);
|
||||
void WriteBasicSetting(const Settings::Setting<Type>& setting);
|
||||
|
||||
ConfigType type;
|
||||
std::unique_ptr<QSettings> qt_config;
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "yuzu/configuration/configuration_shared.h"
|
||||
#include "yuzu/configuration/configure_per_game.h"
|
||||
|
||||
void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting,
|
||||
void ConfigurationShared::ApplyPerGameSetting(Settings::SwitchableSetting<bool>* setting,
|
||||
const QCheckBox* checkbox,
|
||||
const CheckState& tracker) {
|
||||
if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) {
|
||||
@ -25,7 +25,7 @@ void ConfigurationShared::ApplyPerGameSetting(Settings::Setting<bool>* setting,
|
||||
}
|
||||
|
||||
void ConfigurationShared::SetPerGameSetting(QCheckBox* checkbox,
|
||||
const Settings::Setting<bool>* setting) {
|
||||
const Settings::SwitchableSetting<bool>* setting) {
|
||||
if (setting->UsingGlobal()) {
|
||||
checkbox->setCheckState(Qt::PartiallyChecked);
|
||||
} else {
|
||||
@ -45,7 +45,7 @@ void ConfigurationShared::SetHighlight(QWidget* widget, bool highlighted) {
|
||||
}
|
||||
|
||||
void ConfigurationShared::SetColoredTristate(QCheckBox* checkbox,
|
||||
const Settings::Setting<bool>& setting,
|
||||
const Settings::SwitchableSetting<bool>& setting,
|
||||
CheckState& tracker) {
|
||||
if (setting.UsingGlobal()) {
|
||||
tracker = CheckState::Global;
|
||||
|
@ -25,10 +25,10 @@ enum class CheckState {
|
||||
// Global-aware apply and set functions
|
||||
|
||||
// ApplyPerGameSetting, given a Settings::Setting and a Qt UI element, properly applies a Setting
|
||||
void ApplyPerGameSetting(Settings::Setting<bool>* setting, const QCheckBox* checkbox,
|
||||
void ApplyPerGameSetting(Settings::SwitchableSetting<bool>* setting, const QCheckBox* checkbox,
|
||||
const CheckState& tracker);
|
||||
template <typename Type>
|
||||
void ApplyPerGameSetting(Settings::Setting<Type>* setting, const QComboBox* combobox) {
|
||||
void ApplyPerGameSetting(Settings::SwitchableSetting<Type>* setting, const QComboBox* combobox) {
|
||||
if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) {
|
||||
setting->SetValue(static_cast<Type>(combobox->currentIndex()));
|
||||
} else if (!Settings::IsConfiguringGlobal()) {
|
||||
@ -43,10 +43,10 @@ void ApplyPerGameSetting(Settings::Setting<Type>* setting, const QComboBox* comb
|
||||
}
|
||||
|
||||
// Sets a Qt UI element given a Settings::Setting
|
||||
void SetPerGameSetting(QCheckBox* checkbox, const Settings::Setting<bool>* setting);
|
||||
void SetPerGameSetting(QCheckBox* checkbox, const Settings::SwitchableSetting<bool>* setting);
|
||||
|
||||
template <typename Type>
|
||||
void SetPerGameSetting(QComboBox* combobox, const Settings::Setting<Type>* setting) {
|
||||
void SetPerGameSetting(QComboBox* combobox, const Settings::SwitchableSetting<Type>* setting) {
|
||||
combobox->setCurrentIndex(setting->UsingGlobal() ? ConfigurationShared::USE_GLOBAL_INDEX
|
||||
: static_cast<int>(setting->GetValue()) +
|
||||
ConfigurationShared::USE_GLOBAL_OFFSET);
|
||||
@ -56,7 +56,7 @@ void SetPerGameSetting(QComboBox* combobox, const Settings::Setting<Type>* setti
|
||||
void SetHighlight(QWidget* widget, bool highlighted);
|
||||
|
||||
// Sets up a QCheckBox like a tristate one, given a Setting
|
||||
void SetColoredTristate(QCheckBox* checkbox, const Settings::Setting<bool>& setting,
|
||||
void SetColoredTristate(QCheckBox* checkbox, const Settings::SwitchableSetting<bool>& setting,
|
||||
CheckState& tracker);
|
||||
void SetColoredTristate(QCheckBox* checkbox, bool global, bool state, bool global_state,
|
||||
CheckState& tracker);
|
||||
|
@ -64,28 +64,28 @@ struct Values {
|
||||
QByteArray gamelist_header_state;
|
||||
|
||||
QByteArray microprofile_geometry;
|
||||
Settings::BasicSetting<bool> microprofile_visible{false, "microProfileDialogVisible"};
|
||||
Settings::Setting<bool> microprofile_visible{false, "microProfileDialogVisible"};
|
||||
|
||||
Settings::BasicSetting<bool> single_window_mode{true, "singleWindowMode"};
|
||||
Settings::BasicSetting<bool> fullscreen{false, "fullscreen"};
|
||||
Settings::BasicSetting<bool> display_titlebar{true, "displayTitleBars"};
|
||||
Settings::BasicSetting<bool> show_filter_bar{true, "showFilterBar"};
|
||||
Settings::BasicSetting<bool> show_status_bar{true, "showStatusBar"};
|
||||
Settings::Setting<bool> single_window_mode{true, "singleWindowMode"};
|
||||
Settings::Setting<bool> fullscreen{false, "fullscreen"};
|
||||
Settings::Setting<bool> display_titlebar{true, "displayTitleBars"};
|
||||
Settings::Setting<bool> show_filter_bar{true, "showFilterBar"};
|
||||
Settings::Setting<bool> show_status_bar{true, "showStatusBar"};
|
||||
|
||||
Settings::BasicSetting<bool> confirm_before_closing{true, "confirmClose"};
|
||||
Settings::BasicSetting<bool> first_start{true, "firstStart"};
|
||||
Settings::BasicSetting<bool> pause_when_in_background{false, "pauseWhenInBackground"};
|
||||
Settings::BasicSetting<bool> mute_when_in_background{false, "muteWhenInBackground"};
|
||||
Settings::BasicSetting<bool> hide_mouse{true, "hideInactiveMouse"};
|
||||
Settings::Setting<bool> confirm_before_closing{true, "confirmClose"};
|
||||
Settings::Setting<bool> first_start{true, "firstStart"};
|
||||
Settings::Setting<bool> pause_when_in_background{false, "pauseWhenInBackground"};
|
||||
Settings::Setting<bool> mute_when_in_background{false, "muteWhenInBackground"};
|
||||
Settings::Setting<bool> hide_mouse{true, "hideInactiveMouse"};
|
||||
// Set when Vulkan is known to crash the application
|
||||
Settings::BasicSetting<bool> has_broken_vulkan{false, "has_broken_vulkan"};
|
||||
Settings::Setting<bool> has_broken_vulkan{false, "has_broken_vulkan"};
|
||||
|
||||
Settings::BasicSetting<bool> select_user_on_boot{false, "select_user_on_boot"};
|
||||
Settings::Setting<bool> select_user_on_boot{false, "select_user_on_boot"};
|
||||
|
||||
// Discord RPC
|
||||
Settings::BasicSetting<bool> enable_discord_presence{true, "enable_discord_presence"};
|
||||
Settings::Setting<bool> enable_discord_presence{true, "enable_discord_presence"};
|
||||
|
||||
Settings::BasicSetting<bool> enable_screenshot_save_as{true, "enable_screenshot_save_as"};
|
||||
Settings::Setting<bool> enable_screenshot_save_as{true, "enable_screenshot_save_as"};
|
||||
|
||||
QString roms_path;
|
||||
QString symbols_path;
|
||||
@ -100,25 +100,25 @@ struct Values {
|
||||
// Shortcut name <Shortcut, context>
|
||||
std::vector<Shortcut> shortcuts;
|
||||
|
||||
Settings::BasicSetting<uint32_t> callout_flags{0, "calloutFlags"};
|
||||
Settings::Setting<uint32_t> callout_flags{0, "calloutFlags"};
|
||||
|
||||
// logging
|
||||
Settings::BasicSetting<bool> show_console{false, "showConsole"};
|
||||
Settings::Setting<bool> show_console{false, "showConsole"};
|
||||
|
||||
// Game List
|
||||
Settings::BasicSetting<bool> show_add_ons{true, "show_add_ons"};
|
||||
Settings::BasicSetting<uint32_t> game_icon_size{64, "game_icon_size"};
|
||||
Settings::BasicSetting<uint32_t> folder_icon_size{48, "folder_icon_size"};
|
||||
Settings::BasicSetting<uint8_t> row_1_text_id{3, "row_1_text_id"};
|
||||
Settings::BasicSetting<uint8_t> row_2_text_id{2, "row_2_text_id"};
|
||||
Settings::Setting<bool> show_add_ons{true, "show_add_ons"};
|
||||
Settings::Setting<uint32_t> game_icon_size{64, "game_icon_size"};
|
||||
Settings::Setting<uint32_t> folder_icon_size{48, "folder_icon_size"};
|
||||
Settings::Setting<uint8_t> row_1_text_id{3, "row_1_text_id"};
|
||||
Settings::Setting<uint8_t> row_2_text_id{2, "row_2_text_id"};
|
||||
std::atomic_bool is_game_list_reload_pending{false};
|
||||
Settings::BasicSetting<bool> cache_game_list{true, "cache_game_list"};
|
||||
Settings::BasicSetting<bool> favorites_expanded{true, "favorites_expanded"};
|
||||
Settings::Setting<bool> cache_game_list{true, "cache_game_list"};
|
||||
Settings::Setting<bool> favorites_expanded{true, "favorites_expanded"};
|
||||
QVector<u64> favorited_ids;
|
||||
|
||||
bool configuration_applied;
|
||||
bool reset_to_defaults;
|
||||
Settings::BasicSetting<bool> disable_web_applet{true, "disable_web_applet"};
|
||||
Settings::Setting<bool> disable_web_applet{true, "disable_web_applet"};
|
||||
};
|
||||
|
||||
extern Values values;
|
||||
|
Reference in New Issue
Block a user