mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
Fixed mistakenly overwriting the last opened config with the default one if the GUI is opened multiple times in a session
This commit is contained in:
parent
45cc82e925
commit
564a945d22
@ -20,6 +20,8 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
QString previous_game = "default";
|
||||||
|
|
||||||
EditorDialog::EditorDialog(QWidget* parent) : QDialog(parent) {
|
EditorDialog::EditorDialog(QWidget* parent) : QDialog(parent) {
|
||||||
|
|
||||||
setWindowTitle("Edit Config File");
|
setWindowTitle("Edit Config File");
|
||||||
@ -76,7 +78,6 @@ EditorDialog::EditorDialog(QWidget* parent) : QDialog(parent) {
|
|||||||
|
|
||||||
void EditorDialog::loadFile(QString game) {
|
void EditorDialog::loadFile(QString game) {
|
||||||
|
|
||||||
// to make sure the files and the directory do exist
|
|
||||||
const auto config_file = Config::GetFoolproofKbmConfigFile(game.toStdString());
|
const auto config_file = Config::GetFoolproofKbmConfigFile(game.toStdString());
|
||||||
QFile file(config_file);
|
QFile file(config_file);
|
||||||
|
|
||||||
@ -92,7 +93,6 @@ void EditorDialog::loadFile(QString game) {
|
|||||||
|
|
||||||
void EditorDialog::saveFile(QString game) {
|
void EditorDialog::saveFile(QString game) {
|
||||||
|
|
||||||
// to make sure the files and the directory do exist
|
|
||||||
const auto config_file = Config::GetFoolproofKbmConfigFile(game.toStdString());
|
const auto config_file = Config::GetFoolproofKbmConfigFile(game.toStdString());
|
||||||
QFile file(config_file);
|
QFile file(config_file);
|
||||||
|
|
||||||
@ -166,6 +166,7 @@ bool EditorDialog::hasUnsavedChanges() {
|
|||||||
return editor->toPlainText() != originalConfig;
|
return editor->toPlainText() != originalConfig;
|
||||||
}
|
}
|
||||||
void EditorDialog::loadInstalledGames() {
|
void EditorDialog::loadInstalledGames() {
|
||||||
|
previous_game = "default";
|
||||||
QStringList filePaths;
|
QStringList filePaths;
|
||||||
for (const auto& installLoc : Config::getGameInstallDirs()) {
|
for (const auto& installLoc : Config::getGameInstallDirs()) {
|
||||||
QString installDir;
|
QString installDir;
|
||||||
@ -179,9 +180,8 @@ void EditorDialog::loadInstalledGames() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QString previousGame = "default";
|
|
||||||
void EditorDialog::onGameSelectionChanged(const QString& game) {
|
void EditorDialog::onGameSelectionChanged(const QString& game) {
|
||||||
saveFile(previousGame);
|
saveFile(previous_game);
|
||||||
loadFile(gameComboBox->currentText()); // Reload file based on the selected game
|
loadFile(gameComboBox->currentText()); // Reload file based on the selected game
|
||||||
previousGame = gameComboBox->currentText();
|
previous_game = gameComboBox->currentText();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user