summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlat9nq <22451773+lat9nq@users.noreply.github.com>2023-05-09 21:46:07 +0200
committerlat9nq <22451773+lat9nq@users.noreply.github.com>2023-07-21 16:56:07 +0200
commit97674bc88821b202aa7309208b71f2ab042fc5aa (patch)
treeabdbd2840381fab4e49d749941e4d870e1d7f2ac /src
parentconfigure_debug: Reorganize (diff)
downloadyuzu-97674bc88821b202aa7309208b71f2ab042fc5aa.tar
yuzu-97674bc88821b202aa7309208b71f2ab042fc5aa.tar.gz
yuzu-97674bc88821b202aa7309208b71f2ab042fc5aa.tar.bz2
yuzu-97674bc88821b202aa7309208b71f2ab042fc5aa.tar.lz
yuzu-97674bc88821b202aa7309208b71f2ab042fc5aa.tar.xz
yuzu-97674bc88821b202aa7309208b71f2ab042fc5aa.tar.zst
yuzu-97674bc88821b202aa7309208b71f2ab042fc5aa.zip
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/configuration/configure_graphics.cpp2
-rw-r--r--src/yuzu/configuration/shared_widget.cpp50
-rw-r--r--src/yuzu/configuration/shared_widget.h13
3 files changed, 55 insertions, 10 deletions
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp
index 4c6d69703..5132c4796 100644
--- a/src/yuzu/configuration/configure_graphics.cpp
+++ b/src/yuzu/configuration/configure_graphics.cpp
@@ -240,7 +240,7 @@ void ConfigureGraphics::Setup() {
return new ConfigurationShared::Widget(
setting, translations, this, runtime_lock, apply_funcs,
ConfigurationShared::RequestType::LineEdit, true, 1.0f,
- Settings::values.speed_limit.ToString());
+ &Settings::values.speed_limit, QString::fromStdString("%"));
} else {
return new ConfigurationShared::Widget(setting, translations, this, runtime_lock,
apply_funcs);
diff --git a/src/yuzu/configuration/shared_widget.cpp b/src/yuzu/configuration/shared_widget.cpp
index ba44d1973..841524b9c 100644
--- a/src/yuzu/configuration/shared_widget.cpp
+++ b/src/yuzu/configuration/shared_widget.cpp
@@ -6,6 +6,7 @@
#include <QLineEdit>
#include <QPushButton>
#include <QSizePolicy>
+#include <QSpinBox>
#include <QWidget>
#include <qabstractbutton.h>
#include "common/settings.h"
@@ -234,7 +235,8 @@ void Widget::CreateSlider(const QString& name, bool reversed, float multiplier,
}
}
-void Widget::CreateCheckBoxWithLineEdit(const QString& label, const std::string& text_box_default,
+void Widget::CreateCheckBoxWithLineEdit(const QString& label,
+ const Settings::BasicSetting* other_setting,
std::function<void()>& load_func) {
created = true;
@@ -243,7 +245,7 @@ void Widget::CreateCheckBoxWithLineEdit(const QString& label, const std::string&
QHBoxLayout* layout = reinterpret_cast<QHBoxLayout*>(this->layout());
line_edit = new QLineEdit(this);
- line_edit->setText(QString::fromStdString(text_box_default));
+ line_edit->setText(QString::fromStdString(other_setting->ToString()));
checkbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
@@ -254,7 +256,7 @@ void Widget::CreateCheckBoxWithLineEdit(const QString& label, const std::string&
if (!Settings::IsConfiguringGlobal()) {
QObject::connect(restore_button, &QAbstractButton::clicked, [=](bool) {
- line_edit->setText(QString::fromStdString(text_box_default));
+ line_edit->setText(QString::fromStdString(other_setting->ToString()));
});
QObject::connect(line_edit, &QLineEdit::textEdited, [=](const QString&) {
@@ -264,6 +266,41 @@ void Widget::CreateCheckBoxWithLineEdit(const QString& label, const std::string&
}
}
+void Widget::CreateCheckBoxWithSpinBox(const QString& label,
+ const Settings::BasicSetting* other_setting,
+ std::function<void()>& load_func, const QString& suffix) {
+ created = true;
+
+ CreateCheckBox(label, load_func);
+ checkbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+
+ QHBoxLayout* layout = reinterpret_cast<QHBoxLayout*>(this->layout());
+
+ spinbox = new QSpinBox(this);
+ const int min_val = std::stoi(other_setting->MinVal());
+ const int max_val = std::stoi(other_setting->MaxVal());
+ spinbox->setRange(min_val, max_val);
+ spinbox->setValue(std::stoi(other_setting->ToString()));
+ spinbox->setSuffix(suffix);
+ spinbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+
+ layout->insertWidget(1, spinbox);
+
+ QObject::connect(spinbox, QOverload<int>::of(&QSpinBox::valueChanged),
+ [this](int) { checkbox->setCheckState(Qt::Checked); });
+
+ if (!Settings::IsConfiguringGlobal()) {
+ QObject::connect(restore_button, &QAbstractButton::clicked, [this, other_setting](bool) {
+ spinbox->setValue(std::stoi(other_setting->ToString()));
+ });
+
+ QObject::connect(spinbox, QOverload<int>::of(&QSpinBox::valueChanged), [this](int) {
+ restore_button->setEnabled(true);
+ restore_button->setVisible(true);
+ });
+ }
+}
+
bool Widget::Valid() {
return created;
}
@@ -273,7 +310,8 @@ Widget::~Widget() = default;
Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_,
QWidget* parent_, bool runtime_lock,
std::forward_list<std::function<void(bool)>>& apply_funcs, RequestType request,
- bool managed, float multiplier, const std::string& text_box_default)
+ bool managed, float multiplier, const Settings::BasicSetting* other_setting,
+ const QString& format)
: QWidget(parent_), parent{parent_}, translations{translations_}, setting{*setting_} {
if (!Settings::IsConfiguringGlobal() && !setting.Switchable()) {
LOG_DEBUG(Frontend, "\"{}\" is not switchable, skipping...", setting.GetLabel());
@@ -306,8 +344,10 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati
CreateCheckBox(label, load_func);
break;
case RequestType::LineEdit:
+ CreateCheckBoxWithLineEdit(label, other_setting, load_func);
+ break;
case RequestType::SpinBox:
- CreateCheckBoxWithLineEdit(label, text_box_default, load_func);
+ CreateCheckBoxWithSpinBox(label, other_setting, load_func, format);
break;
case RequestType::ComboBox:
case RequestType::Slider:
diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h
index 8d2d7f269..c25d819f0 100644
--- a/src/yuzu/configuration/shared_widget.h
+++ b/src/yuzu/configuration/shared_widget.h
@@ -4,6 +4,7 @@
#include "yuzu/configuration/shared_translation.h"
class QPushButton;
+class QSpinBox;
class QComboBox;
class QLineEdit;
class QSlider;
@@ -32,7 +33,8 @@ public:
Widget(Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent,
bool runtime_lock, std::forward_list<std::function<void(bool)>>& apply_funcs,
RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f,
- const std::string& text_box_default = "");
+ const Settings::BasicSetting* other_setting = nullptr,
+ const QString& format = QStringLiteral(""));
virtual ~Widget();
bool Valid();
@@ -42,16 +44,19 @@ public:
QPushButton* restore_button{};
QLineEdit* line_edit{};
+ QSpinBox* spinbox{};
QCheckBox* checkbox{};
QSlider* slider{};
QComboBox* combobox{};
private:
void CreateCheckBox(const QString& label, std::function<void()>& load_func);
- void CreateCheckBoxWithLineEdit(const QString& label, const std::string& text_box_default,
+ void CreateCheckBoxWithLineEdit(const QString& label,
+ const Settings::BasicSetting* other_setting,
std::function<void()>& load_func);
- void CreateCheckBoxWithSpinBox(const QString& label, const std::string& text_box_default,
- std::function<void()>& load_func);
+ void CreateCheckBoxWithSpinBox(const QString& label,
+ const Settings::BasicSetting* other_setting,
+ std::function<void()>& load_func, const QString& suffix);
void CreateCombobox(const QString& label, bool managed, std::function<void()>& load_func);
void CreateLineEdit(const QString& label, bool managed, std::function<void()>& load_func);
void CreateSlider(const QString& label, bool reversed, float multiplier,