mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
Merge pull request #6346 from lat9nq/apply-config-pgc
yuzu qt: Add an Apply button to configuration dialogs
This commit is contained in:
commit
9110cfdefb
6 changed files with 59 additions and 20 deletions
|
@ -2,8 +2,11 @@
|
|||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHash>
|
||||
#include <QListWidgetItem>
|
||||
#include <QPushButton>
|
||||
#include <QSignalBlocker>
|
||||
#include "common/settings.h"
|
||||
#include "core/core.h"
|
||||
|
@ -31,6 +34,12 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry,
|
|||
connect(ui->selectorList, &QListWidget::itemSelectionChanged, this,
|
||||
&ConfigureDialog::UpdateVisibleTabs);
|
||||
|
||||
if (Core::System::GetInstance().IsPoweredOn()) {
|
||||
QPushButton* apply_button = ui->buttonBox->addButton(QDialogButtonBox::Apply);
|
||||
connect(apply_button, &QAbstractButton::clicked, this,
|
||||
&ConfigureDialog::HandleApplyButtonClicked);
|
||||
}
|
||||
|
||||
adjustSize();
|
||||
ui->selectorList->setCurrentRow(0);
|
||||
}
|
||||
|
@ -80,6 +89,11 @@ void ConfigureDialog::RetranslateUI() {
|
|||
ui->tabWidget->setCurrentIndex(old_index);
|
||||
}
|
||||
|
||||
void ConfigureDialog::HandleApplyButtonClicked() {
|
||||
UISettings::values.configuration_applied = true;
|
||||
ApplyConfiguration();
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(QList<QWidget*>);
|
||||
|
||||
void ConfigureDialog::PopulateSelectionList() {
|
||||
|
|
|
@ -35,9 +35,10 @@ signals:
|
|||
|
||||
private:
|
||||
void changeEvent(QEvent* event) override;
|
||||
|
||||
void RetranslateUI();
|
||||
|
||||
void HandleApplyButtonClicked();
|
||||
|
||||
void SetConfiguration();
|
||||
void UpdateVisibleTabs();
|
||||
void PopulateSelectionList();
|
||||
|
|
|
@ -6,9 +6,12 @@
|
|||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QCheckBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
#include <QPushButton>
|
||||
#include <QStandardItemModel>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
|
@ -42,6 +45,12 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id)
|
|||
scene = new QGraphicsScene;
|
||||
ui->icon_view->setScene(scene);
|
||||
|
||||
if (Core::System::GetInstance().IsPoweredOn()) {
|
||||
QPushButton* apply_button = ui->buttonBox->addButton(QDialogButtonBox::Apply);
|
||||
connect(apply_button, &QAbstractButton::clicked, this,
|
||||
&ConfigurePerGame::HandleApplyButtonClicked);
|
||||
}
|
||||
|
||||
LoadConfiguration();
|
||||
}
|
||||
|
||||
|
@ -74,6 +83,11 @@ void ConfigurePerGame::RetranslateUI() {
|
|||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
void ConfigurePerGame::HandleApplyButtonClicked() {
|
||||
UISettings::values.configuration_applied = true;
|
||||
ApplyConfiguration();
|
||||
}
|
||||
|
||||
void ConfigurePerGame::LoadFromFile(FileSys::VirtualFile file) {
|
||||
this->file = std::move(file);
|
||||
LoadConfiguration();
|
||||
|
|
|
@ -39,6 +39,8 @@ private:
|
|||
void changeEvent(QEvent* event) override;
|
||||
void RetranslateUI();
|
||||
|
||||
void HandleApplyButtonClicked();
|
||||
|
||||
void LoadConfiguration();
|
||||
|
||||
std::unique_ptr<Ui::ConfigurePerGame> ui;
|
||||
|
|
|
@ -2587,12 +2587,12 @@ void GMainWindow::OnConfigure() {
|
|||
&GMainWindow::OnLanguageChanged);
|
||||
|
||||
const auto result = configure_dialog.exec();
|
||||
if (result != QDialog::Accepted) {
|
||||
if (result != QDialog::Accepted && !UISettings::values.configuration_applied) {
|
||||
return;
|
||||
} else if (result == QDialog::Accepted) {
|
||||
configure_dialog.ApplyConfiguration();
|
||||
controller_dialog->refreshConfiguration();
|
||||
}
|
||||
|
||||
configure_dialog.ApplyConfiguration();
|
||||
controller_dialog->refreshConfiguration();
|
||||
InitializeHotkeys();
|
||||
if (UISettings::values.theme != old_theme) {
|
||||
UpdateUITheme();
|
||||
|
@ -2607,6 +2607,8 @@ void GMainWindow::OnConfigure() {
|
|||
game_list->PopulateAsync(UISettings::values.game_dirs);
|
||||
}
|
||||
|
||||
UISettings::values.configuration_applied = false;
|
||||
|
||||
config->Save();
|
||||
|
||||
if ((UISettings::values.hide_mouse || Settings::values.mouse_panning) && emulation_running) {
|
||||
|
@ -2636,23 +2638,27 @@ void GMainWindow::OpenPerGameConfiguration(u64 title_id, const std::string& file
|
|||
ConfigurePerGame dialog(this, title_id);
|
||||
dialog.LoadFromFile(v_file);
|
||||
const auto result = dialog.exec();
|
||||
if (result == QDialog::Accepted) {
|
||||
dialog.ApplyConfiguration();
|
||||
|
||||
const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false);
|
||||
if (reload) {
|
||||
game_list->PopulateAsync(UISettings::values.game_dirs);
|
||||
}
|
||||
|
||||
// Do not cause the global config to write local settings into the config file
|
||||
const bool is_powered_on = system.IsPoweredOn();
|
||||
Settings::RestoreGlobalState(is_powered_on);
|
||||
|
||||
if (!is_powered_on) {
|
||||
config->Save();
|
||||
}
|
||||
} else {
|
||||
if (result != QDialog::Accepted && !UISettings::values.configuration_applied) {
|
||||
Settings::RestoreGlobalState(system.IsPoweredOn());
|
||||
return;
|
||||
} else if (result == QDialog::Accepted) {
|
||||
dialog.ApplyConfiguration();
|
||||
}
|
||||
|
||||
const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false);
|
||||
if (reload) {
|
||||
game_list->PopulateAsync(UISettings::values.game_dirs);
|
||||
}
|
||||
|
||||
// Do not cause the global config to write local settings into the config file
|
||||
const bool is_powered_on = system.IsPoweredOn();
|
||||
Settings::RestoreGlobalState(is_powered_on);
|
||||
|
||||
UISettings::values.configuration_applied = false;
|
||||
|
||||
if (!is_powered_on) {
|
||||
config->Save();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,8 @@ struct Values {
|
|||
uint8_t row_2_text_id;
|
||||
std::atomic_bool is_game_list_reload_pending{false};
|
||||
bool cache_game_list;
|
||||
|
||||
bool configuration_applied;
|
||||
};
|
||||
|
||||
extern Values values;
|
||||
|
|
Loading…
Reference in a new issue