From f66d617107e45f8213643f2bbaa5f58878c3d3a6 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 8 May 2023 22:37:03 -0400 Subject: configuration: Move CreateWidget to a class We were passing so many objects between the function and the caller that it needed to be redesigned. --- src/yuzu/configuration/shared_widget.h | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/yuzu/configuration/shared_widget.h (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h new file mode 100644 index 000000000..559a27b41 --- /dev/null +++ b/src/yuzu/configuration/shared_widget.h @@ -0,0 +1,64 @@ +#include "yuzu/configuration/configuration_shared.h" +#include "yuzu/configuration/shared_translation.h" + +class QPushButton; +class QComboBox; +class QLineEdit; +class QSlider; +class QCheckBox; + +namespace Settings { +class BasicSetting; +} + +namespace ConfigurationShared { + +enum class RequestType { + Default, + ComboBox, + SpinBox, + Slider, + ReverseSlider, + LineEdit, + MaxEnum, +}; + +class Widget : public QWidget { + Q_OBJECT + +public: + Widget(Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent, + bool runtime_lock, std::forward_list>& apply_funcs, + RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f, + const std::string& text_box_default = ""); + virtual ~Widget(); + + bool Valid(); + + QPushButton* restore_button{}; + QLineEdit* line_edit{}; + QCheckBox* checkbox{}; + QSlider* slider{}; + QComboBox* combobox{}; + +private: + void CreateCheckBox(const QString& label, std::function& load_func); + void CreateCheckBoxWithLineEdit(const QString& label, const std::string& text_box_default, + std::function& load_func); + void CreateCheckBoxWithSpinBox(const QString& label, const std::string& text_box_default, + std::function& load_func); + void CreateCombobox(const QString& label, bool managed, std::function& load_func); + void CreateLineEdit(const QString& label, bool managed, std::function& load_func); + void CreateSlider(const QString& label, bool reversed, float multiplier, + std::function& load_func); + + void CreateRestoreGlobalButton(); + + QWidget* parent; + const TranslationMap& translations; + Settings::BasicSetting& setting; + + bool created{false}; +}; + +} // namespace ConfigurationShared -- cgit v1.2.3 From d3d9c3568e9b234d3f4c6679651189c3bae68dbc Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 9 May 2023 01:36:05 -0400 Subject: shared_widget: Fix header --- src/yuzu/configuration/shared_widget.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index 559a27b41..3d96805ed 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -1,3 +1,5 @@ +#pragma once + #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/shared_translation.h" -- cgit v1.2.3 From c1748b229a81390c3ee81a1b951455839204c572 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 9 May 2023 14:26:03 -0400 Subject: shared_widget: Make button creation static --- src/yuzu/configuration/shared_widget.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index 3d96805ed..8d2d7f269 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -37,6 +37,9 @@ public: bool Valid(); + [[nodiscard]] static QPushButton* CreateRestoreGlobalButton(Settings::BasicSetting& setting, + QWidget* parent); + QPushButton* restore_button{}; QLineEdit* line_edit{}; QCheckBox* checkbox{}; @@ -54,8 +57,6 @@ private: void CreateSlider(const QString& label, bool reversed, float multiplier, std::function& load_func); - void CreateRestoreGlobalButton(); - QWidget* parent; const TranslationMap& translations; Settings::BasicSetting& setting; -- cgit v1.2.3 From 97674bc88821b202aa7309208b71f2ab042fc5aa Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 9 May 2023 15:46:07 -0400 Subject: shared_widget: Support checkbox + spinbox --- src/yuzu/configuration/shared_widget.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') 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>& 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& 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& load_func); - void CreateCheckBoxWithSpinBox(const QString& label, const std::string& text_box_default, - std::function& load_func); + void CreateCheckBoxWithSpinBox(const QString& label, + const Settings::BasicSetting* other_setting, + std::function& load_func, const QString& suffix); void CreateCombobox(const QString& label, bool managed, std::function& load_func); void CreateLineEdit(const QString& label, bool managed, std::function& load_func); void CreateSlider(const QString& label, bool reversed, float multiplier, -- cgit v1.2.3 From b11a2a206fa2945c954f0b432937bfd468c43fea Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 9 May 2023 16:36:09 -0400 Subject: shared_widget: Internalize extra setting configuration --- src/yuzu/configuration/shared_widget.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index c25d819f0..88a864b42 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -33,7 +33,7 @@ public: Widget(Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent, bool runtime_lock, std::forward_list>& apply_funcs, RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f, - const Settings::BasicSetting* other_setting = nullptr, + Settings::BasicSetting* other_setting = nullptr, const QString& format = QStringLiteral("")); virtual ~Widget(); @@ -51,11 +51,9 @@ public: private: void CreateCheckBox(const QString& label, std::function& load_func); - void CreateCheckBoxWithLineEdit(const QString& label, - const Settings::BasicSetting* other_setting, + void CreateCheckBoxWithLineEdit(const QString& label, Settings::BasicSetting* other_setting, std::function& load_func); - void CreateCheckBoxWithSpinBox(const QString& label, - const Settings::BasicSetting* other_setting, + void CreateCheckBoxWithSpinBox(const QString& label, Settings::BasicSetting* other_setting, std::function& load_func, const QString& suffix); void CreateCombobox(const QString& label, bool managed, std::function& load_func); void CreateLineEdit(const QString& label, bool managed, std::function& load_func); -- cgit v1.2.3 From 8e151460265f04c7bf4a981b5f97f252a0444c27 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 10 May 2023 17:57:25 -0400 Subject: configure_system: Implement with for loop --- src/yuzu/configuration/shared_widget.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index 88a864b42..9923aa2ea 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -9,6 +9,7 @@ class QComboBox; class QLineEdit; class QSlider; class QCheckBox; +class QDateTimeEdit; namespace Settings { class BasicSetting; @@ -23,6 +24,8 @@ enum class RequestType { Slider, ReverseSlider, LineEdit, + HexEdit, + DateTimeEdit, MaxEnum, }; @@ -33,8 +36,7 @@ public: Widget(Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent, bool runtime_lock, std::forward_list>& apply_funcs, RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f, - Settings::BasicSetting* other_setting = nullptr, - const QString& format = QStringLiteral("")); + Settings::BasicSetting* other_setting = nullptr, const std::string& format = ""); virtual ~Widget(); bool Valid(); @@ -48,13 +50,18 @@ public: QCheckBox* checkbox{}; QSlider* slider{}; QComboBox* combobox{}; + QDateTimeEdit* date_time_edit{}; private: void CreateCheckBox(const QString& label, std::function& load_func); void CreateCheckBoxWithLineEdit(const QString& label, Settings::BasicSetting* other_setting, std::function& load_func); + void CreateCheckBoxWithHexEdit(const QString& label, Settings::BasicSetting* other_setting, + std::function& load_func); void CreateCheckBoxWithSpinBox(const QString& label, Settings::BasicSetting* other_setting, - std::function& load_func, const QString& suffix); + std::function& load_func, const std::string& suffix); + void CreateCheckBoxWithDateTimeEdit(const QString& label, Settings::BasicSetting* other_setting, + std::function& load_func); void CreateCombobox(const QString& label, bool managed, std::function& load_func); void CreateLineEdit(const QString& label, bool managed, std::function& load_func); void CreateSlider(const QString& label, bool reversed, float multiplier, -- cgit v1.2.3 From 4ff8255e4a985e69046e453a9bd38adf80346548 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 9 Jun 2023 16:53:26 -0400 Subject: shared_widget: Refactor helpers Makes checkbox creation an option as opposed to a label. --- src/yuzu/configuration/shared_widget.h | 35 +++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index 9923aa2ea..c4e686574 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -9,6 +9,8 @@ class QComboBox; class QLineEdit; class QSlider; class QCheckBox; +class QLabel; +class QHBoxLayout; class QDateTimeEdit; namespace Settings { @@ -34,9 +36,11 @@ class Widget : public QWidget { public: Widget(Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent, - bool runtime_lock, std::forward_list>& apply_funcs, + bool runtime_lock, std::forward_list>& apply_funcs_, RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr, const std::string& format = ""); + Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_, QWidget* parent_, + std::forward_list>& apply_funcs_); virtual ~Widget(); bool Valid(); @@ -53,23 +57,28 @@ public: QDateTimeEdit* date_time_edit{}; private: - void CreateCheckBox(const QString& label, std::function& load_func); - void CreateCheckBoxWithLineEdit(const QString& label, Settings::BasicSetting* other_setting, - std::function& load_func); - void CreateCheckBoxWithHexEdit(const QString& label, Settings::BasicSetting* other_setting, - std::function& load_func); - void CreateCheckBoxWithSpinBox(const QString& label, Settings::BasicSetting* other_setting, - std::function& load_func, const std::string& suffix); - void CreateCheckBoxWithDateTimeEdit(const QString& label, Settings::BasicSetting* other_setting, - std::function& load_func); - void CreateCombobox(const QString& label, bool managed, std::function& load_func); - void CreateLineEdit(const QString& label, bool managed, std::function& load_func); + QLabel* CreateLabel(const QString& text); + QHBoxLayout* CreateCheckBox(Settings::BasicSetting* bool_setting, const QString& label, + std::function& load_func, bool managed); + + void CreateCombobox(const QString& label, std::function& load_func, bool managed, + Settings::BasicSetting* const other_setting = nullptr); + void CreateLineEdit(const QString& label, std::function& load_func, bool managed, + Settings::BasicSetting* const other_setting = nullptr); + void CreateHexEdit(const QString& label, std::function& load_func, bool managed, + Settings::BasicSetting* const other_setting = nullptr); void CreateSlider(const QString& label, bool reversed, float multiplier, - std::function& load_func); + std::function& load_func, bool managed, + Settings::BasicSetting* const other_setting = nullptr); + void CreateDateTimeEdit(const QString& label, std::function& load_func, bool managed, + bool restrict, Settings::BasicSetting* const other_setting = nullptr); + void CreateSpinBox(const QString& label, std::function& load_func, bool managed, + const std::string& suffix, Settings::BasicSetting* other_setting = nullptr); QWidget* parent; const TranslationMap& translations; Settings::BasicSetting& setting; + std::forward_list>& apply_funcs; bool created{false}; }; -- cgit v1.2.3 From 432f68ad29df7a368ba375d75d667c954e9c80b9 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 18 May 2023 17:54:22 -0400 Subject: configure_audio: Implement ui generation Needs a considerable amount of management specific to some of the comoboboxes due to the audio engine configuration. general: Partial audio config implmentation configure_audio: Implement ui generation Needs a considerable amount of management specific to some of the comoboboxes due to the audio engine configuration. general: Partial audio config implmentation settings: Make audio settings as enums --- src/yuzu/configuration/shared_widget.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index c4e686574..331316040 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -38,15 +38,15 @@ public: Widget(Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent, bool runtime_lock, std::forward_list>& apply_funcs_, 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 QString& string = QStringLiteral("")); Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_, QWidget* parent_, std::forward_list>& apply_funcs_); virtual ~Widget(); bool Valid(); - [[nodiscard]] static QPushButton* CreateRestoreGlobalButton(Settings::BasicSetting& setting, - QWidget* parent); + [[nodiscard]] static QPushButton* CreateRestoreGlobalButton(bool using_global, QWidget* parent); QPushButton* restore_button{}; QLineEdit* line_edit{}; @@ -68,12 +68,12 @@ private: void CreateHexEdit(const QString& label, std::function& load_func, bool managed, Settings::BasicSetting* const other_setting = nullptr); void CreateSlider(const QString& label, bool reversed, float multiplier, - std::function& load_func, bool managed, + std::function& load_func, bool managed, const QString& format, Settings::BasicSetting* const other_setting = nullptr); void CreateDateTimeEdit(const QString& label, std::function& load_func, bool managed, bool restrict, Settings::BasicSetting* const other_setting = nullptr); void CreateSpinBox(const QString& label, std::function& load_func, bool managed, - const std::string& suffix, Settings::BasicSetting* other_setting = nullptr); + const QString& suffix, Settings::BasicSetting* other_setting = nullptr); QWidget* parent; const TranslationMap& translations; @@ -81,6 +81,7 @@ private: std::forward_list>& apply_funcs; bool created{false}; + bool runtime_lock{false}; }; } // namespace ConfigurationShared -- cgit v1.2.3 From c5a3642cb62b4676d0c8b98949daec20e7c02e6b Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 18 May 2023 22:17:36 -0400 Subject: configuration: Use a mapping of setting value to name Makes comboboxes always correspond to the value of the setting they're modifying. --- src/yuzu/configuration/shared_widget.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index 331316040..6077f045d 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -35,13 +35,12 @@ class Widget : public QWidget { Q_OBJECT public: - Widget(Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent, - bool runtime_lock, std::forward_list>& apply_funcs_, + Widget(Settings::BasicSetting* setting, const TranslationMap& translations, + const ComboboxTranslationMap& combobox_translations, QWidget* parent, bool runtime_lock, + std::forward_list>& apply_funcs_, RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr, const QString& string = QStringLiteral("")); - Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_, QWidget* parent_, - std::forward_list>& apply_funcs_); virtual ~Widget(); bool Valid(); @@ -77,6 +76,7 @@ private: QWidget* parent; const TranslationMap& translations; + const ComboboxTranslationMap& combobox_enumerations; Settings::BasicSetting& setting; std::forward_list>& apply_funcs; -- cgit v1.2.3 From d7dd023409d01b09631e02a2dff591c847de32b3 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:45:44 -0400 Subject: shared_widget: Refactor again Starting with combobox Putting code specific to the sub-widget in their own function. --- src/yuzu/configuration/shared_widget.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index 6077f045d..2ed738a06 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -43,7 +43,7 @@ public: const QString& string = QStringLiteral("")); virtual ~Widget(); - bool Valid(); + bool Valid() const; [[nodiscard]] static QPushButton* CreateRestoreGlobalButton(bool using_global, QWidget* parent); @@ -56,12 +56,16 @@ public: QDateTimeEdit* date_time_edit{}; private: + void SetupComponent(const QString& label, std::function& load_func, bool managed, + RequestType request, Settings::BasicSetting* other_setting); + QLabel* CreateLabel(const QString& text); QHBoxLayout* CreateCheckBox(Settings::BasicSetting* bool_setting, const QString& label, std::function& load_func, bool managed); - void CreateCombobox(const QString& label, std::function& load_func, bool managed, - Settings::BasicSetting* const other_setting = nullptr); + QWidget* CreateCombobox(std::function& serializer, + std::function& restore_func, + const std::function& touched); void CreateLineEdit(const QString& label, std::function& load_func, bool managed, Settings::BasicSetting* const other_setting = nullptr); void CreateHexEdit(const QString& label, std::function& load_func, bool managed, -- cgit v1.2.3 From 9a2a92673c8cae4589e0e801f49235a4890719f9 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 6 Jun 2023 21:20:37 -0400 Subject: shared_widget: Complete refactoring Reduces code bloat a good bit by moving code specific to each sub widget to their own functions. --- src/yuzu/configuration/shared_widget.h | 36 ++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index 2ed738a06..01348e442 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -57,26 +57,32 @@ public: private: void SetupComponent(const QString& label, std::function& load_func, bool managed, - RequestType request, Settings::BasicSetting* other_setting); + RequestType request, float multiplier, + Settings::BasicSetting* other_setting, const QString& string); QLabel* CreateLabel(const QString& text); - QHBoxLayout* CreateCheckBox(Settings::BasicSetting* bool_setting, const QString& label, - std::function& load_func, bool managed); + QWidget* CreateCheckBox(Settings::BasicSetting* bool_setting, const QString& label, + std::function& serializer, + std::function& restore_func, + const std::function& touch); QWidget* CreateCombobox(std::function& serializer, std::function& restore_func, - const std::function& touched); - void CreateLineEdit(const QString& label, std::function& load_func, bool managed, - Settings::BasicSetting* const other_setting = nullptr); - void CreateHexEdit(const QString& label, std::function& load_func, bool managed, - Settings::BasicSetting* const other_setting = nullptr); - void CreateSlider(const QString& label, bool reversed, float multiplier, - std::function& load_func, bool managed, const QString& format, - Settings::BasicSetting* const other_setting = nullptr); - void CreateDateTimeEdit(const QString& label, std::function& load_func, bool managed, - bool restrict, Settings::BasicSetting* const other_setting = nullptr); - void CreateSpinBox(const QString& label, std::function& load_func, bool managed, - const QString& suffix, Settings::BasicSetting* other_setting = nullptr); + const std::function& touch); + QWidget* CreateLineEdit(std::function& serializer, + std::function& restore_func, const std::function& touch, + bool managed = true); + QWidget* CreateHexEdit(std::function& serializer, + std::function& restore_func, const std::function& touch); + QWidget* CreateSlider(bool reversed, float multiplier, const QString& format, + std::function& serializer, + std::function& restore_func, const std::function& touch); + QWidget* CreateDateTimeEdit(bool disabled, bool restrict, + std::function& serializer, + std::function& restore_func, + const std::function& touch); + QWidget* CreateSpinBox(const QString& suffix, std::function& serializer, + std::function& restore_func, const std::function& touch); QWidget* parent; const TranslationMap& translations; -- cgit v1.2.3 From c5f8b909ecee8d58b86b3e70e5e6defe56d4780c Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 10 Jun 2023 00:45:04 -0400 Subject: shared_widget: Add SPDX header --- src/yuzu/configuration/shared_widget.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index 01348e442..d99a5eace 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + #pragma once #include "yuzu/configuration/configuration_shared.h" -- cgit v1.2.3 From 3b0650b70d8196b30102e73305066e0dba9da8fe Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 12 Jun 2023 17:42:21 -0400 Subject: configuration/shared: Clean up includes [IWYU] --- src/yuzu/configuration/shared_widget.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index d99a5eace..8ce72b238 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -3,22 +3,28 @@ #pragma once -#include "yuzu/configuration/configuration_shared.h" +#include +#include +#include +#include +#include +#include +#include #include "yuzu/configuration/shared_translation.h" -class QPushButton; -class QSpinBox; +class QCheckBox; class QComboBox; +class QDateTimeEdit; +class QLabel; class QLineEdit; +class QObject; +class QPushButton; class QSlider; -class QCheckBox; -class QLabel; -class QHBoxLayout; -class QDateTimeEdit; +class QSpinBox; namespace Settings { class BasicSetting; -} +} // namespace Settings namespace ConfigurationShared { -- cgit v1.2.3 From 6935332cbab11b08ce6b644c48c6d82e94bd90f9 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 15 Jun 2023 16:45:09 -0400 Subject: shared_widget: Some documentation, add shorter constructor The shorter constructor enables us to specify some options without needing to specify the default values of multiplier which wasn't always appropriate and could be confusing. --- src/yuzu/configuration/shared_widget.h | 65 +++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 8 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index 8ce72b238..10d2d353e 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -44,20 +44,69 @@ class Widget : public QWidget { Q_OBJECT public: - Widget(Settings::BasicSetting* setting, const TranslationMap& translations, - const ComboboxTranslationMap& combobox_translations, QWidget* parent, bool runtime_lock, - std::forward_list>& apply_funcs_, - RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f, - Settings::BasicSetting* other_setting = nullptr, - const QString& string = QStringLiteral("")); + /** + * Shorter-hand version of the constructor + * + * @param setting The primary Setting to create the Widget for + * @param translations Map of translations to display on the left side label/checkbox + * @param combobox_translations Map of translations for enumerating combo boxes + * @param parent Qt parent + * @param runtime_lock Emulated guest powered on state, for use on settings that should be + * configured during guest execution + * @param apply_funcs_ List to append, functions to run to apply the widget state to the setting + * @param other_setting Second setting to modify, to replace the label with a checkbox + * @param request What type of data representation component to create -- not always respected + * for the Setting data type + * @param string Set to specify formats for Slider feedback labels or SpinBox + */ + explicit Widget(Settings::BasicSetting* setting, const TranslationMap& translations, + const ComboboxTranslationMap& combobox_translations, QWidget* parent, + bool runtime_lock, std::forward_list>& apply_funcs_, + Settings::BasicSetting* other_setting, + RequestType request = RequestType::Default, + const QString& string = QStringLiteral("")); + + /** + * @param setting The primary Setting to create the Widget for + * @param translations Map of translations to display on the left side label/checkbox + * @param combobox_translations Map of translations for enumerating combo boxes + * @param parent Qt parent + * @param runtime_lock Emulated guest powered on state, for use on settings that should be + * configured during guest execution + * @param apply_funcs_ List to append, functions to run to apply the widget state to the setting + * @param request What type of data representation component to create -- not always respected + * for the Setting data type + * @param managed Set true if the caller will set up component data and handling + * @param multiplier Value to multiply the slider feedback label + * @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 + */ + explicit Widget(Settings::BasicSetting* setting, const TranslationMap& translations, + const ComboboxTranslationMap& combobox_translations, QWidget* parent, + bool runtime_lock, std::forward_list>& apply_funcs_, + RequestType request = RequestType::Default, bool managed = true, + float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr, + const QString& string = QStringLiteral("")); virtual ~Widget(); + /** + * @returns True if the Widget successfully created the components for the setting + */ bool Valid() const; + /** + * Creates a button to appear when a setting has been modified. This exists for custom + * configurations and wasn't designed to work for the global configuration. It has public access + * for settings that need to be unmanaged but can be custom. + * + * @param using_global The global state of the setting this button is for + * @param parent QWidget parent + */ [[nodiscard]] static QPushButton* CreateRestoreGlobalButton(bool using_global, QWidget* parent); - QPushButton* restore_button{}; - QLineEdit* line_edit{}; + // Direct handles to sub components created + QPushButton* restore_button{}; ///< Restore button for custom configurations + QLineEdit* line_edit{}; ///< QLineEdit, used for LineEdit and HexEdit QSpinBox* spinbox{}; QCheckBox* checkbox{}; QSlider* slider{}; -- cgit v1.2.3 From ad645c29a44bd117cad90bda56e1f4d6296f2666 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 01:42:42 -0400 Subject: configuration: Use a builder to create widgets This gets rid of some repeated code and sets us up to send more information to the new widget. --- src/yuzu/configuration/shared_widget.h | 50 +++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index 10d2d353e..e8c281b81 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -44,28 +45,6 @@ class Widget : public QWidget { Q_OBJECT public: - /** - * Shorter-hand version of the constructor - * - * @param setting The primary Setting to create the Widget for - * @param translations Map of translations to display on the left side label/checkbox - * @param combobox_translations Map of translations for enumerating combo boxes - * @param parent Qt parent - * @param runtime_lock Emulated guest powered on state, for use on settings that should be - * configured during guest execution - * @param apply_funcs_ List to append, functions to run to apply the widget state to the setting - * @param other_setting Second setting to modify, to replace the label with a checkbox - * @param request What type of data representation component to create -- not always respected - * for the Setting data type - * @param string Set to specify formats for Slider feedback labels or SpinBox - */ - explicit Widget(Settings::BasicSetting* setting, const TranslationMap& translations, - const ComboboxTranslationMap& combobox_translations, QWidget* parent, - bool runtime_lock, std::forward_list>& apply_funcs_, - Settings::BasicSetting* other_setting, - RequestType request = RequestType::Default, - const QString& string = QStringLiteral("")); - /** * @param setting The primary Setting to create the Widget for * @param translations Map of translations to display on the left side label/checkbox @@ -152,4 +131,31 @@ private: bool runtime_lock{false}; }; +class Builder { +public: + explicit Builder(QWidget* parent, bool runtime_lock); + ~Builder(); + + Widget* BuildWidget(Settings::BasicSetting* setting, + std::forward_list>& apply_funcs, + RequestType request = RequestType::Default, bool managed = true, + float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr, + const QString& string = QStringLiteral("")) const; + + Widget* BuildWidget(Settings::BasicSetting* setting, + std::forward_list>& apply_funcs, + Settings::BasicSetting* other_setting, + RequestType request = RequestType::Default, + const QString& string = QStringLiteral("")) const; + + const ComboboxTranslationMap& ComboboxTranslations() const; + +private: + std::unique_ptr translations; + std::unique_ptr combobox_translations; + + QWidget* parent; + const bool runtime_lock; +}; + } // namespace ConfigurationShared -- cgit v1.2.3 From 926f3e3d3e6ff57633d2d44085f02754ffe1c988 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 21 Jun 2023 05:04:21 -0400 Subject: settings,configuration: Add a default suffix --- src/yuzu/configuration/shared_widget.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index e8c281b81..b3f9efd78 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -58,14 +58,14 @@ public: * @param managed Set true if the caller will set up component data and handling * @param multiplier Value to multiply the slider feedback label * @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, const ComboboxTranslationMap& combobox_translations, QWidget* parent, bool runtime_lock, std::forward_list>& apply_funcs_, RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr, - const QString& string = QStringLiteral("")); + const QString& suffix = QStringLiteral("")); virtual ~Widget(); /** @@ -95,7 +95,7 @@ public: private: void SetupComponent(const QString& label, std::function& load_func, bool managed, RequestType request, float multiplier, - Settings::BasicSetting* other_setting, const QString& string); + Settings::BasicSetting* other_setting, const QString& suffix); QLabel* CreateLabel(const QString& text); QWidget* CreateCheckBox(Settings::BasicSetting* bool_setting, const QString& label, @@ -111,7 +111,7 @@ private: bool managed = true); QWidget* CreateHexEdit(std::function& serializer, std::function& restore_func, const std::function& touch); - QWidget* CreateSlider(bool reversed, float multiplier, const QString& format, + QWidget* CreateSlider(bool reversed, float multiplier, const QString& suffix, std::function& serializer, std::function& restore_func, const std::function& touch); QWidget* CreateDateTimeEdit(bool disabled, bool restrict, @@ -140,13 +140,13 @@ public: std::forward_list>& apply_funcs, RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr, - const QString& string = QStringLiteral("")) const; + const QString& suffix = QStringLiteral("")) const; Widget* BuildWidget(Settings::BasicSetting* setting, std::forward_list>& apply_funcs, Settings::BasicSetting* other_setting, RequestType request = RequestType::Default, - const QString& string = QStringLiteral("")) const; + const QString& suffix = QStringLiteral("")) const; const ComboboxTranslationMap& ComboboxTranslations() const; -- cgit v1.2.3 From 17b9c1e1715a16bebcdd92c02ce7f7e503212462 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 21 Jul 2023 23:09:09 -0400 Subject: common,qt-config: Remove usage of forward_list --- src/yuzu/configuration/shared_widget.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/yuzu/configuration/shared_widget.h') diff --git a/src/yuzu/configuration/shared_widget.h b/src/yuzu/configuration/shared_widget.h index b3f9efd78..e64693bab 100644 --- a/src/yuzu/configuration/shared_widget.h +++ b/src/yuzu/configuration/shared_widget.h @@ -3,10 +3,10 @@ #pragma once -#include #include #include #include +#include #include #include #include @@ -62,7 +62,7 @@ public: */ explicit Widget(Settings::BasicSetting* setting, const TranslationMap& translations, const ComboboxTranslationMap& combobox_translations, QWidget* parent, - bool runtime_lock, std::forward_list>& apply_funcs_, + bool runtime_lock, std::vector>& apply_funcs_, RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr, const QString& suffix = QStringLiteral("")); @@ -125,7 +125,7 @@ private: const TranslationMap& translations; const ComboboxTranslationMap& combobox_enumerations; Settings::BasicSetting& setting; - std::forward_list>& apply_funcs; + std::vector>& apply_funcs; bool created{false}; bool runtime_lock{false}; @@ -137,13 +137,13 @@ public: ~Builder(); Widget* BuildWidget(Settings::BasicSetting* setting, - std::forward_list>& apply_funcs, + std::vector>& apply_funcs, RequestType request = RequestType::Default, bool managed = true, float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr, const QString& suffix = QStringLiteral("")) const; Widget* BuildWidget(Settings::BasicSetting* setting, - std::forward_list>& apply_funcs, + std::vector>& apply_funcs, Settings::BasicSetting* other_setting, RequestType request = RequestType::Default, const QString& suffix = QStringLiteral("")) const; -- cgit v1.2.3