mirror of https://git.suyu.dev/suyu/suyu
settings,configuration: Add a default suffix
This commit is contained in:
parent
9de50d6194
commit
926f3e3d3e
|
@ -137,8 +137,15 @@ struct Values {
|
||||||
SwitchableSetting<AudioMode, true> sound_index{linkage, AudioMode::Stereo,
|
SwitchableSetting<AudioMode, true> sound_index{linkage, AudioMode::Stereo,
|
||||||
AudioMode::Mono, AudioMode::Surround,
|
AudioMode::Mono, AudioMode::Surround,
|
||||||
"sound_index", Category::SystemAudio};
|
"sound_index", Category::SystemAudio};
|
||||||
SwitchableSetting<u8, true> volume{
|
SwitchableSetting<u8, true> volume{linkage,
|
||||||
linkage, 100, 0, 200, "volume", Category::Audio, Specialization::Scalar, true, true};
|
100,
|
||||||
|
0,
|
||||||
|
200,
|
||||||
|
"volume",
|
||||||
|
Category::Audio,
|
||||||
|
Specialization::Scalar | Specialization::Percentage,
|
||||||
|
true,
|
||||||
|
true};
|
||||||
Setting<bool, false> audio_muted{
|
Setting<bool, false> audio_muted{
|
||||||
linkage, false, "audio_muted", Category::Audio, Specialization::Default, false};
|
linkage, false, "audio_muted", Category::Audio, Specialization::Default, false};
|
||||||
Setting<bool, false> dump_audio_commands{
|
Setting<bool, false> dump_audio_commands{
|
||||||
|
@ -156,7 +163,7 @@ struct Values {
|
||||||
9999,
|
9999,
|
||||||
"speed_limit",
|
"speed_limit",
|
||||||
Category::Core,
|
Category::Core,
|
||||||
Specialization::Countable,
|
Specialization::Countable | Specialization::Percentage,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
&use_speed_limit};
|
&use_speed_limit};
|
||||||
|
@ -268,9 +275,16 @@ struct Values {
|
||||||
Specialization::Default,
|
Specialization::Default,
|
||||||
true,
|
true,
|
||||||
true};
|
true};
|
||||||
SwitchableSetting<int, true> fsr_sharpening_slider{
|
SwitchableSetting<int, true> fsr_sharpening_slider{linkage,
|
||||||
linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer, Specialization::Scalar,
|
25,
|
||||||
true, true};
|
0,
|
||||||
|
200,
|
||||||
|
"fsr_sharpening_slider",
|
||||||
|
Category::Renderer,
|
||||||
|
Specialization::Scalar |
|
||||||
|
Specialization::Percentage,
|
||||||
|
true,
|
||||||
|
true};
|
||||||
|
|
||||||
SwitchableSetting<u8, false> bg_red{
|
SwitchableSetting<u8, false> bg_red{
|
||||||
linkage, 0, "bg_red", Category::Renderer, Specialization::Default, true, true};
|
linkage, 0, "bg_red", Category::Renderer, Specialization::Default, true, true};
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
|
|
||||||
BasicSetting::BasicSetting(Linkage& linkage, const std::string& name, enum Category category_,
|
BasicSetting::BasicSetting(Linkage& linkage, const std::string& name, enum Category category_,
|
||||||
bool save_, bool runtime_modifiable_,
|
bool save_, bool runtime_modifiable_, u32 specialization_,
|
||||||
enum Specialization specialization_, BasicSetting* other_setting_)
|
BasicSetting* other_setting_)
|
||||||
: label{name}, category{category_}, id{linkage.count}, save{save_},
|
: label{name}, category{category_}, id{linkage.count}, save{save_},
|
||||||
runtime_modifiable{runtime_modifiable_}, specialization{specialization_},
|
runtime_modifiable{runtime_modifiable_}, specialization{specialization_},
|
||||||
other_setting{other_setting_} {
|
other_setting{other_setting_} {
|
||||||
|
@ -40,7 +40,7 @@ Category BasicSetting::Category() const {
|
||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
|
|
||||||
Specialization BasicSetting::Specialization() const {
|
u32 BasicSetting::Specialization() const {
|
||||||
return specialization;
|
return specialization;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,15 +43,21 @@ enum class Category : u32 {
|
||||||
MaxEnum,
|
MaxEnum,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Specialization : u32 {
|
constexpr u8 SpecializationTypeMask = 0xf;
|
||||||
Default,
|
constexpr u8 SpecializationAttributeMask = 0xf0;
|
||||||
Time,
|
constexpr u8 SpecializationAttributeOffset = 4;
|
||||||
Hex,
|
|
||||||
List,
|
enum Specialization : u8 {
|
||||||
RuntimeList,
|
Default = 0,
|
||||||
Scalar,
|
Time = 1,
|
||||||
Countable,
|
Hex = 2,
|
||||||
Paired,
|
List = 3,
|
||||||
|
RuntimeList = 4,
|
||||||
|
Scalar = 5,
|
||||||
|
Countable = 6,
|
||||||
|
Paired = 7,
|
||||||
|
|
||||||
|
Percentage = (1 << SpecializationAttributeOffset),
|
||||||
};
|
};
|
||||||
|
|
||||||
bool IsConfiguringGlobal();
|
bool IsConfiguringGlobal();
|
||||||
|
@ -75,7 +81,7 @@ public:
|
||||||
class BasicSetting {
|
class BasicSetting {
|
||||||
protected:
|
protected:
|
||||||
explicit BasicSetting(Linkage& linkage, const std::string& name, enum Category category_,
|
explicit BasicSetting(Linkage& linkage, const std::string& name, enum Category category_,
|
||||||
bool save_, bool runtime_modifiable_, Specialization spec,
|
bool save_, bool runtime_modifiable_, u32 specialization,
|
||||||
BasicSetting* other_setting);
|
BasicSetting* other_setting);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -195,7 +201,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @returns Extra metadata for data representation in frontend implementations.
|
* @returns Extra metadata for data representation in frontend implementations.
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] enum Specialization Specialization() const;
|
[[nodiscard]] u32 Specialization() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns Another BasicSetting if one is paired, or nullptr otherwise.
|
* @returns Another BasicSetting if one is paired, or nullptr otherwise.
|
||||||
|
@ -240,9 +246,8 @@ private:
|
||||||
const u32 id; ///< Unique integer for the setting
|
const u32 id; ///< Unique integer for the setting
|
||||||
const bool save; ///< Suggests if the setting should be saved and read to a frontend config
|
const bool save; ///< Suggests if the setting should be saved and read to a frontend config
|
||||||
const bool
|
const bool
|
||||||
runtime_modifiable; ///< Suggests if the setting can be modified while a guest is running
|
runtime_modifiable; ///< Suggests if the setting can be modified while a guest is running
|
||||||
const enum Specialization
|
const u32 specialization; ///< Extra data to identify representation of a setting
|
||||||
specialization; ///< Extra data to identify representation of a setting
|
|
||||||
BasicSetting* const other_setting; ///< A paired setting
|
BasicSetting* const other_setting; ///< A paired setting
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,7 @@ public:
|
||||||
* @param category_ Category of the setting AKA INI group
|
* @param category_ Category of the setting AKA INI group
|
||||||
*/
|
*/
|
||||||
explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name,
|
explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name,
|
||||||
enum Category category_,
|
enum Category category_, u32 specialization = Specialization::Default,
|
||||||
enum Specialization specialization = Specialization::Default,
|
|
||||||
bool save_ = true, bool runtime_modifiable_ = false,
|
bool save_ = true, bool runtime_modifiable_ = false,
|
||||||
BasicSetting* other_setting = nullptr)
|
BasicSetting* other_setting = nullptr)
|
||||||
requires(!ranged)
|
requires(!ranged)
|
||||||
|
@ -57,9 +56,8 @@ public:
|
||||||
*/
|
*/
|
||||||
explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val,
|
explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val,
|
||||||
const Type& max_val, const std::string& name, enum Category category_,
|
const Type& max_val, const std::string& name, enum Category category_,
|
||||||
enum Specialization specialization = Specialization::Default,
|
u32 specialization = Specialization::Default, bool save_ = true,
|
||||||
bool save_ = true, bool runtime_modifiable_ = false,
|
bool runtime_modifiable_ = false, BasicSetting* other_setting = nullptr)
|
||||||
BasicSetting* other_setting = nullptr)
|
|
||||||
requires(ranged)
|
requires(ranged)
|
||||||
: BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization,
|
: BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization,
|
||||||
other_setting),
|
other_setting),
|
||||||
|
@ -237,8 +235,7 @@ public:
|
||||||
* @param category_ Category of the setting AKA INI group
|
* @param category_ Category of the setting AKA INI group
|
||||||
*/
|
*/
|
||||||
explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name,
|
explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name,
|
||||||
Category category_,
|
Category category_, u32 specialization = Specialization::Default,
|
||||||
enum Specialization specialization = Specialization::Default,
|
|
||||||
bool save_ = true, bool runtime_modifiable_ = false,
|
bool save_ = true, bool runtime_modifiable_ = false,
|
||||||
BasicSetting* other_setting = nullptr)
|
BasicSetting* other_setting = nullptr)
|
||||||
requires(!ranged)
|
requires(!ranged)
|
||||||
|
@ -261,8 +258,8 @@ public:
|
||||||
*/
|
*/
|
||||||
explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val,
|
explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val,
|
||||||
const Type& max_val, const std::string& name, Category category_,
|
const Type& max_val, const std::string& name, Category category_,
|
||||||
enum Specialization specialization = Specialization::Default,
|
u32 specialization = Specialization::Default, bool save_ = true,
|
||||||
bool save_ = true, bool runtime_modifiable_ = false,
|
bool runtime_modifiable_ = false,
|
||||||
BasicSetting* other_setting = nullptr)
|
BasicSetting* other_setting = nullptr)
|
||||||
requires(ranged)
|
requires(ranged)
|
||||||
: Setting<Type, true>{
|
: Setting<Type, true>{
|
||||||
|
|
|
@ -43,17 +43,7 @@ void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) {
|
||||||
push(Settings::Category::SystemAudio);
|
push(Settings::Category::SystemAudio);
|
||||||
|
|
||||||
for (auto* setting : settings) {
|
for (auto* setting : settings) {
|
||||||
auto* widget = [&]() {
|
auto* widget = builder.BuildWidget(setting, apply_funcs);
|
||||||
// TODO (lat9nq): Let the system manage sink_id
|
|
||||||
if (setting->Id() == Settings::values.volume.Id()) {
|
|
||||||
// volume needs to be a slider (default is line edit)
|
|
||||||
return builder.BuildWidget(setting, apply_funcs, nullptr,
|
|
||||||
ConfigurationShared::RequestType::Slider,
|
|
||||||
tr("%1%", "Volume percentage (e.g. 50%)"));
|
|
||||||
} else {
|
|
||||||
return builder.BuildWidget(setting, apply_funcs);
|
|
||||||
}
|
|
||||||
}();
|
|
||||||
|
|
||||||
if (widget == nullptr) {
|
if (widget == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -66,6 +56,7 @@ void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) {
|
||||||
layout.addWidget(widget);
|
layout.addWidget(widget);
|
||||||
|
|
||||||
if (setting->Id() == Settings::values.sink_id.Id()) {
|
if (setting->Id() == Settings::values.sink_id.Id()) {
|
||||||
|
// TODO (lat9nq): Let the system manage sink_id
|
||||||
sink_combo_box = widget->combobox;
|
sink_combo_box = widget->combobox;
|
||||||
InitializeAudioSinkComboBox();
|
InitializeAudioSinkComboBox();
|
||||||
|
|
||||||
|
|
|
@ -232,10 +232,10 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
|
||||||
for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) {
|
for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) {
|
||||||
ConfigurationShared::Widget* widget = [&]() {
|
ConfigurationShared::Widget* widget = [&]() {
|
||||||
if (setting->Id() == Settings::values.fsr_sharpening_slider.Id()) {
|
if (setting->Id() == Settings::values.fsr_sharpening_slider.Id()) {
|
||||||
// FSR needs a reversed slider
|
// FSR needs a reversed slider and a 0.5 multiplier
|
||||||
return builder.BuildWidget(
|
return builder.BuildWidget(
|
||||||
setting, apply_funcs, ConfigurationShared::RequestType::ReverseSlider, true,
|
setting, apply_funcs, ConfigurationShared::RequestType::ReverseSlider, true,
|
||||||
0.5f, nullptr, tr("%1%", "FSR sharpening percentage (e.g. 50%)"));
|
0.5f, nullptr, tr("%", "FSR sharpening percentage (e.g. 50%)"));
|
||||||
} else {
|
} else {
|
||||||
return builder.BuildWidget(setting, apply_funcs);
|
return builder.BuildWidget(setting, apply_funcs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,16 +106,7 @@ void ConfigureSystem::Setup(const ConfigurationShared::Builder& builder) {
|
||||||
push(Settings::values.linkage.by_category[Settings::Category::System]);
|
push(Settings::values.linkage.by_category[Settings::Category::System]);
|
||||||
|
|
||||||
for (auto setting : settings) {
|
for (auto setting : settings) {
|
||||||
ConfigurationShared::Widget* widget = [this, setting, &builder]() {
|
ConfigurationShared::Widget* widget = builder.BuildWidget(setting, apply_funcs);
|
||||||
if (setting->Id() == Settings::values.speed_limit.Id()) {
|
|
||||||
// speed_limit must be specified to translate the percentage
|
|
||||||
return builder.BuildWidget(setting, apply_funcs, &Settings::values.use_speed_limit,
|
|
||||||
ConfigurationShared::RequestType::SpinBox,
|
|
||||||
tr("%", "Limit speed percentage (e.g. 50%)"));
|
|
||||||
} else {
|
|
||||||
return builder.BuildWidget(setting, apply_funcs);
|
|
||||||
}
|
|
||||||
}();
|
|
||||||
|
|
||||||
if (widget == nullptr) {
|
if (widget == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -50,6 +50,20 @@ static std::string RelevantDefault(const Settings::BasicSetting& setting) {
|
||||||
return Settings::IsConfiguringGlobal() ? setting.DefaultToString() : setting.ToStringGlobal();
|
return Settings::IsConfiguringGlobal() ? setting.DefaultToString() : setting.ToStringGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString DefaultSuffix(QWidget* parent, Settings::BasicSetting& setting) {
|
||||||
|
const auto tr = [parent](const char* text, const char* context) {
|
||||||
|
return parent->tr(text, context);
|
||||||
|
};
|
||||||
|
|
||||||
|
if ((setting.Specialization() & Settings::SpecializationAttributeMask) ==
|
||||||
|
Settings::Specialization::Percentage) {
|
||||||
|
std::string context{fmt::format("{} percentage (e.g. 50%)", setting.GetLabel())};
|
||||||
|
return tr("%", context.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return QStringLiteral("");
|
||||||
|
}
|
||||||
|
|
||||||
QPushButton* Widget::CreateRestoreGlobalButton(bool using_global, QWidget* parent) {
|
QPushButton* Widget::CreateRestoreGlobalButton(bool using_global, QWidget* parent) {
|
||||||
restore_button_count++;
|
restore_button_count++;
|
||||||
|
|
||||||
|
@ -180,7 +194,7 @@ QWidget* Widget::CreateLineEdit(std::function<std::string()>& serializer,
|
||||||
return line_edit;
|
return line_edit;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* Widget::CreateSlider(bool reversed, float multiplier, const QString& format,
|
QWidget* Widget::CreateSlider(bool reversed, float multiplier, const QString& given_suffix,
|
||||||
std::function<std::string()>& serializer,
|
std::function<std::string()>& serializer,
|
||||||
std::function<void()>& restore_func,
|
std::function<void()>& restore_func,
|
||||||
const std::function<void()>& touch) {
|
const std::function<void()>& touch) {
|
||||||
|
@ -205,7 +219,10 @@ QWidget* Widget::CreateSlider(bool reversed, float multiplier, const QString& fo
|
||||||
|
|
||||||
int max_val = std::stoi(setting.MaxVal());
|
int max_val = std::stoi(setting.MaxVal());
|
||||||
|
|
||||||
const QString use_format = format == QStringLiteral("") ? QStringLiteral("%1") : format;
|
QString suffix =
|
||||||
|
given_suffix == QStringLiteral("") ? DefaultSuffix(this, setting) : given_suffix;
|
||||||
|
|
||||||
|
const QString use_format = QStringLiteral("%1").append(suffix);
|
||||||
|
|
||||||
QObject::connect(slider, &QAbstractSlider::valueChanged, [=](int value) {
|
QObject::connect(slider, &QAbstractSlider::valueChanged, [=](int value) {
|
||||||
int present = (reversed ? max_val - value : value) * multiplier + 0.5f;
|
int present = (reversed ? max_val - value : value) * multiplier + 0.5f;
|
||||||
|
@ -228,7 +245,8 @@ QWidget* Widget::CreateSlider(bool reversed, float multiplier, const QString& fo
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* Widget::CreateSpinBox(const QString& suffix, std::function<std::string()>& serializer,
|
QWidget* Widget::CreateSpinBox(const QString& given_suffix,
|
||||||
|
std::function<std::string()>& serializer,
|
||||||
std::function<void()>& restore_func,
|
std::function<void()>& restore_func,
|
||||||
const std::function<void()>& touch) {
|
const std::function<void()>& touch) {
|
||||||
const int min_val =
|
const int min_val =
|
||||||
|
@ -237,6 +255,9 @@ QWidget* Widget::CreateSpinBox(const QString& suffix, std::function<std::string(
|
||||||
setting.Ranged() ? std::stoi(setting.MaxVal()) : std::numeric_limits<int>::max();
|
setting.Ranged() ? std::stoi(setting.MaxVal()) : std::numeric_limits<int>::max();
|
||||||
const int default_val = std::stoi(setting.ToString());
|
const int default_val = std::stoi(setting.ToString());
|
||||||
|
|
||||||
|
QString suffix =
|
||||||
|
given_suffix == QStringLiteral("") ? DefaultSuffix(this, setting) : given_suffix;
|
||||||
|
|
||||||
spinbox = new QSpinBox(this);
|
spinbox = new QSpinBox(this);
|
||||||
spinbox->setRange(min_val, max_val);
|
spinbox->setRange(min_val, max_val);
|
||||||
spinbox->setValue(default_val);
|
spinbox->setValue(default_val);
|
||||||
|
@ -338,7 +359,7 @@ QWidget* Widget::CreateDateTimeEdit(bool disabled, bool restrict,
|
||||||
|
|
||||||
void Widget::SetupComponent(const QString& label, std::function<void()>& load_func, bool managed,
|
void Widget::SetupComponent(const QString& label, std::function<void()>& load_func, bool managed,
|
||||||
RequestType request, float multiplier,
|
RequestType request, float multiplier,
|
||||||
Settings::BasicSetting* other_setting, const QString& string) {
|
Settings::BasicSetting* other_setting, const QString& suffix) {
|
||||||
created = true;
|
created = true;
|
||||||
const auto type = setting.TypeId();
|
const auto type = setting.TypeId();
|
||||||
|
|
||||||
|
@ -391,7 +412,7 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu
|
||||||
if (request != RequestType::Default) {
|
if (request != RequestType::Default) {
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
switch (setting.Specialization()) {
|
switch (setting.Specialization() & Settings::SpecializationTypeMask) {
|
||||||
case Settings::Specialization::Default:
|
case Settings::Specialization::Default:
|
||||||
return RequestType::Default;
|
return RequestType::Default;
|
||||||
case Settings::Specialization::Time:
|
case Settings::Specialization::Time:
|
||||||
|
@ -422,7 +443,7 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu
|
||||||
switch (request) {
|
switch (request) {
|
||||||
case RequestType::Slider:
|
case RequestType::Slider:
|
||||||
case RequestType::ReverseSlider:
|
case RequestType::ReverseSlider:
|
||||||
data_component = CreateSlider(request == RequestType::ReverseSlider, multiplier, string,
|
data_component = CreateSlider(request == RequestType::ReverseSlider, multiplier, suffix,
|
||||||
serializer, restore_func, touch);
|
serializer, restore_func, touch);
|
||||||
break;
|
break;
|
||||||
case RequestType::Default:
|
case RequestType::Default:
|
||||||
|
@ -434,7 +455,7 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu
|
||||||
serializer, restore_func, touch);
|
serializer, restore_func, touch);
|
||||||
break;
|
break;
|
||||||
case RequestType::SpinBox:
|
case RequestType::SpinBox:
|
||||||
data_component = CreateSpinBox(string, serializer, restore_func, touch);
|
data_component = CreateSpinBox(suffix, serializer, restore_func, touch);
|
||||||
break;
|
break;
|
||||||
case RequestType::HexEdit:
|
case RequestType::HexEdit:
|
||||||
data_component = CreateHexEdit(serializer, restore_func, touch);
|
data_component = CreateHexEdit(serializer, restore_func, touch);
|
||||||
|
@ -527,7 +548,7 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati
|
||||||
const ComboboxTranslationMap& combobox_translations_, QWidget* parent_,
|
const ComboboxTranslationMap& combobox_translations_, QWidget* parent_,
|
||||||
bool runtime_lock_, std::forward_list<std::function<void(bool)>>& apply_funcs_,
|
bool runtime_lock_, std::forward_list<std::function<void(bool)>>& apply_funcs_,
|
||||||
RequestType request, bool managed, float multiplier,
|
RequestType request, bool managed, float multiplier,
|
||||||
Settings::BasicSetting* other_setting, const QString& string)
|
Settings::BasicSetting* other_setting, const QString& suffix)
|
||||||
: QWidget(parent_), parent{parent_}, translations{translations_},
|
: QWidget(parent_), parent{parent_}, translations{translations_},
|
||||||
combobox_enumerations{combobox_translations_}, setting{*setting_}, apply_funcs{apply_funcs_},
|
combobox_enumerations{combobox_translations_}, setting{*setting_}, apply_funcs{apply_funcs_},
|
||||||
runtime_lock{runtime_lock_} {
|
runtime_lock{runtime_lock_} {
|
||||||
|
@ -555,7 +576,7 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati
|
||||||
|
|
||||||
std::function<void()> load_func = []() {};
|
std::function<void()> load_func = []() {};
|
||||||
|
|
||||||
SetupComponent(label, load_func, managed, request, multiplier, other_setting, string);
|
SetupComponent(label, load_func, managed, request, multiplier, other_setting, suffix);
|
||||||
|
|
||||||
if (!created) {
|
if (!created) {
|
||||||
LOG_WARNING(Frontend, "No widget was created for \"{}\"", setting.GetLabel());
|
LOG_WARNING(Frontend, "No widget was created for \"{}\"", setting.GetLabel());
|
||||||
|
@ -587,7 +608,7 @@ Builder::~Builder() = default;
|
||||||
Widget* Builder::BuildWidget(Settings::BasicSetting* setting,
|
Widget* Builder::BuildWidget(Settings::BasicSetting* setting,
|
||||||
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
||||||
RequestType request, bool managed, float multiplier,
|
RequestType request, bool managed, float multiplier,
|
||||||
Settings::BasicSetting* other_setting, const QString& string) const {
|
Settings::BasicSetting* other_setting, const QString& suffix) const {
|
||||||
if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) {
|
if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -598,14 +619,14 @@ Widget* Builder::BuildWidget(Settings::BasicSetting* setting,
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Widget(setting, *translations, *combobox_translations, parent, runtime_lock,
|
return new Widget(setting, *translations, *combobox_translations, parent, runtime_lock,
|
||||||
apply_funcs, request, managed, multiplier, other_setting, string);
|
apply_funcs, request, managed, multiplier, other_setting, suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget* Builder::BuildWidget(Settings::BasicSetting* setting,
|
Widget* Builder::BuildWidget(Settings::BasicSetting* setting,
|
||||||
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
||||||
Settings::BasicSetting* other_setting, RequestType request,
|
Settings::BasicSetting* other_setting, RequestType request,
|
||||||
const QString& string) const {
|
const QString& suffix) const {
|
||||||
return BuildWidget(setting, apply_funcs, request, true, 1.0f, other_setting, string);
|
return BuildWidget(setting, apply_funcs, request, true, 1.0f, other_setting, suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ComboboxTranslationMap& Builder::ComboboxTranslations() const {
|
const ComboboxTranslationMap& Builder::ComboboxTranslations() const {
|
||||||
|
|
|
@ -58,14 +58,14 @@ public:
|
||||||
* @param managed Set true if the caller will set up component data and handling
|
* @param managed Set true if the caller will set up component data and handling
|
||||||
* @param multiplier Value to multiply the slider feedback label
|
* @param multiplier Value to multiply the slider feedback label
|
||||||
* @param other_setting Second setting to modify, to replace the label with a checkbox
|
* @param other_setting Second setting to modify, to replace the label with a checkbox
|
||||||
* @param string Set to specify formats for Slider feedback labels or SpinBox
|
* @param suffix Set to specify formats for Slider feedback labels or SpinBox
|
||||||
*/
|
*/
|
||||||
explicit Widget(Settings::BasicSetting* setting, const TranslationMap& translations,
|
explicit Widget(Settings::BasicSetting* setting, const TranslationMap& translations,
|
||||||
const ComboboxTranslationMap& combobox_translations, QWidget* parent,
|
const ComboboxTranslationMap& combobox_translations, QWidget* parent,
|
||||||
bool runtime_lock, std::forward_list<std::function<void(bool)>>& apply_funcs_,
|
bool runtime_lock, std::forward_list<std::function<void(bool)>>& apply_funcs_,
|
||||||
RequestType request = RequestType::Default, bool managed = true,
|
RequestType request = RequestType::Default, bool managed = true,
|
||||||
float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr,
|
float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr,
|
||||||
const QString& string = QStringLiteral(""));
|
const QString& suffix = QStringLiteral(""));
|
||||||
virtual ~Widget();
|
virtual ~Widget();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,7 +95,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void SetupComponent(const QString& label, std::function<void()>& load_func, bool managed,
|
void SetupComponent(const QString& label, std::function<void()>& load_func, bool managed,
|
||||||
RequestType request, float multiplier,
|
RequestType request, float multiplier,
|
||||||
Settings::BasicSetting* other_setting, const QString& string);
|
Settings::BasicSetting* other_setting, const QString& suffix);
|
||||||
|
|
||||||
QLabel* CreateLabel(const QString& text);
|
QLabel* CreateLabel(const QString& text);
|
||||||
QWidget* CreateCheckBox(Settings::BasicSetting* bool_setting, const QString& label,
|
QWidget* CreateCheckBox(Settings::BasicSetting* bool_setting, const QString& label,
|
||||||
|
@ -111,7 +111,7 @@ private:
|
||||||
bool managed = true);
|
bool managed = true);
|
||||||
QWidget* CreateHexEdit(std::function<std::string()>& serializer,
|
QWidget* CreateHexEdit(std::function<std::string()>& serializer,
|
||||||
std::function<void()>& restore_func, const std::function<void()>& touch);
|
std::function<void()>& restore_func, const std::function<void()>& touch);
|
||||||
QWidget* CreateSlider(bool reversed, float multiplier, const QString& format,
|
QWidget* CreateSlider(bool reversed, float multiplier, const QString& suffix,
|
||||||
std::function<std::string()>& serializer,
|
std::function<std::string()>& serializer,
|
||||||
std::function<void()>& restore_func, const std::function<void()>& touch);
|
std::function<void()>& restore_func, const std::function<void()>& touch);
|
||||||
QWidget* CreateDateTimeEdit(bool disabled, bool restrict,
|
QWidget* CreateDateTimeEdit(bool disabled, bool restrict,
|
||||||
|
@ -140,13 +140,13 @@ public:
|
||||||
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
||||||
RequestType request = RequestType::Default, bool managed = true,
|
RequestType request = RequestType::Default, bool managed = true,
|
||||||
float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr,
|
float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr,
|
||||||
const QString& string = QStringLiteral("")) const;
|
const QString& suffix = QStringLiteral("")) const;
|
||||||
|
|
||||||
Widget* BuildWidget(Settings::BasicSetting* setting,
|
Widget* BuildWidget(Settings::BasicSetting* setting,
|
||||||
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
||||||
Settings::BasicSetting* other_setting,
|
Settings::BasicSetting* other_setting,
|
||||||
RequestType request = RequestType::Default,
|
RequestType request = RequestType::Default,
|
||||||
const QString& string = QStringLiteral("")) const;
|
const QString& suffix = QStringLiteral("")) const;
|
||||||
|
|
||||||
const ComboboxTranslationMap& ComboboxTranslations() const;
|
const ComboboxTranslationMap& ComboboxTranslations() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue