mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-21 17:03:25 +02:00
shared_widget: Refactor helpers
Makes checkbox creation an option as opposed to a label.
This commit is contained in:
parent
4c4bc134a9
commit
4ff8255e4a
@ -165,6 +165,11 @@ void ConfigureGraphics::PopulateVSyncModeSelection() {
|
|||||||
: vsync_mode_combobox_enum_map[current_index];
|
: vsync_mode_combobox_enum_map[current_index];
|
||||||
int index{};
|
int index{};
|
||||||
const int device{vulkan_device_combobox->currentIndex()}; //< current selected Vulkan device
|
const int device{vulkan_device_combobox->currentIndex()}; //< current selected Vulkan device
|
||||||
|
if (device == -1) {
|
||||||
|
// Invalid device
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto& present_modes = //< relevant vector of present modes for the selected device or API
|
const auto& present_modes = //< relevant vector of present modes for the selected device or API
|
||||||
backend == Settings::RendererBackend::Vulkan ? device_present_modes[device]
|
backend == Settings::RendererBackend::Vulkan ? device_present_modes[device]
|
||||||
: default_present_modes;
|
: default_present_modes;
|
||||||
@ -236,11 +241,11 @@ void ConfigureGraphics::Setup() {
|
|||||||
return new ConfigurationShared::Widget(
|
return new ConfigurationShared::Widget(
|
||||||
setting, translations, this, runtime_lock, apply_funcs,
|
setting, translations, this, runtime_lock, apply_funcs,
|
||||||
ConfigurationShared::RequestType::ReverseSlider, true, 0.5f);
|
ConfigurationShared::RequestType::ReverseSlider, true, 0.5f);
|
||||||
} else if (setting->Id() == Settings::values.use_speed_limit.Id()) {
|
} else if (setting->Id() == Settings::values.speed_limit.Id()) {
|
||||||
return new ConfigurationShared::Widget(
|
return new ConfigurationShared::Widget(
|
||||||
setting, translations, this, runtime_lock, apply_funcs,
|
setting, translations, this, runtime_lock, apply_funcs,
|
||||||
ConfigurationShared::RequestType::SpinBox, true, 1.0f,
|
ConfigurationShared::RequestType::SpinBox, true, 1.0f,
|
||||||
&Settings::values.speed_limit, "%");
|
&Settings::values.use_speed_limit, "%");
|
||||||
} else {
|
} else {
|
||||||
return new ConfigurationShared::Widget(setting, translations, this, runtime_lock,
|
return new ConfigurationShared::Widget(setting, translations, this, runtime_lock,
|
||||||
apply_funcs);
|
apply_funcs);
|
||||||
|
@ -77,8 +77,8 @@ private:
|
|||||||
std::vector<QString> vulkan_devices;
|
std::vector<QString> vulkan_devices;
|
||||||
std::vector<std::vector<VkPresentModeKHR>> device_present_modes;
|
std::vector<std::vector<VkPresentModeKHR>> device_present_modes;
|
||||||
std::vector<VkPresentModeKHR>
|
std::vector<VkPresentModeKHR>
|
||||||
vsync_mode_combobox_enum_map; //< Keeps track of which present mode corresponds to which
|
vsync_mode_combobox_enum_map{}; //< Keeps track of which present mode corresponds to which
|
||||||
// selection in the combobox
|
// selection in the combobox
|
||||||
u32 vulkan_device{};
|
u32 vulkan_device{};
|
||||||
Settings::ShaderBackend shader_backend{};
|
Settings::ShaderBackend shader_backend{};
|
||||||
const std::function<void()>& expose_compute_option;
|
const std::function<void()>& expose_compute_option;
|
||||||
|
@ -117,17 +117,18 @@ void ConfigureSystem::Setup() {
|
|||||||
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) {
|
||||||
|
[[maybe_unused]] std::string label = setting->GetLabel();
|
||||||
ConfigurationShared::Widget* widget = [=]() {
|
ConfigurationShared::Widget* widget = [=]() {
|
||||||
if (setting->Id() == Settings::values.custom_rtc_enabled.Id()) {
|
if (setting->Id() == Settings::values.custom_rtc.Id()) {
|
||||||
return new ConfigurationShared::Widget(
|
return new ConfigurationShared::Widget(
|
||||||
setting, translations, this, runtime_lock, apply_funcs,
|
setting, translations, this, runtime_lock, apply_funcs,
|
||||||
ConfigurationShared::RequestType::DateTimeEdit, true, 1.0f,
|
ConfigurationShared::RequestType::DateTimeEdit, true, 1.0f,
|
||||||
&Settings::values.custom_rtc);
|
&Settings::values.custom_rtc_enabled);
|
||||||
} else if (setting->Id() == Settings::values.rng_seed_enabled.Id()) {
|
} else if (setting->Id() == Settings::values.rng_seed.Id()) {
|
||||||
return new ConfigurationShared::Widget(setting, translations, this, runtime_lock,
|
return new ConfigurationShared::Widget(
|
||||||
apply_funcs,
|
setting, translations, this, runtime_lock, apply_funcs,
|
||||||
ConfigurationShared::RequestType::HexEdit,
|
ConfigurationShared::RequestType::HexEdit, true, 1.0f,
|
||||||
true, 1.0f, &Settings::values.rng_seed);
|
&Settings::values.rng_seed_enabled);
|
||||||
} else {
|
} else {
|
||||||
return new ConfigurationShared::Widget(setting, translations, this, runtime_lock,
|
return new ConfigurationShared::Widget(setting, translations, this, runtime_lock,
|
||||||
|
|
||||||
@ -140,14 +141,12 @@ void ConfigureSystem::Setup() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setting->Id() == Settings::values.rng_seed_enabled.Id()) {
|
if (setting->Id() == Settings::values.rng_seed.Id()) {
|
||||||
rng_seed_checkbox = widget->checkbox;
|
rng_seed_checkbox = widget->checkbox;
|
||||||
rng_seed_edit = widget->line_edit;
|
rng_seed_edit = widget->line_edit;
|
||||||
|
|
||||||
if (!Settings::values.rng_seed_enabled.GetValue()) {
|
rng_seed_edit->setEnabled(Settings::values.rng_seed_enabled.GetValue());
|
||||||
rng_seed_edit->setEnabled(false);
|
} else if (setting->Id() == Settings::values.custom_rtc.Id()) {
|
||||||
}
|
|
||||||
} else if (setting->Id() == Settings::values.custom_rtc_enabled.Id()) {
|
|
||||||
custom_rtc_checkbox = widget->checkbox;
|
custom_rtc_checkbox = widget->checkbox;
|
||||||
custom_rtc_edit = widget->date_time_edit;
|
custom_rtc_edit = widget->date_time_edit;
|
||||||
|
|
||||||
|
@ -108,11 +108,11 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
|||||||
INSERT(Settings, speed_limit, "Limit Speed Percent", "");
|
INSERT(Settings, speed_limit, "Limit Speed Percent", "");
|
||||||
|
|
||||||
// System
|
// System
|
||||||
INSERT(Settings, rng_seed_enabled, "RNG Seed", "");
|
INSERT(Settings, rng_seed, "RNG Seed", "");
|
||||||
INSERT(Settings, rng_seed, "", "");
|
INSERT(Settings, rng_seed_enabled, "", "");
|
||||||
INSERT(Settings, device_name, "Device Name", "");
|
INSERT(Settings, device_name, "Device Name", "");
|
||||||
INSERT(Settings, custom_rtc_enabled, "Custom RTC", "");
|
INSERT(Settings, custom_rtc, "Custom RTC", "");
|
||||||
INSERT(Settings, custom_rtc, "", "");
|
INSERT(Settings, custom_rtc_enabled, "", "");
|
||||||
INSERT(Settings, language_index, "Language:", "");
|
INSERT(Settings, language_index, "Language:", "");
|
||||||
INSERT(Settings, region_index, "Region:", "");
|
INSERT(Settings, region_index, "Region:", "");
|
||||||
INSERT(Settings, time_zone_index, "Time Zone:", "");
|
INSERT(Settings, time_zone_index, "Time Zone:", "");
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <qabstractbutton.h>
|
#include <qabstractbutton.h>
|
||||||
#include <qabstractspinbox.h>
|
#include <qabstractspinbox.h>
|
||||||
|
#include <qboxlayout.h>
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
|
#include <qpushbutton.h>
|
||||||
#include <qvalidator.h>
|
#include <qvalidator.h>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
@ -22,10 +24,6 @@
|
|||||||
|
|
||||||
namespace ConfigurationShared {
|
namespace ConfigurationShared {
|
||||||
|
|
||||||
static bool IsInt(const std::type_index& type) {
|
|
||||||
return type == typeid(u32) || type == typeid(s32) || type == typeid(u16) || type == typeid(s16);
|
|
||||||
}
|
|
||||||
|
|
||||||
QPushButton* Widget::CreateRestoreGlobalButton(Settings::BasicSetting& setting, QWidget* parent) {
|
QPushButton* Widget::CreateRestoreGlobalButton(Settings::BasicSetting& setting, QWidget* parent) {
|
||||||
QStyle* style = parent->style();
|
QStyle* style = parent->style();
|
||||||
QIcon* icon = new QIcon(style->standardIcon(QStyle::SP_DialogResetButton));
|
QIcon* icon = new QIcon(style->standardIcon(QStyle::SP_DialogResetButton));
|
||||||
@ -42,50 +40,65 @@ QPushButton* Widget::CreateRestoreGlobalButton(Settings::BasicSetting& setting,
|
|||||||
return restore_button;
|
return restore_button;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::CreateCheckBox(const QString& label, std::function<void()>& load_func) {
|
QLabel* Widget::CreateLabel(const QString& text) {
|
||||||
|
QLabel* qt_label = new QLabel(text, this->parent);
|
||||||
|
qt_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
return qt_label;
|
||||||
|
}
|
||||||
|
|
||||||
|
QHBoxLayout* Widget::CreateCheckBox(Settings::BasicSetting* bool_setting, const QString& label,
|
||||||
|
std::function<void()>& load_func, bool managed) {
|
||||||
created = true;
|
created = true;
|
||||||
|
|
||||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||||
|
|
||||||
checkbox = new QCheckBox(label, this);
|
checkbox = new QCheckBox(label, this);
|
||||||
checkbox->setObjectName(QString::fromStdString(setting.GetLabel()));
|
checkbox->setCheckState(bool_setting->ToString() == "true" ? Qt::CheckState::Checked
|
||||||
checkbox->setCheckState(setting.ToString() == "true" ? Qt::CheckState::Checked
|
: Qt::CheckState::Unchecked);
|
||||||
: Qt::CheckState::Unchecked);
|
checkbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
|
||||||
layout->addWidget(checkbox);
|
layout->addWidget(checkbox);
|
||||||
|
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
if (!managed) {
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
load_func = [=]() {
|
load_func = [=]() {
|
||||||
setting.LoadString(checkbox->checkState() == Qt::Checked ? "true" : "false");
|
bool_setting->LoadString(checkbox->checkState() == Qt::Checked ? "true" : "false");
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
restore_button = CreateRestoreGlobalButton(setting, this);
|
restore_button = CreateRestoreGlobalButton(*bool_setting, this);
|
||||||
layout->addWidget(restore_button);
|
layout->addWidget(restore_button);
|
||||||
|
|
||||||
QObject::connect(checkbox, &QCheckBox::stateChanged, [&](int) {
|
QObject::connect(checkbox, &QCheckBox::stateChanged, [=](int) {
|
||||||
restore_button->setVisible(true);
|
restore_button->setVisible(true);
|
||||||
restore_button->setEnabled(true);
|
restore_button->setEnabled(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(restore_button, &QAbstractButton::clicked, [&](bool) {
|
QObject::connect(restore_button, &QAbstractButton::clicked, [=](bool) {
|
||||||
checkbox->setCheckState(setting.ToStringGlobal() == "true" ? Qt::Checked
|
checkbox->setCheckState(bool_setting->ToStringGlobal() == "true" ? Qt::Checked
|
||||||
: Qt::Unchecked);
|
: Qt::Unchecked);
|
||||||
restore_button->setEnabled(false);
|
restore_button->setEnabled(false);
|
||||||
restore_button->setVisible(false);
|
restore_button->setVisible(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
load_func = [=]() {
|
load_func = [=]() {
|
||||||
bool using_global = !restore_button->isEnabled();
|
bool using_global = !restore_button->isEnabled();
|
||||||
setting.SetGlobal(using_global);
|
bool_setting->SetGlobal(using_global);
|
||||||
if (!using_global) {
|
if (!using_global) {
|
||||||
setting.LoadString(checkbox->checkState() == Qt::Checked ? "true" : "false");
|
bool_setting->LoadString(checkbox->checkState() == Qt::Checked ? "true" : "false");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::CreateCombobox(const QString& label, bool managed, std::function<void()>& load_func) {
|
void Widget::CreateCombobox(const QString& label, std::function<void()>& load_func, bool managed,
|
||||||
|
Settings::BasicSetting* const other_setting) {
|
||||||
created = true;
|
created = true;
|
||||||
|
|
||||||
const auto type = setting.TypeId();
|
const auto type = setting.TypeId();
|
||||||
@ -108,9 +121,13 @@ void Widget::CreateCombobox(const QString& label, bool managed, std::function<vo
|
|||||||
|
|
||||||
combobox->setCurrentIndex(std::stoi(setting.ToString()));
|
combobox->setCurrentIndex(std::stoi(setting.ToString()));
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal() && managed) {
|
if (!managed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
load_func = [=]() { setting.LoadString(std::to_string(combobox->currentIndex())); };
|
load_func = [=]() { setting.LoadString(std::to_string(combobox->currentIndex())); };
|
||||||
} else if (managed) {
|
} else {
|
||||||
restore_button = CreateRestoreGlobalButton(setting, this);
|
restore_button = CreateRestoreGlobalButton(setting, this);
|
||||||
layout->addWidget(restore_button);
|
layout->addWidget(restore_button);
|
||||||
|
|
||||||
@ -136,30 +153,50 @@ void Widget::CreateCombobox(const QString& label, bool managed, std::function<vo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::CreateLineEdit(const QString& label, bool managed, std::function<void()>& load_func) {
|
void Widget::CreateLineEdit(const QString& label, std::function<void()>& load_func, bool managed,
|
||||||
|
Settings::BasicSetting* other_setting) {
|
||||||
|
const bool has_checkbox = other_setting != nullptr;
|
||||||
|
if (has_checkbox && other_setting->TypeId() != typeid(bool)) {
|
||||||
|
LOG_WARNING(Frontend, "Extra setting requested but setting is not boolean");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
created = true;
|
created = true;
|
||||||
|
|
||||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
QHBoxLayout* layout{nullptr};
|
||||||
line_edit = new QLineEdit(this);
|
std::function<void()> checkbox_load_func = []() {};
|
||||||
|
|
||||||
|
if (has_checkbox) {
|
||||||
|
layout = CreateCheckBox(other_setting, label, checkbox_load_func, managed);
|
||||||
|
} else {
|
||||||
|
layout = new QHBoxLayout(this);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
QLabel* q_label = CreateLabel(label);
|
||||||
|
layout->addWidget(q_label);
|
||||||
|
}
|
||||||
|
|
||||||
const QString text = QString::fromStdString(setting.ToString());
|
const QString text = QString::fromStdString(setting.ToString());
|
||||||
|
line_edit = new QLineEdit(this);
|
||||||
line_edit->setText(text);
|
line_edit->setText(text);
|
||||||
|
|
||||||
QLabel* q_label = new QLabel(label, this);
|
|
||||||
// setSizePolicy lets widget expand and take an equal part of the space as the line edit
|
|
||||||
q_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
||||||
layout->addWidget(q_label);
|
|
||||||
|
|
||||||
layout->addWidget(line_edit);
|
layout->addWidget(line_edit);
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal() && !managed) {
|
if (!managed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
load_func = [=]() {
|
load_func = [=]() {
|
||||||
|
checkbox_load_func();
|
||||||
|
|
||||||
std::string load_text = line_edit->text().toStdString();
|
std::string load_text = line_edit->text().toStdString();
|
||||||
setting.LoadString(load_text);
|
setting.LoadString(load_text);
|
||||||
};
|
};
|
||||||
} else if (!managed) {
|
} else {
|
||||||
restore_button = CreateRestoreGlobalButton(setting, this);
|
if (!has_checkbox) {
|
||||||
layout->addWidget(restore_button);
|
restore_button = CreateRestoreGlobalButton(setting, this);
|
||||||
|
layout->addWidget(restore_button);
|
||||||
|
}
|
||||||
|
|
||||||
QObject::connect(restore_button, &QAbstractButton::clicked, [&](bool) {
|
QObject::connect(restore_button, &QAbstractButton::clicked, [&](bool) {
|
||||||
restore_button->setEnabled(false);
|
restore_button->setEnabled(false);
|
||||||
@ -174,6 +211,8 @@ void Widget::CreateLineEdit(const QString& label, bool managed, std::function<vo
|
|||||||
});
|
});
|
||||||
|
|
||||||
load_func = [=]() {
|
load_func = [=]() {
|
||||||
|
checkbox_load_func();
|
||||||
|
|
||||||
bool using_global = !restore_button->isEnabled();
|
bool using_global = !restore_button->isEnabled();
|
||||||
setting.SetGlobal(using_global);
|
setting.SetGlobal(using_global);
|
||||||
if (!using_global) {
|
if (!using_global) {
|
||||||
@ -181,24 +220,23 @@ void Widget::CreateLineEdit(const QString& label, bool managed, std::function<vo
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::CreateSlider(const QString& name, bool reversed, float multiplier,
|
void Widget::CreateSlider(const QString& label, bool reversed, float multiplier,
|
||||||
std::function<void()>& load_func) {
|
std::function<void()>& load_func, bool managed,
|
||||||
|
Settings::BasicSetting* const other_setting) {
|
||||||
created = true;
|
created = true;
|
||||||
|
|
||||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||||
slider = new QSlider(Qt::Horizontal, this);
|
slider = new QSlider(Qt::Horizontal, this);
|
||||||
QLabel* label = new QLabel(name, this);
|
QLabel* qt_label = new QLabel(label, this);
|
||||||
QLabel* feedback = new QLabel(this);
|
QLabel* feedback = new QLabel(this);
|
||||||
|
|
||||||
layout->addWidget(label);
|
layout->addWidget(qt_label);
|
||||||
layout->addWidget(slider);
|
layout->addWidget(slider);
|
||||||
layout->addWidget(feedback);
|
layout->addWidget(feedback);
|
||||||
|
|
||||||
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
qt_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
@ -214,8 +252,10 @@ void Widget::CreateSlider(const QString& name, bool reversed, float multiplier,
|
|||||||
slider->setMinimum(std::stoi(setting.MinVal()));
|
slider->setMinimum(std::stoi(setting.MinVal()));
|
||||||
slider->setMaximum(max_val);
|
slider->setMaximum(max_val);
|
||||||
|
|
||||||
if (reversed) {
|
slider->setInvertedAppearance(reversed);
|
||||||
slider->setInvertedAppearance(true);
|
|
||||||
|
if (!managed) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
@ -246,134 +286,33 @@ void Widget::CreateSlider(const QString& name, bool reversed, float multiplier,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::CreateCheckBoxWithHexEdit(const QString& label, Settings::BasicSetting* other_setting,
|
void Widget::CreateSpinBox(const QString& label, std::function<void()>& load_func, bool managed,
|
||||||
std::function<void()>& load_func) {
|
const std::string& suffix, Settings::BasicSetting* other_setting) {
|
||||||
if (other_setting == nullptr) {
|
const bool has_checkbox = other_setting != nullptr;
|
||||||
LOG_WARNING(Frontend, "Extra setting is null or not an integer");
|
if (has_checkbox && other_setting->TypeId() != typeid(bool)) {
|
||||||
|
LOG_WARNING(Frontend, "Extra setting requested but setting is not boolean");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
created = true;
|
created = true;
|
||||||
|
|
||||||
std::function<void()> checkbox_load_func;
|
QHBoxLayout* layout{nullptr};
|
||||||
CreateCheckBox(label, checkbox_load_func);
|
std::function<void()> checkbox_load_func = []() {};
|
||||||
|
QLabel* q_label{nullptr};
|
||||||
|
|
||||||
auto to_hex = [=](const std::string& input) {
|
if (has_checkbox) {
|
||||||
return QString::fromStdString(fmt::format("{:08x}", std::stoi(input)));
|
layout = CreateCheckBox(other_setting, label, checkbox_load_func, managed);
|
||||||
};
|
|
||||||
|
|
||||||
QHBoxLayout* layout = reinterpret_cast<QHBoxLayout*>(this->layout());
|
|
||||||
const QString default_val = to_hex(other_setting->ToString());
|
|
||||||
|
|
||||||
line_edit = new QLineEdit(this);
|
|
||||||
line_edit->setText(default_val);
|
|
||||||
|
|
||||||
checkbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
||||||
|
|
||||||
layout->insertWidget(1, line_edit);
|
|
||||||
|
|
||||||
line_edit->setMaxLength(8);
|
|
||||||
QRegExpValidator* regex =
|
|
||||||
new QRegExpValidator{QRegExp{QStringLiteral("^[0-9a-fA-F]{0,8}$")}, line_edit};
|
|
||||||
line_edit->setValidator(regex);
|
|
||||||
|
|
||||||
auto hex_to_dec = [=]() -> std::string {
|
|
||||||
return std::to_string(std::stoul(line_edit->text().toStdString(), nullptr, 16));
|
|
||||||
};
|
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
|
||||||
load_func = [=]() {
|
|
||||||
checkbox_load_func();
|
|
||||||
other_setting->LoadString(hex_to_dec());
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
QObject::connect(restore_button, &QAbstractButton::clicked, [=](bool) {
|
layout = new QHBoxLayout(this);
|
||||||
line_edit->setText(to_hex(other_setting->ToStringGlobal()));
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
});
|
q_label = CreateLabel(label);
|
||||||
|
layout->addWidget(q_label);
|
||||||
QObject::connect(line_edit, &QLineEdit::textEdited, [=](const QString&) {
|
|
||||||
restore_button->setEnabled(true);
|
|
||||||
restore_button->setVisible(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
load_func = [=]() {
|
|
||||||
checkbox_load_func();
|
|
||||||
|
|
||||||
const bool using_global = !restore_button->isEnabled();
|
|
||||||
other_setting->SetGlobal(using_global);
|
|
||||||
if (!using_global) {
|
|
||||||
other_setting->LoadString(hex_to_dec());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Widget::CreateCheckBoxWithLineEdit(const QString& label, Settings::BasicSetting* other_setting,
|
const int min_val = std::stoi(setting.MinVal());
|
||||||
std::function<void()>& load_func) {
|
const int max_val = std::stoi(setting.MaxVal());
|
||||||
if (other_setting == nullptr) {
|
const int default_val = std::stoi(setting.ToString());
|
||||||
LOG_WARNING(Frontend, "Extra setting is null or not an integer");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
created = true;
|
|
||||||
|
|
||||||
std::function<void()> checkbox_load_func;
|
|
||||||
CreateCheckBox(label, checkbox_load_func);
|
|
||||||
|
|
||||||
QHBoxLayout* layout = reinterpret_cast<QHBoxLayout*>(this->layout());
|
|
||||||
const QString default_val = QString::fromStdString(other_setting->ToString());
|
|
||||||
|
|
||||||
line_edit = new QLineEdit(this);
|
|
||||||
line_edit->setText(default_val);
|
|
||||||
|
|
||||||
checkbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
||||||
|
|
||||||
layout->insertWidget(1, line_edit);
|
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
|
||||||
load_func = [=]() {
|
|
||||||
checkbox_load_func();
|
|
||||||
other_setting->LoadString(line_edit->text().toStdString());
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
QObject::connect(restore_button, &QAbstractButton::clicked, [=](bool) {
|
|
||||||
line_edit->setText(QString::fromStdString(other_setting->ToStringGlobal()));
|
|
||||||
});
|
|
||||||
|
|
||||||
QObject::connect(line_edit, &QLineEdit::textEdited, [=](const QString&) {
|
|
||||||
restore_button->setEnabled(true);
|
|
||||||
restore_button->setVisible(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
load_func = [=]() {
|
|
||||||
checkbox_load_func();
|
|
||||||
|
|
||||||
const bool using_global = !restore_button->isEnabled();
|
|
||||||
other_setting->SetGlobal(using_global);
|
|
||||||
if (!using_global) {
|
|
||||||
other_setting->LoadString(line_edit->text().toStdString());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Widget::CreateCheckBoxWithSpinBox(const QString& label, Settings::BasicSetting* other_setting,
|
|
||||||
std::function<void()>& load_func,
|
|
||||||
const std::string& suffix) {
|
|
||||||
if (other_setting == nullptr && IsInt(other_setting->TypeId())) {
|
|
||||||
LOG_WARNING(Frontend, "Extra setting is null or not an integer");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
created = true;
|
|
||||||
|
|
||||||
std::function<void()> checkbox_load_func;
|
|
||||||
CreateCheckBox(label, checkbox_load_func);
|
|
||||||
checkbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
||||||
|
|
||||||
QHBoxLayout* layout = reinterpret_cast<QHBoxLayout*>(this->layout());
|
|
||||||
|
|
||||||
spinbox = new QSpinBox(this);
|
spinbox = new QSpinBox(this);
|
||||||
const int min_val = std::stoi(other_setting->MinVal());
|
|
||||||
const int max_val = std::stoi(other_setting->MaxVal());
|
|
||||||
const int default_val = std::stoi(other_setting->ToString());
|
|
||||||
spinbox->setRange(min_val, max_val);
|
spinbox->setRange(min_val, max_val);
|
||||||
spinbox->setValue(default_val);
|
spinbox->setValue(default_val);
|
||||||
spinbox->setSuffix(QString::fromStdString(suffix));
|
spinbox->setSuffix(QString::fromStdString(suffix));
|
||||||
@ -384,12 +323,15 @@ void Widget::CreateCheckBoxWithSpinBox(const QString& label, Settings::BasicSett
|
|||||||
if (Settings::IsConfiguringGlobal()) {
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
load_func = [=]() {
|
load_func = [=]() {
|
||||||
checkbox_load_func();
|
checkbox_load_func();
|
||||||
other_setting->LoadString(std::to_string(spinbox->value()));
|
setting.LoadString(std::to_string(spinbox->value()));
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
QObject::connect(restore_button, &QAbstractButton::clicked, [this, other_setting](bool) {
|
if (!has_checkbox) {
|
||||||
spinbox->setValue(std::stoi(other_setting->ToStringGlobal()));
|
restore_button = CreateRestoreGlobalButton(setting, this);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
QObject::connect(restore_button, &QAbstractButton::clicked,
|
||||||
|
[this](bool) { spinbox->setValue(std::stoi(setting.ToStringGlobal())); });
|
||||||
|
|
||||||
QObject::connect(spinbox, QOverload<int>::of(&QSpinBox::valueChanged), [this](int) {
|
QObject::connect(spinbox, QOverload<int>::of(&QSpinBox::valueChanged), [this](int) {
|
||||||
restore_button->setEnabled(true);
|
restore_button->setEnabled(true);
|
||||||
@ -400,47 +342,122 @@ void Widget::CreateCheckBoxWithSpinBox(const QString& label, Settings::BasicSett
|
|||||||
checkbox_load_func();
|
checkbox_load_func();
|
||||||
|
|
||||||
const bool using_global = !restore_button->isEnabled();
|
const bool using_global = !restore_button->isEnabled();
|
||||||
other_setting->SetGlobal(using_global);
|
setting.SetGlobal(using_global);
|
||||||
if (!using_global) {
|
if (!using_global) {
|
||||||
other_setting->LoadString(std::to_string(spinbox->value()));
|
setting.LoadString(std::to_string(spinbox->value()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently tailored to custom_rtc
|
void Widget::CreateHexEdit(const QString& label, std::function<void()>& load_func, bool managed,
|
||||||
void Widget::CreateCheckBoxWithDateTimeEdit(const QString& label,
|
Settings::BasicSetting* const other_setting) {
|
||||||
Settings::BasicSetting* other_setting,
|
CreateLineEdit(label, load_func, false, other_setting);
|
||||||
std::function<void()>& load_func) {
|
if (!created || !managed) {
|
||||||
if (other_setting == nullptr) {
|
return;
|
||||||
LOG_WARNING(Frontend, "Extra setting is null or not an integer");
|
}
|
||||||
|
|
||||||
|
QLayout* layout = this->layout();
|
||||||
|
|
||||||
|
auto to_hex = [=](const std::string& input) {
|
||||||
|
return QString::fromStdString(fmt::format("{:08x}", std::stoi(input)));
|
||||||
|
};
|
||||||
|
|
||||||
|
QRegExpValidator* regex =
|
||||||
|
new QRegExpValidator{QRegExp{QStringLiteral("^[0-9a-fA-F]{0,8}$")}, line_edit};
|
||||||
|
|
||||||
|
const QString default_val = to_hex(setting.ToString());
|
||||||
|
|
||||||
|
line_edit->setText(default_val);
|
||||||
|
line_edit->setMaxLength(8);
|
||||||
|
line_edit->setValidator(regex);
|
||||||
|
|
||||||
|
auto hex_to_dec = [=]() -> std::string {
|
||||||
|
return std::to_string(std::stoul(line_edit->text().toStdString(), nullptr, 16));
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
|
load_func = [=]() {
|
||||||
|
other_setting->LoadString(checkbox->checkState() == Qt::Checked ? "true" : "false");
|
||||||
|
setting.LoadString(hex_to_dec());
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
restore_button = CreateRestoreGlobalButton(setting, this);
|
||||||
|
layout->addWidget(restore_button);
|
||||||
|
|
||||||
|
QObject::connect(restore_button, &QAbstractButton::clicked, [=](bool) {
|
||||||
|
line_edit->setText(to_hex(setting.ToStringGlobal()));
|
||||||
|
checkbox->setCheckState(other_setting->ToStringGlobal() == "true" ? Qt::Checked
|
||||||
|
: Qt::Unchecked);
|
||||||
|
|
||||||
|
restore_button->setEnabled(false);
|
||||||
|
restore_button->setVisible(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(line_edit, &QLineEdit::textEdited, [&]() {
|
||||||
|
restore_button->setEnabled(true);
|
||||||
|
restore_button->setVisible(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(checkbox, &QAbstractButton::clicked, [&]() {
|
||||||
|
restore_button->setEnabled(true);
|
||||||
|
restore_button->setVisible(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
load_func = [=]() {
|
||||||
|
const bool using_global = !restore_button->isEnabled();
|
||||||
|
other_setting->SetGlobal(using_global);
|
||||||
|
setting.SetGlobal(using_global);
|
||||||
|
|
||||||
|
if (!using_global) {
|
||||||
|
other_setting->LoadString(checkbox->checkState() == Qt::Checked ? "true" : "false");
|
||||||
|
setting.LoadString(hex_to_dec());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::CreateDateTimeEdit(const QString& label, std::function<void()>& load_func,
|
||||||
|
bool managed, bool restrict,
|
||||||
|
Settings::BasicSetting* const other_setting) {
|
||||||
|
const bool has_checkbox = other_setting != nullptr;
|
||||||
|
if ((restrict && !has_checkbox) || (has_checkbox && other_setting->TypeId() != typeid(bool))) {
|
||||||
|
LOG_WARNING(Frontend, "Extra setting or restrict requested but is not boolean");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
created = true;
|
created = true;
|
||||||
|
|
||||||
std::function<void()> checkbox_load_func;
|
QHBoxLayout* layout{nullptr};
|
||||||
CreateCheckBox(label, checkbox_load_func);
|
std::function<void()> checkbox_load_func = []() {};
|
||||||
|
|
||||||
QHBoxLayout* layout = reinterpret_cast<QHBoxLayout*>(this->layout());
|
if (has_checkbox) {
|
||||||
const bool disabled = setting.ToString() != "true";
|
layout = CreateCheckBox(other_setting, label, checkbox_load_func, managed);
|
||||||
|
} else {
|
||||||
|
layout = new QHBoxLayout(this);
|
||||||
|
QLabel* q_label = CreateLabel(label);
|
||||||
|
layout->addWidget(q_label);
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool disabled = other_setting->ToString() != "true";
|
||||||
const long long current_time = QDateTime::currentSecsSinceEpoch();
|
const long long current_time = QDateTime::currentSecsSinceEpoch();
|
||||||
const s64 the_time = disabled ? current_time : std::stoll(other_setting->ToString());
|
const s64 the_time = disabled ? current_time : std::stoll(setting.ToString());
|
||||||
const auto default_val = QDateTime::fromSecsSinceEpoch(the_time);
|
const auto default_val = QDateTime::fromSecsSinceEpoch(the_time);
|
||||||
|
|
||||||
date_time_edit = new QDateTimeEdit(this);
|
date_time_edit = new QDateTimeEdit(this);
|
||||||
date_time_edit->setDateTime(default_val);
|
date_time_edit->setDateTime(default_val);
|
||||||
|
|
||||||
date_time_edit->setMinimumDateTime(QDateTime::fromSecsSinceEpoch(0));
|
date_time_edit->setMinimumDateTime(QDateTime::fromSecsSinceEpoch(0));
|
||||||
|
|
||||||
date_time_edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
date_time_edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
checkbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
||||||
|
|
||||||
layout->insertWidget(1, date_time_edit);
|
layout->insertWidget(1, date_time_edit);
|
||||||
|
|
||||||
|
if (!managed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
load_func = [=]() {
|
load_func = [=]() {
|
||||||
checkbox_load_func();
|
checkbox_load_func();
|
||||||
if (checkbox->checkState() == Qt::Unchecked) {
|
if (restrict && checkbox->checkState() == Qt::Unchecked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,9 +465,14 @@ void Widget::CreateCheckBoxWithDateTimeEdit(const QString& label,
|
|||||||
std::to_string(date_time_edit->dateTime().toSecsSinceEpoch()));
|
std::to_string(date_time_edit->dateTime().toSecsSinceEpoch()));
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
if (!has_checkbox) {
|
||||||
|
restore_button = CreateRestoreGlobalButton(setting, this);
|
||||||
|
layout->addWidget(restore_button);
|
||||||
|
}
|
||||||
|
|
||||||
auto get_clear_val = [=]() {
|
auto get_clear_val = [=]() {
|
||||||
return QDateTime::fromSecsSinceEpoch([=]() {
|
return QDateTime::fromSecsSinceEpoch([=]() {
|
||||||
if (checkbox->checkState() == Qt::Checked) {
|
if (restrict && checkbox->checkState() == Qt::Checked) {
|
||||||
return std::stoll(other_setting->ToStringGlobal());
|
return std::stoll(other_setting->ToStringGlobal());
|
||||||
}
|
}
|
||||||
return current_time;
|
return current_time;
|
||||||
@ -469,7 +491,7 @@ void Widget::CreateCheckBoxWithDateTimeEdit(const QString& label,
|
|||||||
|
|
||||||
load_func = [=]() {
|
load_func = [=]() {
|
||||||
checkbox_load_func();
|
checkbox_load_func();
|
||||||
if (checkbox->checkState() == Qt::Unchecked) {
|
if (restrict && checkbox->checkState() == Qt::Unchecked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,12 +511,18 @@ bool Widget::Valid() {
|
|||||||
|
|
||||||
Widget::~Widget() = default;
|
Widget::~Widget() = default;
|
||||||
|
|
||||||
|
Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_,
|
||||||
|
QWidget* parent_, std::forward_list<std::function<void(bool)>>& apply_funcs_)
|
||||||
|
: QWidget(parent_), parent{parent_}, translations{translations_}, setting{*setting_},
|
||||||
|
apply_funcs{apply_funcs_} {}
|
||||||
|
|
||||||
Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_,
|
Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_,
|
||||||
QWidget* parent_, bool runtime_lock,
|
QWidget* parent_, bool runtime_lock,
|
||||||
std::forward_list<std::function<void(bool)>>& apply_funcs, RequestType request,
|
std::forward_list<std::function<void(bool)>>& apply_funcs_, RequestType request,
|
||||||
bool managed, float multiplier, Settings::BasicSetting* other_setting,
|
bool managed, float multiplier, Settings::BasicSetting* other_setting,
|
||||||
const std::string& string)
|
const std::string& string)
|
||||||
: QWidget(parent_), parent{parent_}, translations{translations_}, setting{*setting_} {
|
: QWidget(parent_), parent{parent_}, translations{translations_}, setting{*setting_},
|
||||||
|
apply_funcs{apply_funcs_} {
|
||||||
if (!Settings::IsConfiguringGlobal() && !setting.Switchable()) {
|
if (!Settings::IsConfiguringGlobal() && !setting.Switchable()) {
|
||||||
LOG_DEBUG(Frontend, "\"{}\" is not switchable, skipping...", setting.GetLabel());
|
LOG_DEBUG(Frontend, "\"{}\" is not switchable, skipping...", setting.GetLabel());
|
||||||
return;
|
return;
|
||||||
@ -523,51 +551,44 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati
|
|||||||
if (type == typeid(bool)) {
|
if (type == typeid(bool)) {
|
||||||
switch (request) {
|
switch (request) {
|
||||||
case RequestType::Default:
|
case RequestType::Default:
|
||||||
CreateCheckBox(label, load_func);
|
CreateCheckBox(&setting, label, load_func, managed);
|
||||||
break;
|
break;
|
||||||
case RequestType::SpinBox:
|
default:
|
||||||
CreateCheckBoxWithSpinBox(label, other_setting, load_func, string);
|
LOG_WARNING(Frontend, "Requested widget is unimplemented.");
|
||||||
break;
|
|
||||||
case RequestType::HexEdit:
|
|
||||||
CreateCheckBoxWithHexEdit(label, other_setting, load_func);
|
|
||||||
break;
|
|
||||||
case RequestType::LineEdit:
|
|
||||||
CreateCheckBoxWithLineEdit(label, other_setting, load_func);
|
|
||||||
break;
|
|
||||||
case RequestType::DateTimeEdit:
|
|
||||||
CreateCheckBoxWithDateTimeEdit(label, other_setting, load_func);
|
|
||||||
break;
|
|
||||||
case RequestType::ComboBox:
|
|
||||||
case RequestType::Slider:
|
|
||||||
case RequestType::ReverseSlider:
|
|
||||||
case RequestType::MaxEnum:
|
|
||||||
LOG_DEBUG(Frontend, "Requested widget is unimplemented.");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (setting.IsEnum()) {
|
} else if (setting.IsEnum()) {
|
||||||
CreateCombobox(label, managed, load_func);
|
CreateCombobox(label, load_func, managed);
|
||||||
} else if (type == typeid(u32) || type == typeid(int)) {
|
} else if (type == typeid(u32) || type == typeid(int) || type == typeid(u16) ||
|
||||||
|
type == typeid(s64)) {
|
||||||
switch (request) {
|
switch (request) {
|
||||||
case RequestType::Slider:
|
case RequestType::Slider:
|
||||||
case RequestType::ReverseSlider:
|
case RequestType::ReverseSlider:
|
||||||
CreateSlider(label, request == RequestType::ReverseSlider, multiplier, load_func);
|
CreateSlider(label, request == RequestType::ReverseSlider, multiplier, load_func,
|
||||||
|
managed);
|
||||||
break;
|
break;
|
||||||
case RequestType::LineEdit:
|
case RequestType::LineEdit:
|
||||||
case RequestType::Default:
|
case RequestType::Default:
|
||||||
CreateLineEdit(label, managed, load_func);
|
CreateLineEdit(label, load_func, managed);
|
||||||
break;
|
break;
|
||||||
case RequestType::ComboBox:
|
case RequestType::ComboBox:
|
||||||
CreateCombobox(label, managed, load_func);
|
CreateCombobox(label, load_func, managed);
|
||||||
break;
|
break;
|
||||||
case RequestType::DateTimeEdit:
|
case RequestType::DateTimeEdit:
|
||||||
|
CreateDateTimeEdit(label, load_func, managed, true, other_setting);
|
||||||
|
break;
|
||||||
case RequestType::SpinBox:
|
case RequestType::SpinBox:
|
||||||
|
CreateSpinBox(label, load_func, managed, string, other_setting);
|
||||||
|
break;
|
||||||
case RequestType::HexEdit:
|
case RequestType::HexEdit:
|
||||||
case RequestType::MaxEnum:
|
CreateHexEdit(label, load_func, managed, other_setting);
|
||||||
LOG_DEBUG(Frontend, "Requested widget is unimplemented.");
|
break;
|
||||||
|
default:
|
||||||
|
LOG_WARNING(Frontend, "Requested widget is unimplemented.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (type == typeid(std::string)) {
|
} else if (type == typeid(std::string)) {
|
||||||
CreateLineEdit(label, managed, load_func);
|
CreateLineEdit(label, load_func, managed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!created) {
|
if (!created) {
|
||||||
|
@ -9,6 +9,8 @@ class QComboBox;
|
|||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QSlider;
|
class QSlider;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
|
class QLabel;
|
||||||
|
class QHBoxLayout;
|
||||||
class QDateTimeEdit;
|
class QDateTimeEdit;
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
@ -34,9 +36,11 @@ class Widget : public QWidget {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Widget(Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent,
|
Widget(Settings::BasicSetting* setting, const TranslationMap& 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, float multiplier = 1.0f,
|
RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f,
|
||||||
Settings::BasicSetting* other_setting = nullptr, const std::string& format = "");
|
Settings::BasicSetting* other_setting = nullptr, const std::string& format = "");
|
||||||
|
Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_, QWidget* parent_,
|
||||||
|
std::forward_list<std::function<void(bool)>>& apply_funcs_);
|
||||||
virtual ~Widget();
|
virtual ~Widget();
|
||||||
|
|
||||||
bool Valid();
|
bool Valid();
|
||||||
@ -53,23 +57,28 @@ public:
|
|||||||
QDateTimeEdit* date_time_edit{};
|
QDateTimeEdit* date_time_edit{};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateCheckBox(const QString& label, std::function<void()>& load_func);
|
QLabel* CreateLabel(const QString& text);
|
||||||
void CreateCheckBoxWithLineEdit(const QString& label, Settings::BasicSetting* other_setting,
|
QHBoxLayout* CreateCheckBox(Settings::BasicSetting* bool_setting, const QString& label,
|
||||||
std::function<void()>& load_func);
|
std::function<void()>& load_func, bool managed);
|
||||||
void CreateCheckBoxWithHexEdit(const QString& label, Settings::BasicSetting* other_setting,
|
|
||||||
std::function<void()>& load_func);
|
void CreateCombobox(const QString& label, std::function<void()>& load_func, bool managed,
|
||||||
void CreateCheckBoxWithSpinBox(const QString& label, Settings::BasicSetting* other_setting,
|
Settings::BasicSetting* const other_setting = nullptr);
|
||||||
std::function<void()>& load_func, const std::string& suffix);
|
void CreateLineEdit(const QString& label, std::function<void()>& load_func, bool managed,
|
||||||
void CreateCheckBoxWithDateTimeEdit(const QString& label, Settings::BasicSetting* other_setting,
|
Settings::BasicSetting* const other_setting = nullptr);
|
||||||
std::function<void()>& load_func);
|
void CreateHexEdit(const QString& label, std::function<void()>& load_func, bool managed,
|
||||||
void CreateCombobox(const QString& label, bool managed, std::function<void()>& load_func);
|
Settings::BasicSetting* const other_setting = nullptr);
|
||||||
void CreateLineEdit(const QString& label, bool managed, std::function<void()>& load_func);
|
|
||||||
void CreateSlider(const QString& label, bool reversed, float multiplier,
|
void CreateSlider(const QString& label, bool reversed, float multiplier,
|
||||||
std::function<void()>& load_func);
|
std::function<void()>& load_func, bool managed,
|
||||||
|
Settings::BasicSetting* const other_setting = nullptr);
|
||||||
|
void CreateDateTimeEdit(const QString& label, std::function<void()>& load_func, bool managed,
|
||||||
|
bool restrict, Settings::BasicSetting* const other_setting = nullptr);
|
||||||
|
void CreateSpinBox(const QString& label, std::function<void()>& load_func, bool managed,
|
||||||
|
const std::string& suffix, Settings::BasicSetting* other_setting = nullptr);
|
||||||
|
|
||||||
QWidget* parent;
|
QWidget* parent;
|
||||||
const TranslationMap& translations;
|
const TranslationMap& translations;
|
||||||
Settings::BasicSetting& setting;
|
Settings::BasicSetting& setting;
|
||||||
|
std::forward_list<std::function<void(bool)>>& apply_funcs;
|
||||||
|
|
||||||
bool created{false};
|
bool created{false};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user