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