diff options
| author | 2021-05-17 16:13:39 -0400 | |
|---|---|---|
| committer | 2021-05-25 02:25:39 -0400 | |
| commit | c1bad4357ac90de0dc25f2d4fb3ae7f9dbe138b6 (patch) | |
| tree | 75b8144692a32c5f71fe08d7d2186cfe18f4d12c /src | |
| parent | Merge pull request #6321 from lat9nq/per-game-cpu (diff) | |
| download | yuzu-c1bad4357ac90de0dc25f2d4fb3ae7f9dbe138b6.tar.gz yuzu-c1bad4357ac90de0dc25f2d4fb3ae7f9dbe138b6.tar.xz yuzu-c1bad4357ac90de0dc25f2d4fb3ae7f9dbe138b6.zip | |
yuzu qt: Add an Apply button to configuration dialogs
Most of the code already exists to do this, but the Apply button itself
was never added. This adds a button and boolean that tells yuzu to save
the configuration after applying settings, even if close/Cancel is
pressed on the dialog. Changes after applying will not be saved when
Cancel is pressed, though.
Diffstat (limited to '')
| -rw-r--r-- | src/yuzu/configuration/configure_dialog.cpp | 14 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_dialog.h | 3 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_per_game.cpp | 14 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_per_game.h | 2 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 40 | ||||
| -rw-r--r-- | src/yuzu/uisettings.h | 2 |
6 files changed, 57 insertions, 18 deletions
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 3ad40d2b3..6028135c5 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp | |||
| @@ -2,8 +2,11 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <QAbstractButton> | ||
| 6 | #include <QDialogButtonBox> | ||
| 5 | #include <QHash> | 7 | #include <QHash> |
| 6 | #include <QListWidgetItem> | 8 | #include <QListWidgetItem> |
| 9 | #include <QPushButton> | ||
| 7 | #include <QSignalBlocker> | 10 | #include <QSignalBlocker> |
| 8 | #include "common/settings.h" | 11 | #include "common/settings.h" |
| 9 | #include "core/core.h" | 12 | #include "core/core.h" |
| @@ -31,6 +34,12 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, | |||
| 31 | connect(ui->selectorList, &QListWidget::itemSelectionChanged, this, | 34 | connect(ui->selectorList, &QListWidget::itemSelectionChanged, this, |
| 32 | &ConfigureDialog::UpdateVisibleTabs); | 35 | &ConfigureDialog::UpdateVisibleTabs); |
| 33 | 36 | ||
| 37 | if (Core::System::GetInstance().IsPoweredOn()) { | ||
| 38 | QPushButton* apply_button = ui->buttonBox->addButton(QDialogButtonBox::Apply); | ||
| 39 | connect(apply_button, &QAbstractButton::clicked, this, | ||
| 40 | &ConfigureDialog::HandleApplyButtonClicked); | ||
| 41 | } | ||
| 42 | |||
| 34 | adjustSize(); | 43 | adjustSize(); |
| 35 | ui->selectorList->setCurrentRow(0); | 44 | ui->selectorList->setCurrentRow(0); |
| 36 | } | 45 | } |
| @@ -80,6 +89,11 @@ void ConfigureDialog::RetranslateUI() { | |||
| 80 | ui->tabWidget->setCurrentIndex(old_index); | 89 | ui->tabWidget->setCurrentIndex(old_index); |
| 81 | } | 90 | } |
| 82 | 91 | ||
| 92 | void ConfigureDialog::HandleApplyButtonClicked() { | ||
| 93 | UISettings::values.configuration_applied = true; | ||
| 94 | ApplyConfiguration(); | ||
| 95 | } | ||
| 96 | |||
| 83 | Q_DECLARE_METATYPE(QList<QWidget*>); | 97 | Q_DECLARE_METATYPE(QList<QWidget*>); |
| 84 | 98 | ||
| 85 | void ConfigureDialog::PopulateSelectionList() { | 99 | void ConfigureDialog::PopulateSelectionList() { |
diff --git a/src/yuzu/configuration/configure_dialog.h b/src/yuzu/configuration/configure_dialog.h index 570c3b941..abe019635 100644 --- a/src/yuzu/configuration/configure_dialog.h +++ b/src/yuzu/configuration/configure_dialog.h | |||
| @@ -35,9 +35,10 @@ signals: | |||
| 35 | 35 | ||
| 36 | private: | 36 | private: |
| 37 | void changeEvent(QEvent* event) override; | 37 | void changeEvent(QEvent* event) override; |
| 38 | |||
| 39 | void RetranslateUI(); | 38 | void RetranslateUI(); |
| 40 | 39 | ||
| 40 | void HandleApplyButtonClicked(); | ||
| 41 | |||
| 41 | void SetConfiguration(); | 42 | void SetConfiguration(); |
| 42 | void UpdateVisibleTabs(); | 43 | void UpdateVisibleTabs(); |
| 43 | void PopulateSelectionList(); | 44 | void PopulateSelectionList(); |
diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index f550567e2..aeeb080bc 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp | |||
| @@ -6,9 +6,12 @@ | |||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <utility> | 7 | #include <utility> |
| 8 | 8 | ||
| 9 | #include <QAbstractButton> | ||
| 9 | #include <QCheckBox> | 10 | #include <QCheckBox> |
| 11 | #include <QDialogButtonBox> | ||
| 10 | #include <QHeaderView> | 12 | #include <QHeaderView> |
| 11 | #include <QMenu> | 13 | #include <QMenu> |
| 14 | #include <QPushButton> | ||
| 12 | #include <QStandardItemModel> | 15 | #include <QStandardItemModel> |
| 13 | #include <QString> | 16 | #include <QString> |
| 14 | #include <QTimer> | 17 | #include <QTimer> |
| @@ -44,6 +47,12 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id) | |||
| 44 | scene = new QGraphicsScene; | 47 | scene = new QGraphicsScene; |
| 45 | ui->icon_view->setScene(scene); | 48 | ui->icon_view->setScene(scene); |
| 46 | 49 | ||
| 50 | if (Core::System::GetInstance().IsPoweredOn()) { | ||
| 51 | QPushButton* apply_button = ui->buttonBox->addButton(QDialogButtonBox::Apply); | ||
| 52 | connect(apply_button, &QAbstractButton::clicked, this, | ||
| 53 | &ConfigurePerGame::HandleApplyButtonClicked); | ||
| 54 | } | ||
| 55 | |||
| 47 | LoadConfiguration(); | 56 | LoadConfiguration(); |
| 48 | } | 57 | } |
| 49 | 58 | ||
| @@ -76,6 +85,11 @@ void ConfigurePerGame::RetranslateUI() { | |||
| 76 | ui->retranslateUi(this); | 85 | ui->retranslateUi(this); |
| 77 | } | 86 | } |
| 78 | 87 | ||
| 88 | void ConfigurePerGame::HandleApplyButtonClicked() { | ||
| 89 | UISettings::values.configuration_applied = true; | ||
| 90 | ApplyConfiguration(); | ||
| 91 | } | ||
| 92 | |||
| 79 | void ConfigurePerGame::LoadFromFile(FileSys::VirtualFile file) { | 93 | void ConfigurePerGame::LoadFromFile(FileSys::VirtualFile file) { |
| 80 | this->file = std::move(file); | 94 | this->file = std::move(file); |
| 81 | LoadConfiguration(); | 95 | LoadConfiguration(); |
diff --git a/src/yuzu/configuration/configure_per_game.h b/src/yuzu/configuration/configure_per_game.h index 5f9a08cef..f6e6ab7c4 100644 --- a/src/yuzu/configuration/configure_per_game.h +++ b/src/yuzu/configuration/configure_per_game.h | |||
| @@ -39,6 +39,8 @@ private: | |||
| 39 | void changeEvent(QEvent* event) override; | 39 | void changeEvent(QEvent* event) override; |
| 40 | void RetranslateUI(); | 40 | void RetranslateUI(); |
| 41 | 41 | ||
| 42 | void HandleApplyButtonClicked(); | ||
| 43 | |||
| 42 | void LoadConfiguration(); | 44 | void LoadConfiguration(); |
| 43 | 45 | ||
| 44 | std::unique_ptr<Ui::ConfigurePerGame> ui; | 46 | std::unique_ptr<Ui::ConfigurePerGame> ui; |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 9275cba53..588db0bb8 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -2578,12 +2578,12 @@ void GMainWindow::OnConfigure() { | |||
| 2578 | &GMainWindow::OnLanguageChanged); | 2578 | &GMainWindow::OnLanguageChanged); |
| 2579 | 2579 | ||
| 2580 | const auto result = configure_dialog.exec(); | 2580 | const auto result = configure_dialog.exec(); |
| 2581 | if (result != QDialog::Accepted) { | 2581 | if (result != QDialog::Accepted && !UISettings::values.configuration_applied) { |
| 2582 | return; | 2582 | return; |
| 2583 | } else if (result == QDialog::Accepted) { | ||
| 2584 | configure_dialog.ApplyConfiguration(); | ||
| 2585 | controller_dialog->refreshConfiguration(); | ||
| 2583 | } | 2586 | } |
| 2584 | |||
| 2585 | configure_dialog.ApplyConfiguration(); | ||
| 2586 | controller_dialog->refreshConfiguration(); | ||
| 2587 | InitializeHotkeys(); | 2587 | InitializeHotkeys(); |
| 2588 | if (UISettings::values.theme != old_theme) { | 2588 | if (UISettings::values.theme != old_theme) { |
| 2589 | UpdateUITheme(); | 2589 | UpdateUITheme(); |
| @@ -2598,6 +2598,8 @@ void GMainWindow::OnConfigure() { | |||
| 2598 | game_list->PopulateAsync(UISettings::values.game_dirs); | 2598 | game_list->PopulateAsync(UISettings::values.game_dirs); |
| 2599 | } | 2599 | } |
| 2600 | 2600 | ||
| 2601 | UISettings::values.configuration_applied = false; | ||
| 2602 | |||
| 2601 | config->Save(); | 2603 | config->Save(); |
| 2602 | 2604 | ||
| 2603 | if ((UISettings::values.hide_mouse || Settings::values.mouse_panning) && emulation_running) { | 2605 | if ((UISettings::values.hide_mouse || Settings::values.mouse_panning) && emulation_running) { |
| @@ -2627,23 +2629,27 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file | |||
| 2627 | ConfigurePerGame dialog(this, title_id); | 2629 | ConfigurePerGame dialog(this, title_id); |
| 2628 | dialog.LoadFromFile(v_file); | 2630 | dialog.LoadFromFile(v_file); |
| 2629 | const auto result = dialog.exec(); | 2631 | const auto result = dialog.exec(); |
| 2630 | if (result == QDialog::Accepted) { | 2632 | |
| 2633 | if (result != QDialog::Accepted && !UISettings::values.configuration_applied) { | ||
| 2634 | Settings::RestoreGlobalState(system.IsPoweredOn()); | ||
| 2635 | return; | ||
| 2636 | } else if (result == QDialog::Accepted) { | ||
| 2631 | dialog.ApplyConfiguration(); | 2637 | dialog.ApplyConfiguration(); |
| 2638 | } | ||
| 2632 | 2639 | ||
| 2633 | const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false); | 2640 | const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false); |
| 2634 | if (reload) { | 2641 | if (reload) { |
| 2635 | game_list->PopulateAsync(UISettings::values.game_dirs); | 2642 | game_list->PopulateAsync(UISettings::values.game_dirs); |
| 2636 | } | 2643 | } |
| 2637 | 2644 | ||
| 2638 | // Do not cause the global config to write local settings into the config file | 2645 | // Do not cause the global config to write local settings into the config file |
| 2639 | const bool is_powered_on = system.IsPoweredOn(); | 2646 | const bool is_powered_on = system.IsPoweredOn(); |
| 2640 | Settings::RestoreGlobalState(is_powered_on); | 2647 | Settings::RestoreGlobalState(is_powered_on); |
| 2641 | 2648 | ||
| 2642 | if (!is_powered_on) { | 2649 | UISettings::values.configuration_applied = false; |
| 2643 | config->Save(); | 2650 | |
| 2644 | } | 2651 | if (!is_powered_on) { |
| 2645 | } else { | 2652 | config->Save(); |
| 2646 | Settings::RestoreGlobalState(system.IsPoweredOn()); | ||
| 2647 | } | 2653 | } |
| 2648 | } | 2654 | } |
| 2649 | 2655 | ||
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 5ba00b8c8..49122ec32 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h | |||
| @@ -95,6 +95,8 @@ struct Values { | |||
| 95 | uint8_t row_2_text_id; | 95 | uint8_t row_2_text_id; |
| 96 | std::atomic_bool is_game_list_reload_pending{false}; | 96 | std::atomic_bool is_game_list_reload_pending{false}; |
| 97 | bool cache_game_list; | 97 | bool cache_game_list; |
| 98 | |||
| 99 | bool configuration_applied; | ||
| 98 | }; | 100 | }; |
| 99 | 101 | ||
| 100 | extern Values values; | 102 | extern Values values; |