diff options
| author | 2023-05-09 01:38:01 -0400 | |
|---|---|---|
| committer | 2023-07-21 10:56:07 -0400 | |
| commit | 827082c5ac30ff488016d168e3ca93021eb612e4 (patch) | |
| tree | 8a45c8f304d22b3c814f4834bffb22c5182bc7a1 /src | |
| parent | shared_translation: Add UI widget translations (diff) | |
| download | yuzu-827082c5ac30ff488016d168e3ca93021eb612e4.tar.gz yuzu-827082c5ac30ff488016d168e3ca93021eb612e4.tar.xz yuzu-827082c5ac30ff488016d168e3ca93021eb612e4.zip | |
configure_general: Generate UI using containers
This leaves per-game config's General tab empty?
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/configuration/configure_dialog.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_general.cpp | 105 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_general.h | 8 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_general.ui | 87 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_per_game.cpp | 2 |
5 files changed, 41 insertions, 163 deletions
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 5b356a074..8baa8de1e 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp | |||
| @@ -38,7 +38,7 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry_, | |||
| 38 | cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, this)}, | 38 | cpu_tab{std::make_unique<ConfigureCpu>(system_, nullptr, this)}, |
| 39 | debug_tab_tab{std::make_unique<ConfigureDebugTab>(system_, this)}, | 39 | debug_tab_tab{std::make_unique<ConfigureDebugTab>(system_, this)}, |
| 40 | filesystem_tab{std::make_unique<ConfigureFilesystem>(this)}, | 40 | filesystem_tab{std::make_unique<ConfigureFilesystem>(this)}, |
| 41 | general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, this)}, | 41 | general_tab{std::make_unique<ConfigureGeneral>(system_, nullptr, *translations, this)}, |
| 42 | graphics_advanced_tab{ | 42 | graphics_advanced_tab{ |
| 43 | std::make_unique<ConfigureGraphicsAdvanced>(system_, nullptr, *translations, this)}, | 43 | std::make_unique<ConfigureGraphicsAdvanced>(system_, nullptr, *translations, this)}, |
| 44 | graphics_tab{std::make_unique<ConfigureGraphics>( | 44 | graphics_tab{std::make_unique<ConfigureGraphics>( |
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 764ff68b3..743ea824c 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp | |||
| @@ -9,23 +9,19 @@ | |||
| 9 | #include "ui_configure_general.h" | 9 | #include "ui_configure_general.h" |
| 10 | #include "yuzu/configuration/configuration_shared.h" | 10 | #include "yuzu/configuration/configuration_shared.h" |
| 11 | #include "yuzu/configuration/configure_general.h" | 11 | #include "yuzu/configuration/configure_general.h" |
| 12 | #include "yuzu/configuration/shared_widget.h" | ||
| 12 | #include "yuzu/uisettings.h" | 13 | #include "yuzu/uisettings.h" |
| 13 | 14 | ||
| 14 | ConfigureGeneral::ConfigureGeneral( | 15 | ConfigureGeneral::ConfigureGeneral( |
| 15 | const Core::System& system_, | 16 | const Core::System& system_, |
| 16 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, QWidget* parent) | 17 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, |
| 17 | : Tab(group, parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_} { | 18 | const ConfigurationShared::TranslationMap& translations_, QWidget* parent) |
| 19 | : Tab(group, parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_}, | ||
| 20 | translations{translations_} { | ||
| 18 | ui->setupUi(this); | 21 | ui->setupUi(this); |
| 19 | 22 | ||
| 20 | SetupPerGameUI(); | ||
| 21 | |||
| 22 | SetConfiguration(); | 23 | SetConfiguration(); |
| 23 | 24 | ||
| 24 | // if (Settings::IsConfiguringGlobal()) { | ||
| 25 | // connect(ui->toggle_speed_limit, &QCheckBox::clicked, ui->speed_limit, | ||
| 26 | // [this]() { ui->speed_limit->setEnabled(ui->toggle_speed_limit->isChecked()); }); | ||
| 27 | // } | ||
| 28 | |||
| 29 | connect(ui->button_reset_defaults, &QPushButton::clicked, this, | 25 | connect(ui->button_reset_defaults, &QPushButton::clicked, this, |
| 30 | &ConfigureGeneral::ResetDefaults); | 26 | &ConfigureGeneral::ResetDefaults); |
| 31 | } | 27 | } |
| @@ -34,29 +30,20 @@ ConfigureGeneral::~ConfigureGeneral() = default; | |||
| 34 | 30 | ||
| 35 | void ConfigureGeneral::SetConfiguration() { | 31 | void ConfigureGeneral::SetConfiguration() { |
| 36 | const bool runtime_lock = !system.IsPoweredOn(); | 32 | const bool runtime_lock = !system.IsPoweredOn(); |
| 33 | QLayout& layout = *ui->general_widget->layout(); | ||
| 37 | 34 | ||
| 38 | ui->use_multi_core->setEnabled(runtime_lock); | 35 | for (const auto setting : |
| 39 | ui->use_multi_core->setChecked(Settings::values.use_multi_core.GetValue()); | 36 | UISettings::values.linkage.by_category[Settings::Category::UiGeneral]) { |
| 40 | 37 | ConfigurationShared::Widget* widget = | |
| 41 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing.GetValue()); | 38 | new ConfigurationShared::Widget(setting, translations, this, runtime_lock, apply_funcs); |
| 42 | ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot.GetValue()); | ||
| 43 | ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background.GetValue()); | ||
| 44 | ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse.GetValue()); | ||
| 45 | ui->toggle_controller_applet_disabled->setEnabled(runtime_lock); | ||
| 46 | ui->toggle_controller_applet_disabled->setChecked( | ||
| 47 | UISettings::values.controller_applet_disabled.GetValue()); | ||
| 48 | |||
| 49 | // ui->toggle_speed_limit->setChecked(Settings::values.use_speed_limit.GetValue()); | ||
| 50 | // ui->speed_limit->setValue(Settings::values.speed_limit.GetValue()); | ||
| 51 | 39 | ||
| 52 | ui->button_reset_defaults->setEnabled(runtime_lock); | 40 | if (!widget->Valid()) { |
| 41 | delete widget; | ||
| 42 | continue; | ||
| 43 | } | ||
| 53 | 44 | ||
| 54 | // if (Settings::IsConfiguringGlobal()) { | 45 | layout.addWidget(widget); |
| 55 | // ui->speed_limit->setEnabled(Settings::values.use_speed_limit.GetValue()); | 46 | } |
| 56 | // } else { | ||
| 57 | // ui->speed_limit->setEnabled(Settings::values.use_speed_limit.GetValue() && | ||
| 58 | // use_speed_limit != ConfigurationShared::CheckState::Global); | ||
| 59 | // } | ||
| 60 | } | 47 | } |
| 61 | 48 | ||
| 62 | // Called to set the callback when resetting settings to defaults | 49 | // Called to set the callback when resetting settings to defaults |
| @@ -79,32 +66,9 @@ void ConfigureGeneral::ResetDefaults() { | |||
| 79 | } | 66 | } |
| 80 | 67 | ||
| 81 | void ConfigureGeneral::ApplyConfiguration() { | 68 | void ConfigureGeneral::ApplyConfiguration() { |
| 82 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_multi_core, ui->use_multi_core, | 69 | bool powered_on = system.IsPoweredOn(); |
| 83 | use_multi_core); | 70 | for (const auto& func : apply_funcs) { |
| 84 | 71 | func(powered_on); | |
| 85 | if (Settings::IsConfiguringGlobal()) { | ||
| 86 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); | ||
| 87 | UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); | ||
| 88 | UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); | ||
| 89 | UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); | ||
| 90 | UISettings::values.controller_applet_disabled = | ||
| 91 | ui->toggle_controller_applet_disabled->isChecked(); | ||
| 92 | |||
| 93 | // Guard if during game and set to game-specific value | ||
| 94 | // if (Settings::values.use_speed_limit.UsingGlobal()) { | ||
| 95 | // Settings::values.use_speed_limit.SetValue(ui->toggle_speed_limit->checkState() == | ||
| 96 | // Qt::Checked); | ||
| 97 | // Settings::values.speed_limit.SetValue(ui->speed_limit->value()); | ||
| 98 | // } | ||
| 99 | } else { | ||
| 100 | // bool global_speed_limit = use_speed_limit == ConfigurationShared::CheckState::Global; | ||
| 101 | // Settings::values.use_speed_limit.SetGlobal(global_speed_limit); | ||
| 102 | // Settings::values.speed_limit.SetGlobal(global_speed_limit); | ||
| 103 | // if (!global_speed_limit) { | ||
| 104 | // Settings::values.use_speed_limit.SetValue(ui->toggle_speed_limit->checkState() == | ||
| 105 | // Qt::Checked); | ||
| 106 | // Settings::values.speed_limit.SetValue(ui->speed_limit->value()); | ||
| 107 | // } | ||
| 108 | } | 72 | } |
| 109 | } | 73 | } |
| 110 | 74 | ||
| @@ -119,34 +83,3 @@ void ConfigureGeneral::changeEvent(QEvent* event) { | |||
| 119 | void ConfigureGeneral::RetranslateUI() { | 83 | void ConfigureGeneral::RetranslateUI() { |
| 120 | ui->retranslateUi(this); | 84 | ui->retranslateUi(this); |
| 121 | } | 85 | } |
| 122 | |||
| 123 | void ConfigureGeneral::SetupPerGameUI() { | ||
| 124 | if (Settings::IsConfiguringGlobal()) { | ||
| 125 | // Disables each setting if: | ||
| 126 | // - A game is running (thus settings in use), and | ||
| 127 | // - A non-global setting is applied. | ||
| 128 | // ui->toggle_speed_limit->setEnabled(Settings::values.use_speed_limit.UsingGlobal()); | ||
| 129 | // ui->speed_limit->setEnabled(Settings::values.speed_limit.UsingGlobal()); | ||
| 130 | |||
| 131 | return; | ||
| 132 | } | ||
| 133 | |||
| 134 | ui->toggle_check_exit->setVisible(false); | ||
| 135 | ui->toggle_user_on_boot->setVisible(false); | ||
| 136 | ui->toggle_background_pause->setVisible(false); | ||
| 137 | ui->toggle_hide_mouse->setVisible(false); | ||
| 138 | ui->toggle_controller_applet_disabled->setVisible(false); | ||
| 139 | |||
| 140 | ui->button_reset_defaults->setVisible(false); | ||
| 141 | |||
| 142 | // ConfigurationShared::SetColoredTristate(ui->toggle_speed_limit, | ||
| 143 | // Settings::values.use_speed_limit, use_speed_limit); | ||
| 144 | ConfigurationShared::SetColoredTristate(ui->use_multi_core, Settings::values.use_multi_core, | ||
| 145 | use_multi_core); | ||
| 146 | |||
| 147 | // connect(ui->toggle_speed_limit, &QCheckBox::clicked, ui->speed_limit, [this]() { | ||
| 148 | // ui->speed_limit->setEnabled(ui->toggle_speed_limit->isChecked() && | ||
| 149 | // (use_speed_limit != | ||
| 150 | // ConfigurationShared::CheckState::Global)); | ||
| 151 | // }); | ||
| 152 | } | ||
diff --git a/src/yuzu/configuration/configure_general.h b/src/yuzu/configuration/configure_general.h index 0aad69f0a..7692c16da 100644 --- a/src/yuzu/configuration/configure_general.h +++ b/src/yuzu/configuration/configure_general.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <QWidget> | 8 | #include <QWidget> |
| 9 | #include "yuzu/configuration/configuration_shared.h" | 9 | #include "yuzu/configuration/configuration_shared.h" |
| 10 | #include "yuzu/configuration/shared_widget.h" | ||
| 10 | 11 | ||
| 11 | namespace Core { | 12 | namespace Core { |
| 12 | class System; | 13 | class System; |
| @@ -23,6 +24,7 @@ class ConfigureGeneral : public ConfigurationShared::Tab { | |||
| 23 | public: | 24 | public: |
| 24 | explicit ConfigureGeneral(const Core::System& system_, | 25 | explicit ConfigureGeneral(const Core::System& system_, |
| 25 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, | 26 | std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, |
| 27 | const ConfigurationShared::TranslationMap& translations_, | ||
| 26 | QWidget* parent = nullptr); | 28 | QWidget* parent = nullptr); |
| 27 | ~ConfigureGeneral() override; | 29 | ~ConfigureGeneral() override; |
| 28 | 30 | ||
| @@ -35,14 +37,12 @@ private: | |||
| 35 | void changeEvent(QEvent* event) override; | 37 | void changeEvent(QEvent* event) override; |
| 36 | void RetranslateUI(); | 38 | void RetranslateUI(); |
| 37 | 39 | ||
| 38 | void SetupPerGameUI(); | ||
| 39 | |||
| 40 | std::function<void()> reset_callback; | 40 | std::function<void()> reset_callback; |
| 41 | 41 | ||
| 42 | std::unique_ptr<Ui::ConfigureGeneral> ui; | 42 | std::unique_ptr<Ui::ConfigureGeneral> ui; |
| 43 | 43 | ||
| 44 | ConfigurationShared::CheckState use_speed_limit; | 44 | std::forward_list<std::function<void(bool)>> apply_funcs{}; |
| 45 | ConfigurationShared::CheckState use_multi_core; | ||
| 46 | 45 | ||
| 47 | const Core::System& system; | 46 | const Core::System& system; |
| 47 | const ConfigurationShared::TranslationMap& translations; | ||
| 48 | }; | 48 | }; |
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui index fe757d011..a10e7d3a5 100644 --- a/src/yuzu/configuration/configure_general.ui +++ b/src/yuzu/configuration/configure_general.ui | |||
| @@ -26,77 +26,22 @@ | |||
| 26 | </property> | 26 | </property> |
| 27 | <layout class="QHBoxLayout" name="GeneralHorizontalLayout"> | 27 | <layout class="QHBoxLayout" name="GeneralHorizontalLayout"> |
| 28 | <item> | 28 | <item> |
| 29 | <layout class="QVBoxLayout" name="GeneralVerticalLayout"> | 29 | <widget class="QWidget" name="general_widget" native="true"> |
| 30 | <item> | 30 | <layout class="QVBoxLayout" name="GeneralVerticalLayout"> |
| 31 | <layout class="QHBoxLayout" name="horizontalLayout_2"> | 31 | <property name="leftMargin"> |
| 32 | <item> | 32 | <number>0</number> |
| 33 | <widget class="QCheckBox" name="toggle_speed_limit"> | 33 | </property> |
| 34 | <property name="text"> | 34 | <property name="topMargin"> |
| 35 | <string>Limit Speed Percent</string> | 35 | <number>0</number> |
| 36 | </property> | 36 | </property> |
| 37 | </widget> | 37 | <property name="rightMargin"> |
| 38 | </item> | 38 | <number>0</number> |
| 39 | <item> | 39 | </property> |
| 40 | <widget class="QSpinBox" name="speed_limit"> | 40 | <property name="bottomMargin"> |
| 41 | <property name="suffix"> | 41 | <number>0</number> |
| 42 | <string>%</string> | 42 | </property> |
| 43 | </property> | 43 | </layout> |
| 44 | <property name="minimum"> | 44 | </widget> |
| 45 | <number>1</number> | ||
| 46 | </property> | ||
| 47 | <property name="maximum"> | ||
| 48 | <number>9999</number> | ||
| 49 | </property> | ||
| 50 | <property name="value"> | ||
| 51 | <number>100</number> | ||
| 52 | </property> | ||
| 53 | </widget> | ||
| 54 | </item> | ||
| 55 | </layout> | ||
| 56 | </item> | ||
| 57 | <item> | ||
| 58 | <widget class="QCheckBox" name="use_multi_core"> | ||
| 59 | <property name="text"> | ||
| 60 | <string>Multicore CPU Emulation</string> | ||
| 61 | </property> | ||
| 62 | </widget> | ||
| 63 | </item> | ||
| 64 | <item> | ||
| 65 | <widget class="QCheckBox" name="toggle_check_exit"> | ||
| 66 | <property name="text"> | ||
| 67 | <string>Confirm exit while emulation is running</string> | ||
| 68 | </property> | ||
| 69 | </widget> | ||
| 70 | </item> | ||
| 71 | <item> | ||
| 72 | <widget class="QCheckBox" name="toggle_user_on_boot"> | ||
| 73 | <property name="text"> | ||
| 74 | <string>Prompt for user on game boot</string> | ||
| 75 | </property> | ||
| 76 | </widget> | ||
| 77 | </item> | ||
| 78 | <item> | ||
| 79 | <widget class="QCheckBox" name="toggle_background_pause"> | ||
| 80 | <property name="text"> | ||
| 81 | <string>Pause emulation when in background</string> | ||
| 82 | </property> | ||
| 83 | </widget> | ||
| 84 | </item> | ||
| 85 | <item> | ||
| 86 | <widget class="QCheckBox" name="toggle_hide_mouse"> | ||
| 87 | <property name="text"> | ||
| 88 | <string>Hide mouse on inactivity</string> | ||
| 89 | </property> | ||
| 90 | </widget> | ||
| 91 | </item> | ||
| 92 | <item> | ||
| 93 | <widget class="QCheckBox" name="toggle_controller_applet_disabled"> | ||
| 94 | <property name="text"> | ||
| 95 | <string>Disable controller applet</string> | ||
| 96 | </property> | ||
| 97 | </widget> | ||
| 98 | </item> | ||
| 99 | </layout> | ||
| 100 | </item> | 45 | </item> |
| 101 | </layout> | 46 | </layout> |
| 102 | </widget> | 47 | </widget> |
diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index 9e229977d..05da9bda0 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp | |||
| @@ -53,7 +53,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st | |||
| 53 | addons_tab = std::make_unique<ConfigurePerGameAddons>(system_, this); | 53 | addons_tab = std::make_unique<ConfigurePerGameAddons>(system_, this); |
| 54 | audio_tab = std::make_unique<ConfigureAudio>(system_, tab_group, this); | 54 | audio_tab = std::make_unique<ConfigureAudio>(system_, tab_group, this); |
| 55 | cpu_tab = std::make_unique<ConfigureCpu>(system_, tab_group, this); | 55 | cpu_tab = std::make_unique<ConfigureCpu>(system_, tab_group, this); |
| 56 | general_tab = std::make_unique<ConfigureGeneral>(system_, tab_group, this); | 56 | general_tab = std::make_unique<ConfigureGeneral>(system_, tab_group, *translations, this); |
| 57 | graphics_advanced_tab = | 57 | graphics_advanced_tab = |
| 58 | std::make_unique<ConfigureGraphicsAdvanced>(system_, tab_group, *translations, this); | 58 | std::make_unique<ConfigureGraphicsAdvanced>(system_, tab_group, *translations, this); |
| 59 | graphics_tab = std::make_unique<ConfigureGraphics>( | 59 | graphics_tab = std::make_unique<ConfigureGraphics>( |