Added ability to change save data path (#2199)

* added ability to change save data path

* get default save data path from fs

* add copyright

* formatting
This commit is contained in:
f3d209 2025-01-22 10:10:35 +00:00 committed by GitHub
parent 78ae9613c5
commit adbff4056f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 132 additions and 53 deletions

View file

@ -202,6 +202,21 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
delete selected_item;
}
});
connect(ui->browseButton, &QPushButton::clicked, this, [this]() {
const auto save_data_path = Config::GetSaveDataPath();
QString initial_path;
Common::FS::PathToQString(initial_path, save_data_path);
QString save_data_path_string =
QFileDialog::getExistingDirectory(this, tr("Directory to save data"), initial_path);
auto file_path = Common::FS::PathFromQString(save_data_path_string);
if (!file_path.empty()) {
Config::setSaveDataPath(file_path);
ui->currentSaveDataPath->setText(save_data_path_string);
}
});
}
// DEBUG TAB
@ -256,6 +271,10 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
ui->addFolderButton->installEventFilter(this);
ui->removeFolderButton->installEventFilter(this);
ui->saveDataGroupBox->installEventFilter(this);
ui->currentSaveDataPath->installEventFilter(this);
ui->browseButton->installEventFilter(this);
// Debug
ui->debugDump->installEventFilter(this);
ui->vkValidationCheckBox->installEventFilter(this);
@ -286,6 +305,11 @@ void SettingsDialog::LoadValuesFromConfig() {
const QVector<int> languageIndexes = {21, 23, 14, 6, 18, 1, 12, 22, 2, 4, 25, 24, 29, 5, 0, 9,
15, 16, 17, 7, 26, 8, 11, 20, 3, 13, 27, 10, 19, 30, 28};
const auto save_data_path = Config::GetSaveDataPath();
QString save_data_path_string;
Common::FS::PathToQString(save_data_path_string, save_data_path);
ui->currentSaveDataPath->setText(save_data_path_string);
ui->consoleLanguageComboBox->setCurrentIndex(
std::distance(languageIndexes.begin(),
std::find(languageIndexes.begin(), languageIndexes.end(),
@ -497,6 +521,13 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) {
text = tr("removeFolderButton");
}
// Save Data
if (elementName == "saveDataGroupBox" || elementName == "currentSaveDataPath") {
text = tr("saveDataBox");
} else if (elementName == "browseButton") {
text = tr("browseButton");
}
// Debug
if (elementName == "debugDump") {
text = tr("debugDump");
@ -603,4 +634,4 @@ void SettingsDialog::ResetInstallFolders() {
}
Config::setGameInstallDirs(settings_install_dirs_config);
}
}
}

View file

@ -53,7 +53,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QScrollArea" name="generalTab">
<property name="widgetResizable">
@ -67,8 +67,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>946</width>
<height>611</height>
<width>771</width>
<height>606</height>
</rect>
</property>
<layout class="QVBoxLayout" name="generalTabVLayout" stretch="0">
@ -644,8 +644,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>946</width>
<height>605</height>
<width>455</width>
<height>252</height>
</rect>
</property>
<layout class="QVBoxLayout" name="inputTabVLayout" stretch="0,0">
@ -928,8 +928,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>946</width>
<height>605</height>
<width>579</width>
<height>194</height>
</rect>
</property>
<layout class="QVBoxLayout" name="graphicsTabVLayout" stretch="0,0">
@ -1178,51 +1178,76 @@
<string>Paths</string>
</attribute>
<widget class="QWidget" name="pathsTabContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>946</width>
<height>605</height>
</rect>
</property>
<layout class="QVBoxLayout" name="pathsTabLayout" stretch="0">
<layout class="QVBoxLayout" name="pathsTabLayout">
<item>
<layout class="QHBoxLayout" name="pathsTabVLayout">
<item>
<widget class="QGroupBox" name="gameFoldersGroupBox">
<property name="title">
<string>Game Folders</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="gameFoldersGroupBox">
<property name="title">
<string>Game Folders</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="addFolderButton">
<property name="text">
<string>Add...</string>
</property>
<property name="text">
<string>Add...</string>
</property>
</widget>
</item>
<item>
</item>
<item>
<widget class="QPushButton" name="removeFolderButton">
<property name="text">
<string>Remove</string>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="gameFoldersListWidget"/>
</item>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="gameFoldersListWidget"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="saveDataGroupBox">
<property name="title">
<string>Save Data Path</string>
</property>
<layout class="QVBoxLayout" name="saveDataLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="currentSaveDataPath">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="browseButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
@ -1239,8 +1264,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>946</width>
<height>586</height>
<width>510</width>
<height>269</height>
</rect>
</property>
<layout class="QVBoxLayout" name="debugTabVLayout" stretch="0,1">

View file

@ -912,6 +912,14 @@
<source>rdocCheckBox</source>
<translation>Enable RenderDoc Debugging:\nIf enabled, the emulator will provide compatibility with Renderdoc to allow capture and analysis of the currently rendered frame.</translation>
</message>
<message>
<source>saveDataBox</source>
<translation>Save Data Path:\nThe folder where game save data will be saved.</translation>
</message>
<message>
<source>browseButton</source>
<translation>Browse:\nBrowse for a folder to set as the save data path.</translation>
</message>
</context>
<context>
<name>CheatsPatches</name>