forked from suyu/suyu
configuration: Implement slider
This commit is contained in:
parent
39a1ffbb91
commit
d35577d3ed
7 changed files with 188 additions and 71 deletions
|
@ -200,6 +200,8 @@ public:
|
||||||
virtual bool RuntimeModfiable() const = 0;
|
virtual bool RuntimeModfiable() const = 0;
|
||||||
virtual void SetGlobal(bool global) {}
|
virtual void SetGlobal(bool global) {}
|
||||||
virtual constexpr u32 Id() const = 0;
|
virtual constexpr u32 Id() const = 0;
|
||||||
|
virtual std::string MinVal() const = 0;
|
||||||
|
virtual std::string MaxVal() const = 0;
|
||||||
virtual bool UsingGlobal() const {
|
virtual bool UsingGlobal() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -336,7 +338,7 @@ protected:
|
||||||
if constexpr (std::is_same<Type, std::string>()) {
|
if constexpr (std::is_same<Type, std::string>()) {
|
||||||
return value_;
|
return value_;
|
||||||
} else if constexpr (std::is_same<Type, std::optional<u32>>()) {
|
} else if constexpr (std::is_same<Type, std::optional<u32>>()) {
|
||||||
return value_.has_value() ? std::to_string(*value_) : "0";
|
return value_.has_value() ? std::to_string(*value_) : "none";
|
||||||
} else if constexpr (std::is_same<Type, bool>()) {
|
} else if constexpr (std::is_same<Type, bool>()) {
|
||||||
return value_ ? "true" : "false";
|
return value_ ? "true" : "false";
|
||||||
} else {
|
} else {
|
||||||
|
@ -401,7 +403,7 @@ public:
|
||||||
if constexpr (std::is_same<Type, std::string>()) {
|
if constexpr (std::is_same<Type, std::string>()) {
|
||||||
this->SetValue(input);
|
this->SetValue(input);
|
||||||
} else if constexpr (std::is_same<Type, std::optional<u32>>()) {
|
} else if constexpr (std::is_same<Type, std::optional<u32>>()) {
|
||||||
this->SetValue(static_cast<u32>(std::stoll(input)));
|
this->SetValue(static_cast<u32>(std::stoul(input)));
|
||||||
} else if constexpr (std::is_same<Type, bool>()) {
|
} else if constexpr (std::is_same<Type, bool>()) {
|
||||||
this->SetValue(input == "true");
|
this->SetValue(input == "true");
|
||||||
} else {
|
} else {
|
||||||
|
@ -435,6 +437,13 @@ public:
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual std::string MinVal() const override {
|
||||||
|
return this->ToString(minimum);
|
||||||
|
}
|
||||||
|
virtual std::string MaxVal() const override {
|
||||||
|
return this->ToString(maximum);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Type value{}; ///< The setting
|
Type value{}; ///< The setting
|
||||||
const Type default_value{}; ///< The default value
|
const Type default_value{}; ///< The default value
|
||||||
|
|
|
@ -13,10 +13,14 @@
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <qabstractbutton.h>
|
#include <qabstractbutton.h>
|
||||||
|
#include <qabstractslider.h>
|
||||||
|
#include <qboxlayout.h>
|
||||||
#include <qcheckbox.h>
|
#include <qcheckbox.h>
|
||||||
#include <qcombobox.h>
|
#include <qcombobox.h>
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
|
#include <qsize.h>
|
||||||
#include <qsizepolicy.h>
|
#include <qsizepolicy.h>
|
||||||
|
#include <qsurfaceformat.h>
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "yuzu/configuration/configuration_shared.h"
|
#include "yuzu/configuration/configuration_shared.h"
|
||||||
#include "yuzu/configuration/configure_per_game.h"
|
#include "yuzu/configuration/configure_per_game.h"
|
||||||
|
@ -24,7 +28,7 @@
|
||||||
|
|
||||||
namespace ConfigurationShared {
|
namespace ConfigurationShared {
|
||||||
|
|
||||||
static QPushButton* CreateClearGlobalButton(QWidget* parent, Settings::BasicSetting* setting) {
|
static QPushButton* CreateRestoreGlobalButton(QWidget* parent, Settings::BasicSetting* setting) {
|
||||||
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));
|
||||||
QPushButton* button = new QPushButton(*icon, QStringLiteral(""), parent);
|
QPushButton* button = new QPushButton(*icon, QStringLiteral(""), parent);
|
||||||
|
@ -40,10 +44,8 @@ static QPushButton* CreateClearGlobalButton(QWidget* parent, Settings::BasicSett
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::pair<QWidget*, std::function<void()>> CreateCheckBox(Settings::BasicSetting* setting,
|
static std::tuple<QWidget*, void*, QPushButton*, std::function<void()>> CreateCheckBox(
|
||||||
const QString& label,
|
Settings::BasicSetting* setting, const QString& label, QWidget* parent) {
|
||||||
QWidget* parent,
|
|
||||||
std::list<CheckState>& trackers) {
|
|
||||||
QWidget* widget = new QWidget(parent);
|
QWidget* widget = new QWidget(parent);
|
||||||
QHBoxLayout* layout = new QHBoxLayout(widget);
|
QHBoxLayout* layout = new QHBoxLayout(widget);
|
||||||
|
|
||||||
|
@ -54,13 +56,15 @@ static std::pair<QWidget*, std::function<void()>> CreateCheckBox(Settings::Basic
|
||||||
|
|
||||||
std::function<void()> load_func;
|
std::function<void()> load_func;
|
||||||
|
|
||||||
|
QPushButton* button{nullptr};
|
||||||
|
|
||||||
layout->addWidget(checkbox);
|
layout->addWidget(checkbox);
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
load_func = [setting, checkbox]() {
|
load_func = [setting, checkbox]() {
|
||||||
setting->LoadString(checkbox->checkState() == Qt::Checked ? "true" : "false");
|
setting->LoadString(checkbox->checkState() == Qt::Checked ? "true" : "false");
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
auto* button = CreateClearGlobalButton(parent, setting);
|
button = CreateRestoreGlobalButton(parent, setting);
|
||||||
layout->addWidget(button);
|
layout->addWidget(button);
|
||||||
|
|
||||||
QObject::connect(checkbox, &QCheckBox::stateChanged, [button](int) {
|
QObject::connect(checkbox, &QCheckBox::stateChanged, [button](int) {
|
||||||
|
@ -86,7 +90,7 @@ static std::pair<QWidget*, std::function<void()>> CreateCheckBox(Settings::Basic
|
||||||
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
return {widget, load_func};
|
return {widget, checkbox, button, load_func};
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::tuple<QWidget*, QComboBox*, QPushButton*, std::function<void()>> CreateCombobox(
|
static std::tuple<QWidget*, QComboBox*, QPushButton*, std::function<void()>> CreateCombobox(
|
||||||
|
@ -122,7 +126,7 @@ static std::tuple<QWidget*, QComboBox*, QPushButton*, std::function<void()>> Cre
|
||||||
setting->LoadString(std::to_string(combobox->currentIndex()));
|
setting->LoadString(std::to_string(combobox->currentIndex()));
|
||||||
};
|
};
|
||||||
} else if (managed) {
|
} else if (managed) {
|
||||||
button = CreateClearGlobalButton(parent, setting);
|
button = CreateRestoreGlobalButton(parent, setting);
|
||||||
layout->addWidget(button);
|
layout->addWidget(button);
|
||||||
|
|
||||||
QObject::connect(button, &QAbstractButton::clicked, [button, combobox, setting](bool) {
|
QObject::connect(button, &QAbstractButton::clicked, [button, combobox, setting](bool) {
|
||||||
|
@ -149,8 +153,8 @@ static std::tuple<QWidget*, QComboBox*, QPushButton*, std::function<void()>> Cre
|
||||||
return {group, combobox, button, load_func};
|
return {group, combobox, button, load_func};
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::tuple<QWidget*, void*, std::function<void()>> CreateLineEdit(
|
static std::tuple<QWidget*, void*, QPushButton*, std::function<void()>> CreateLineEdit(
|
||||||
Settings::BasicSetting* setting, const QString& label, QWidget* parent) {
|
Settings::BasicSetting* setting, const QString& label, QWidget* parent, bool managed = true) {
|
||||||
QWidget* widget = new QWidget(parent);
|
QWidget* widget = new QWidget(parent);
|
||||||
widget->setObjectName(label);
|
widget->setObjectName(label);
|
||||||
|
|
||||||
|
@ -160,58 +164,140 @@ static std::tuple<QWidget*, void*, std::function<void()>> CreateLineEdit(
|
||||||
const QString text = QString::fromStdString(setting->ToString());
|
const QString text = QString::fromStdString(setting->ToString());
|
||||||
line_edit->setText(text);
|
line_edit->setText(text);
|
||||||
|
|
||||||
std::function<void()> load_func;
|
std::function<void()> load_func = []() {};
|
||||||
|
|
||||||
|
QLabel* q_label = new QLabel(label, widget);
|
||||||
// setSizePolicy lets widget expand and take an equal part of the space as the line edit
|
// setSizePolicy lets widget expand and take an equal part of the space as the line edit
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
q_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
QLabel* q_label = new QLabel(label, widget);
|
layout->addWidget(q_label);
|
||||||
q_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
||||||
layout->addWidget(q_label);
|
|
||||||
|
|
||||||
|
layout->addWidget(line_edit);
|
||||||
|
|
||||||
|
QPushButton* button{nullptr};
|
||||||
|
|
||||||
|
if (Settings::IsConfiguringGlobal() && !managed) {
|
||||||
load_func = [line_edit, setting]() {
|
load_func = [line_edit, setting]() {
|
||||||
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 {
|
} else if (!managed) {
|
||||||
QCheckBox* checkbox = new QCheckBox(label, parent);
|
button = CreateRestoreGlobalButton(parent, setting);
|
||||||
checkbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
layout->addWidget(button);
|
||||||
layout->addWidget(checkbox);
|
|
||||||
|
|
||||||
const auto highlight_func = [widget, line_edit](int state) {
|
QObject::connect(button, &QAbstractButton::clicked, [=](bool) {
|
||||||
bool using_global = state != Qt::Checked;
|
button->setEnabled(false);
|
||||||
SetHighlight(widget, !using_global);
|
button->setVisible(false);
|
||||||
line_edit->setEnabled(!using_global);
|
|
||||||
};
|
|
||||||
|
|
||||||
QObject::connect(checkbox, qOverload<int>(&QCheckBox::stateChanged), widget,
|
line_edit->setText(QString::fromStdString(setting->ToStringGlobal()));
|
||||||
highlight_func);
|
});
|
||||||
|
|
||||||
checkbox->setCheckState(setting->UsingGlobal() ? Qt::Unchecked : Qt::Checked);
|
QObject::connect(line_edit, &QLineEdit::textChanged, [=](QString) {
|
||||||
highlight_func(checkbox->checkState());
|
button->setEnabled(true);
|
||||||
|
button->setVisible(true);
|
||||||
|
});
|
||||||
|
|
||||||
load_func = [checkbox, setting, line_edit]() {
|
load_func = [=]() {
|
||||||
if (checkbox->checkState() == Qt::Checked) {
|
bool using_global = !button->isEnabled();
|
||||||
setting->SetGlobal(false);
|
setting->SetGlobal(using_global);
|
||||||
|
if (!using_global) {
|
||||||
std::string load_text = line_edit->text().toStdString();
|
setting->LoadString(line_edit->text().toStdString());
|
||||||
setting->LoadString(load_text);
|
|
||||||
} else {
|
|
||||||
setting->SetGlobal(true);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->addWidget(line_edit);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
return {widget, line_edit, button, load_func};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::tuple<QWidget*, void*, QPushButton*, std::function<void()>> CreateSlider(
|
||||||
|
Settings::BasicSetting* setting, const QString& name, QWidget* parent, bool reversed,
|
||||||
|
float multiplier) {
|
||||||
|
QWidget* widget = new QWidget(parent);
|
||||||
|
QHBoxLayout* layout = new QHBoxLayout(widget);
|
||||||
|
QSlider* slider = new QSlider(Qt::Horizontal, widget);
|
||||||
|
QLabel* label = new QLabel(name, widget);
|
||||||
|
QPushButton* button{nullptr};
|
||||||
|
QLabel* feedback = new QLabel(widget);
|
||||||
|
|
||||||
|
layout->addWidget(label);
|
||||||
|
layout->addWidget(slider);
|
||||||
|
layout->addWidget(feedback);
|
||||||
|
|
||||||
|
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
return {widget, line_edit, load_func};
|
int max_val = std::stoi(setting->MaxVal());
|
||||||
|
|
||||||
|
QObject::connect(slider, &QAbstractSlider::valueChanged, [=](int value) {
|
||||||
|
int present = (reversed ? max_val - value : value) * multiplier;
|
||||||
|
feedback->setText(
|
||||||
|
QStringLiteral("%1%").arg(QString::fromStdString(std::to_string(present))));
|
||||||
|
});
|
||||||
|
|
||||||
|
slider->setValue(std::stoi(setting->ToString()));
|
||||||
|
slider->setMinimum(std::stoi(setting->MinVal()));
|
||||||
|
slider->setMaximum(max_val);
|
||||||
|
|
||||||
|
if (reversed) {
|
||||||
|
slider->setInvertedAppearance(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::function<void()> load_func;
|
||||||
|
|
||||||
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
|
load_func = [=]() { setting->LoadString(std::to_string(slider->value())); };
|
||||||
|
} else {
|
||||||
|
button = CreateRestoreGlobalButton(parent, setting);
|
||||||
|
layout->addWidget(button);
|
||||||
|
|
||||||
|
QObject::connect(button, &QAbstractButton::clicked, [=](bool) {
|
||||||
|
slider->setValue(std::stoi(setting->ToStringGlobal()));
|
||||||
|
|
||||||
|
button->setEnabled(false);
|
||||||
|
button->setVisible(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(slider, &QAbstractSlider::sliderMoved, [=](int) {
|
||||||
|
button->setEnabled(true);
|
||||||
|
button->setVisible(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
load_func = [=]() {
|
||||||
|
bool using_global = !button->isEnabled();
|
||||||
|
setting->SetGlobal(using_global);
|
||||||
|
if (!using_global) {
|
||||||
|
setting->LoadString(std::to_string(slider->value()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {widget, slider, button, []() {}};
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::tuple<QWidget*, void*, void*, QPushButton*, std::function<void()>>
|
||||||
|
CreateCheckBoxWithLineEdit(Settings::BasicSetting* setting, const QString& label, QWidget* parent) {
|
||||||
|
auto tuple = CreateCheckBox(setting, label, parent);
|
||||||
|
auto* widget = std::get<0>(tuple);
|
||||||
|
auto* checkbox = std::get<1>(tuple);
|
||||||
|
auto* button = std::get<2>(tuple);
|
||||||
|
auto load_func = std::get<3>(tuple);
|
||||||
|
QHBoxLayout* layout = dynamic_cast<QHBoxLayout*>(widget->layout());
|
||||||
|
|
||||||
|
auto line_edit_tuple = CreateLineEdit(setting, label, parent, false);
|
||||||
|
auto* line_edit_widget = std::get<0>(line_edit_tuple);
|
||||||
|
auto* line_edit = std::get<1>(line_edit_tuple);
|
||||||
|
|
||||||
|
layout->insertWidget(1, line_edit_widget);
|
||||||
|
|
||||||
|
return {widget, checkbox, line_edit, button, load_func};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<QWidget*, void*, QPushButton*> CreateWidget(
|
std::tuple<QWidget*, void*, QPushButton*> CreateWidget(
|
||||||
Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent,
|
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,
|
||||||
std::list<CheckState>& trackers, RequestType request, bool managed) {
|
RequestType request, bool managed, float multiplier, const std::string& text_box_default) {
|
||||||
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 {nullptr, nullptr, nullptr};
|
return {nullptr, nullptr, nullptr};
|
||||||
|
@ -242,9 +328,27 @@ std::tuple<QWidget*, void*, QPushButton*> CreateWidget(
|
||||||
QPushButton* button;
|
QPushButton* button;
|
||||||
|
|
||||||
if (type == typeid(bool)) {
|
if (type == typeid(bool)) {
|
||||||
auto pair = CreateCheckBox(setting, label, parent, trackers);
|
switch (request) {
|
||||||
widget = pair.first;
|
case RequestType::Default: {
|
||||||
load_func = pair.second;
|
auto tuple = CreateCheckBox(setting, label, parent);
|
||||||
|
widget = std::get<0>(tuple);
|
||||||
|
extra = std::get<1>(tuple);
|
||||||
|
button = std::get<2>(tuple);
|
||||||
|
load_func = std::get<3>(tuple);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RequestType::LineEdit: {
|
||||||
|
auto tuple = CreateCheckBoxWithLineEdit(setting, label, parent);
|
||||||
|
widget = std::get<0>(tuple);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RequestType::ComboBox:
|
||||||
|
case RequestType::SpinBox:
|
||||||
|
case RequestType::Slider:
|
||||||
|
case RequestType::ReverseSlider:
|
||||||
|
case RequestType::MaxEnum:
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else if (setting->IsEnum()) {
|
} else if (setting->IsEnum()) {
|
||||||
auto tuple = CreateCombobox(setting, label, parent, managed);
|
auto tuple = CreateCombobox(setting, label, parent, managed);
|
||||||
widget = std::get<0>(tuple);
|
widget = std::get<0>(tuple);
|
||||||
|
@ -253,11 +357,13 @@ std::tuple<QWidget*, void*, QPushButton*> CreateWidget(
|
||||||
load_func = std::get<3>(tuple);
|
load_func = std::get<3>(tuple);
|
||||||
} else if (type == typeid(u32) || type == typeid(int)) {
|
} else if (type == typeid(u32) || type == typeid(int)) {
|
||||||
switch (request) {
|
switch (request) {
|
||||||
|
case RequestType::LineEdit:
|
||||||
case RequestType::Default: {
|
case RequestType::Default: {
|
||||||
auto tuple = CreateLineEdit(setting, label, parent);
|
auto tuple = CreateLineEdit(setting, label, parent);
|
||||||
widget = std::get<0>(tuple);
|
widget = std::get<0>(tuple);
|
||||||
extra = std::get<1>(tuple);
|
extra = std::get<1>(tuple);
|
||||||
load_func = std::get<2>(tuple);
|
button = std::get<2>(tuple);
|
||||||
|
load_func = std::get<3>(tuple);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RequestType::ComboBox: {
|
case RequestType::ComboBox: {
|
||||||
|
@ -268,8 +374,17 @@ std::tuple<QWidget*, void*, QPushButton*> CreateWidget(
|
||||||
load_func = std::get<3>(tuple);
|
load_func = std::get<3>(tuple);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RequestType::SpinBox:
|
|
||||||
case RequestType::Slider:
|
case RequestType::Slider:
|
||||||
|
case RequestType::ReverseSlider: {
|
||||||
|
auto tuple = CreateSlider(setting, label, parent, request == RequestType::ReverseSlider,
|
||||||
|
multiplier);
|
||||||
|
widget = std::get<0>(tuple);
|
||||||
|
extra = std::get<1>(tuple);
|
||||||
|
button = std::get<2>(tuple);
|
||||||
|
load_func = std::get<3>(tuple);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RequestType::SpinBox:
|
||||||
case RequestType::MaxEnum:
|
case RequestType::MaxEnum:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,14 +48,16 @@ enum class RequestType {
|
||||||
ComboBox,
|
ComboBox,
|
||||||
SpinBox,
|
SpinBox,
|
||||||
Slider,
|
Slider,
|
||||||
|
ReverseSlider,
|
||||||
|
LineEdit,
|
||||||
MaxEnum,
|
MaxEnum,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::tuple<QWidget*, void*, QPushButton*> CreateWidget(
|
std::tuple<QWidget*, void*, QPushButton*> CreateWidget(
|
||||||
Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent,
|
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,
|
||||||
std::list<CheckState>& trackers, RequestType request = RequestType::Default,
|
RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f,
|
||||||
bool managed = true);
|
const std::string& text_box_default = "");
|
||||||
|
|
||||||
// Global-aware apply and set functions
|
// Global-aware apply and set functions
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,6 @@ ConfigureGraphics::ConfigureGraphics(
|
||||||
Settings::values.bg_blue.GetValue()));
|
Settings::values.bg_blue.GetValue()));
|
||||||
UpdateAPILayout();
|
UpdateAPILayout();
|
||||||
PopulateVSyncModeSelection(); //< must happen after UpdateAPILayout
|
PopulateVSyncModeSelection(); //< must happen after UpdateAPILayout
|
||||||
// SetFSRIndicatorText(ui->fsr_sharpening_slider->sliderPosition());
|
|
||||||
|
|
||||||
// VSync setting needs to be determined after populating the VSync combobox
|
// VSync setting needs to be determined after populating the VSync combobox
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
|
@ -134,18 +133,13 @@ ConfigureGraphics::ConfigureGraphics(
|
||||||
// }
|
// }
|
||||||
// UpdateBackgroundColorButton(new_bg_color);
|
// UpdateBackgroundColorButton(new_bg_color);
|
||||||
// });
|
// });
|
||||||
|
// ui->bg_label->setVisible(Settings::IsConfiguringGlobal());
|
||||||
|
// ui->bg_combobox->setVisible(!Settings::IsConfiguringGlobal());
|
||||||
|
|
||||||
api_combobox->setEnabled(!UISettings::values.has_broken_vulkan && api_combobox->isEnabled());
|
api_combobox->setEnabled(!UISettings::values.has_broken_vulkan && api_combobox->isEnabled());
|
||||||
ui->api_widget->setEnabled(
|
ui->api_widget->setEnabled(
|
||||||
(!UISettings::values.has_broken_vulkan || Settings::IsConfiguringGlobal()) &&
|
(!UISettings::values.has_broken_vulkan || Settings::IsConfiguringGlobal()) &&
|
||||||
ui->api_widget->isEnabled());
|
ui->api_widget->isEnabled());
|
||||||
// ui->bg_label->setVisible(Settings::IsConfiguringGlobal());
|
|
||||||
// ui->bg_combobox->setVisible(!Settings::IsConfiguringGlobal());
|
|
||||||
|
|
||||||
// connect(ui->fsr_sharpening_slider, &QSlider::valueChanged, this,
|
|
||||||
// &ConfigureGraphics::SetFSRIndicatorText);
|
|
||||||
// ui->fsr_sharpening_combobox->setVisible(!Settings::IsConfiguringGlobal());
|
|
||||||
// ui->fsr_sharpening_label->setVisible(Settings::IsConfiguringGlobal());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureGraphics::PopulateVSyncModeSelection() {
|
void ConfigureGraphics::PopulateVSyncModeSelection() {
|
||||||
|
@ -230,11 +224,19 @@ void ConfigureGraphics::SetConfiguration() {
|
||||||
setting->Id() == Settings::values.shader_backend.Id() ||
|
setting->Id() == Settings::values.shader_backend.Id() ||
|
||||||
setting->Id() == Settings::values.vsync_mode.Id()) {
|
setting->Id() == Settings::values.vsync_mode.Id()) {
|
||||||
return ConfigurationShared::CreateWidget(
|
return ConfigurationShared::CreateWidget(
|
||||||
setting, translations, this, runtime_lock, apply_funcs, trackers,
|
setting, translations, this, runtime_lock, apply_funcs,
|
||||||
ConfigurationShared::RequestType::ComboBox, false);
|
ConfigurationShared::RequestType::ComboBox, false);
|
||||||
|
} else if (setting->Id() == Settings::values.fsr_sharpening_slider.Id()) {
|
||||||
|
return ConfigurationShared::CreateWidget(
|
||||||
|
setting, translations, this, runtime_lock, apply_funcs,
|
||||||
|
ConfigurationShared::RequestType::ReverseSlider, true, 0.5f);
|
||||||
|
} else if (setting->Id() == Settings::values.use_speed_limit.Id()) {
|
||||||
|
return ConfigurationShared::CreateWidget(
|
||||||
|
setting, translations, this, runtime_lock, apply_funcs,
|
||||||
|
ConfigurationShared::RequestType::LineEdit, true, 1.0f, setting->ToString());
|
||||||
} else {
|
} else {
|
||||||
return ConfigurationShared::CreateWidget(setting, translations, this, runtime_lock,
|
return ConfigurationShared::CreateWidget(setting, translations, this, runtime_lock,
|
||||||
apply_funcs, trackers);
|
apply_funcs);
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
@ -251,12 +253,10 @@ void ConfigureGraphics::SetConfiguration() {
|
||||||
QObject::connect(api_restore_global_button, &QAbstractButton::clicked,
|
QObject::connect(api_restore_global_button, &QAbstractButton::clicked,
|
||||||
[=](bool) { UpdateAPILayout(); });
|
[=](bool) { UpdateAPILayout(); });
|
||||||
|
|
||||||
|
// Detach API's restore button and place it where we want
|
||||||
widget->layout()->removeWidget(api_restore_global_button);
|
widget->layout()->removeWidget(api_restore_global_button);
|
||||||
api_layout->addWidget(api_restore_global_button);
|
api_layout->addWidget(api_restore_global_button);
|
||||||
}
|
}
|
||||||
} else if (setting->Id() == Settings::values.vulkan_device.Id()) {
|
|
||||||
api_layout->addWidget(widget);
|
|
||||||
api_combobox = reinterpret_cast<QComboBox*>(extra);
|
|
||||||
} else if (setting->Id() == Settings::values.vulkan_device.Id()) {
|
} else if (setting->Id() == Settings::values.vulkan_device.Id()) {
|
||||||
hold_api.push_front(widget);
|
hold_api.push_front(widget);
|
||||||
vulkan_device_combobox = reinterpret_cast<QComboBox*>(extra);
|
vulkan_device_combobox = reinterpret_cast<QComboBox*>(extra);
|
||||||
|
@ -284,11 +284,6 @@ void ConfigureGraphics::SetConfiguration() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureGraphics::SetFSRIndicatorText(int percentage) {
|
|
||||||
// ui->fsr_sharpening_value->setText(
|
|
||||||
// tr("%1%", "FSR sharpening percentage (e.g. 50%)").arg(100 - (percentage / 2)));
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode,
|
const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode,
|
||||||
Settings::RendererBackend backend) const {
|
Settings::RendererBackend backend) const {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
|
|
@ -58,7 +58,6 @@ private:
|
||||||
|
|
||||||
void RetrieveVulkanDevices();
|
void RetrieveVulkanDevices();
|
||||||
|
|
||||||
void SetFSRIndicatorText(int percentage);
|
|
||||||
/* Turns a Vulkan present mode into a textual string for a UI
|
/* Turns a Vulkan present mode into a textual string for a UI
|
||||||
* (and eventually for a human to read) */
|
* (and eventually for a human to read) */
|
||||||
const QString TranslateVSyncMode(VkPresentModeKHR mode,
|
const QString TranslateVSyncMode(VkPresentModeKHR mode,
|
||||||
|
@ -69,7 +68,6 @@ private:
|
||||||
std::unique_ptr<Ui::ConfigureGraphics> ui;
|
std::unique_ptr<Ui::ConfigureGraphics> ui;
|
||||||
QColor bg_color;
|
QColor bg_color;
|
||||||
|
|
||||||
std::list<ConfigurationShared::CheckState> trackers{};
|
|
||||||
std::forward_list<std::function<void(bool)>> apply_funcs{};
|
std::forward_list<std::function<void(bool)>> apply_funcs{};
|
||||||
|
|
||||||
std::vector<VkDeviceInfo::Record>& records;
|
std::vector<VkDeviceInfo::Record>& records;
|
||||||
|
|
|
@ -33,7 +33,7 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
|
||||||
for (auto setting :
|
for (auto setting :
|
||||||
Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) {
|
Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) {
|
||||||
auto [widget, extra, button] = ConfigurationShared::CreateWidget(
|
auto [widget, extra, button] = ConfigurationShared::CreateWidget(
|
||||||
setting, translations, this, runtime_lock, apply_funcs, trackers);
|
setting, translations, this, runtime_lock, apply_funcs);
|
||||||
|
|
||||||
if (widget == nullptr) {
|
if (widget == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -34,8 +34,6 @@ private:
|
||||||
|
|
||||||
std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui;
|
std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui;
|
||||||
|
|
||||||
std::list<ConfigurationShared::CheckState> trackers{};
|
|
||||||
|
|
||||||
const Core::System& system;
|
const Core::System& system;
|
||||||
const ConfigurationShared::TranslationMap& translations;
|
const ConfigurationShared::TranslationMap& translations;
|
||||||
std::forward_list<std::function<void(bool)>> apply_funcs;
|
std::forward_list<std::function<void(bool)>> apply_funcs;
|
||||||
|
|
Loading…
Reference in a new issue