Per-Game Settings: options to reset game settings (#6219)

This commit is contained in:
Vitor K 2022-12-17 12:04:31 -03:00 committed by GitHub
parent cb82ffbe20
commit 812c4fa059
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 1 deletions

View file

@ -141,10 +141,12 @@ void ConfigureGeneral::ResetDefaults() {
tr("Are you sure you want to <b>reset your settings</b> and close Citra?"), tr("Are you sure you want to <b>reset your settings</b> and close Citra?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No); QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (answer == QMessageBox::No) if (answer == QMessageBox::No) {
return; return;
}
FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "qt-config.ini"); FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "qt-config.ini");
FileUtil::DeleteDirRecursively(FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "custom");
std::exit(0); std::exit(0);
} }

View file

@ -3,6 +3,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <QMessageBox>
#include <QPushButton> #include <QPushButton>
#include <QString> #include <QString>
#include <fmt/format.h> #include <fmt/format.h>
@ -13,6 +14,7 @@
#include "citra_qt/configuration/configure_per_game.h" #include "citra_qt/configuration/configure_per_game.h"
#include "citra_qt/configuration/configure_system.h" #include "citra_qt/configuration/configure_system.h"
#include "citra_qt/util/util.h" #include "citra_qt/util/util.h"
#include "common/file_util.h"
#include "core/core.h" #include "core/core.h"
#include "core/loader/loader.h" #include "core/loader/loader.h"
#include "core/loader/smdh.h" #include "core/loader/smdh.h"
@ -51,11 +53,30 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const QString
&ConfigurePerGame::HandleApplyButtonClicked); &ConfigurePerGame::HandleApplyButtonClicked);
} }
connect(ui->button_reset_per_game, &QPushButton::clicked, this,
&ConfigurePerGame::ResetDefaults);
LoadConfiguration(); LoadConfiguration();
} }
ConfigurePerGame::~ConfigurePerGame() = default; ConfigurePerGame::~ConfigurePerGame() = default;
void ConfigurePerGame::ResetDefaults() {
const auto config_file_name = title_id == 0 ? filename : fmt::format("{:016X}", title_id);
QMessageBox::StandardButton answer = QMessageBox::question(
this, tr("Citra"), tr("Are you sure you want to <b>reset your settings for this game</b>?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (answer == QMessageBox::No) {
return;
}
FileUtil::Delete(fmt::format("{}/custom/{}.ini",
FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir),
config_file_name));
close();
}
void ConfigurePerGame::ApplyConfiguration() { void ConfigurePerGame::ApplyConfiguration() {
general_tab->ApplyConfiguration(); general_tab->ApplyConfiguration();
system_tab->ApplyConfiguration(); system_tab->ApplyConfiguration();

View file

@ -43,6 +43,9 @@ public:
/// Save all button configurations to settings file /// Save all button configurations to settings file
void ApplyConfiguration(); void ApplyConfiguration();
/// Reset the settings for this game
void ResetDefaults();
private: private:
void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
void RetranslateUI(); void RetranslateUI();

View file

@ -177,6 +177,13 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QPushButton" name="button_reset_per_game">
<property name="text">
<string>Reset Game Settings</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>