Gate use of custom directories behind a variable (#6157)
previous changes had forced every single user to use custom directories for NAND and SDMC. Those paths were saved to the config file and would interact badly with portable builds.
This commit is contained in:
parent
67c4b87184
commit
9626bdf385
8 changed files with 183 additions and 144 deletions
|
@ -203,14 +203,15 @@ void Config::ReadValues() {
|
||||||
Settings::values.use_virtual_sd =
|
Settings::values.use_virtual_sd =
|
||||||
sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
|
sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
|
||||||
|
|
||||||
const std::string default_nand_dir = FileUtil::GetDefaultUserPath(FileUtil::UserPath::NANDDir);
|
Settings::values.use_custom_storage =
|
||||||
FileUtil::UpdateUserPath(
|
sdl2_config->GetBoolean("Data Storage", "use_custom_storage", false);
|
||||||
FileUtil::UserPath::NANDDir,
|
|
||||||
sdl2_config->GetString("Data Storage", "nand_directory", default_nand_dir));
|
if (Settings::values.use_custom_storage) {
|
||||||
const std::string default_sdmc_dir = FileUtil::GetDefaultUserPath(FileUtil::UserPath::SDMCDir);
|
FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir,
|
||||||
FileUtil::UpdateUserPath(
|
sdl2_config->GetString("Data Storage", "nand_directory", ""));
|
||||||
FileUtil::UserPath::SDMCDir,
|
FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir,
|
||||||
sdl2_config->GetString("Data Storage", "sdmc_directory", default_sdmc_dir));
|
sdl2_config->GetString("Data Storage", "sdmc_directory", ""));
|
||||||
|
}
|
||||||
|
|
||||||
// System
|
// System
|
||||||
Settings::values.is_new_3ds = sdl2_config->GetBoolean("System", "is_new_3ds", true);
|
Settings::values.is_new_3ds = sdl2_config->GetBoolean("System", "is_new_3ds", true);
|
||||||
|
|
|
@ -250,6 +250,10 @@ volume =
|
||||||
# 1 (default): Yes, 0: No
|
# 1 (default): Yes, 0: No
|
||||||
use_virtual_sd =
|
use_virtual_sd =
|
||||||
|
|
||||||
|
# Whether to use custom storage locations
|
||||||
|
# 1: Yes, 0 (default): No
|
||||||
|
use_custom_storage =
|
||||||
|
|
||||||
# The path of the virtual SD card directory.
|
# The path of the virtual SD card directory.
|
||||||
# empty (default) will use the user_path
|
# empty (default) will use the user_path
|
||||||
sdmc_directory =
|
sdmc_directory =
|
||||||
|
|
|
@ -304,21 +304,17 @@ void Config::ReadDataStorageValues() {
|
||||||
|
|
||||||
Settings::values.use_virtual_sd = ReadSetting(QStringLiteral("use_virtual_sd"), true).toBool();
|
Settings::values.use_virtual_sd = ReadSetting(QStringLiteral("use_virtual_sd"), true).toBool();
|
||||||
|
|
||||||
|
Settings::values.use_custom_storage =
|
||||||
|
ReadSetting(QStringLiteral("use_custom_storage"), false).toBool();
|
||||||
const std::string nand_dir =
|
const std::string nand_dir =
|
||||||
ReadSetting(
|
ReadSetting(QStringLiteral("nand_directory"), QStringLiteral("")).toString().toStdString();
|
||||||
QStringLiteral("nand_directory"),
|
|
||||||
QString::fromStdString(FileUtil::GetDefaultUserPath(FileUtil::UserPath::NANDDir)))
|
|
||||||
.toString()
|
|
||||||
.toStdString();
|
|
||||||
const std::string sdmc_dir =
|
const std::string sdmc_dir =
|
||||||
ReadSetting(
|
ReadSetting(QStringLiteral("sdmc_directory"), QStringLiteral("")).toString().toStdString();
|
||||||
QStringLiteral("sdmc_directory"),
|
|
||||||
QString::fromStdString(FileUtil::GetDefaultUserPath(FileUtil::UserPath::SDMCDir)))
|
|
||||||
.toString()
|
|
||||||
.toStdString();
|
|
||||||
|
|
||||||
FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir, nand_dir);
|
if (Settings::values.use_custom_storage) {
|
||||||
FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir, sdmc_dir);
|
FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir, nand_dir);
|
||||||
|
FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir, sdmc_dir);
|
||||||
|
}
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
}
|
}
|
||||||
|
@ -869,12 +865,13 @@ void Config::SaveDataStorageValues() {
|
||||||
qt_config->beginGroup(QStringLiteral("Data Storage"));
|
qt_config->beginGroup(QStringLiteral("Data Storage"));
|
||||||
|
|
||||||
WriteSetting(QStringLiteral("use_virtual_sd"), Settings::values.use_virtual_sd, true);
|
WriteSetting(QStringLiteral("use_virtual_sd"), Settings::values.use_virtual_sd, true);
|
||||||
|
WriteSetting(QStringLiteral("use_custom_storage"), Settings::values.use_custom_storage, false);
|
||||||
WriteSetting(QStringLiteral("nand_directory"),
|
WriteSetting(QStringLiteral("nand_directory"),
|
||||||
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)),
|
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)),
|
||||||
QString::fromStdString(FileUtil::GetDefaultUserPath(FileUtil::UserPath::NANDDir)));
|
QStringLiteral(""));
|
||||||
WriteSetting(QStringLiteral("sdmc_directory"),
|
WriteSetting(QStringLiteral("sdmc_directory"),
|
||||||
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)),
|
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)),
|
||||||
QString::fromStdString(FileUtil::GetDefaultUserPath(FileUtil::UserPath::SDMCDir)));
|
QStringLiteral(""));
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,28 +51,42 @@ ConfigureStorage::ConfigureStorage(QWidget* parent)
|
||||||
ApplyConfiguration();
|
ApplyConfiguration();
|
||||||
SetConfiguration();
|
SetConfiguration();
|
||||||
});
|
});
|
||||||
|
connect(ui->toggle_custom_storage, &QCheckBox::clicked, this, [this]() {
|
||||||
|
ApplyConfiguration();
|
||||||
|
SetConfiguration();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigureStorage::~ConfigureStorage() = default;
|
ConfigureStorage::~ConfigureStorage() = default;
|
||||||
|
|
||||||
void ConfigureStorage::SetConfiguration() {
|
void ConfigureStorage::SetConfiguration() {
|
||||||
ui->nand_group->setVisible(Settings::values.use_virtual_sd);
|
ui->nand_group->setVisible(Settings::values.use_custom_storage);
|
||||||
QString nand_path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
|
QString nand_path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
|
||||||
ui->nand_dir_path->setText(nand_path);
|
ui->nand_dir_path->setText(nand_path);
|
||||||
ui->open_nand_dir->setEnabled(!nand_path.isEmpty());
|
ui->open_nand_dir->setEnabled(!nand_path.isEmpty());
|
||||||
|
|
||||||
ui->sdmc_group->setVisible(Settings::values.use_virtual_sd);
|
ui->sdmc_group->setVisible(Settings::values.use_virtual_sd &&
|
||||||
|
Settings::values.use_custom_storage);
|
||||||
QString sdmc_path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir));
|
QString sdmc_path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir));
|
||||||
ui->sdmc_dir_path->setText(sdmc_path);
|
ui->sdmc_dir_path->setText(sdmc_path);
|
||||||
ui->open_sdmc_dir->setEnabled(!sdmc_path.isEmpty());
|
ui->open_sdmc_dir->setEnabled(!sdmc_path.isEmpty());
|
||||||
|
|
||||||
ui->toggle_virtual_sd->setChecked(Settings::values.use_virtual_sd);
|
ui->toggle_virtual_sd->setChecked(Settings::values.use_virtual_sd);
|
||||||
|
ui->toggle_custom_storage->setChecked(Settings::values.use_custom_storage);
|
||||||
|
|
||||||
ui->storage_group->setEnabled(!Core::System::GetInstance().IsPoweredOn());
|
ui->storage_group->setEnabled(!Core::System::GetInstance().IsPoweredOn());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureStorage::ApplyConfiguration() {
|
void ConfigureStorage::ApplyConfiguration() {
|
||||||
Settings::values.use_virtual_sd = ui->toggle_virtual_sd->isChecked();
|
Settings::values.use_virtual_sd = ui->toggle_virtual_sd->isChecked();
|
||||||
|
Settings::values.use_custom_storage = ui->toggle_custom_storage->isChecked();
|
||||||
|
|
||||||
|
if (!Settings::values.use_custom_storage) {
|
||||||
|
FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir,
|
||||||
|
GetDefaultUserPath(FileUtil::UserPath::NANDDir));
|
||||||
|
FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir,
|
||||||
|
GetDefaultUserPath(FileUtil::UserPath::SDMCDir));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureStorage::RetranslateUI() {
|
void ConfigureStorage::RetranslateUI() {
|
||||||
|
|
|
@ -34,131 +34,147 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="nand_group">
|
<widget class="QGroupBox" name="custom_storage_group">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string/>
|
<string>Custom Storage</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<widget class="QCheckBox" name="toggle_custom_storage">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QLabel" name="label">
|
<string>Use Custom Storage</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>NAND Directory</string>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="nand_dir_path">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="open_nand_dir">
|
|
||||||
<property name="text">
|
|
||||||
<string>Open</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<widget class="QGroupBox" name="nand_group">
|
||||||
<item>
|
<property name="title">
|
||||||
<widget class="QLabel" name="label_4">
|
<string/>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>NOTE: This does not move the contents of the previous directory to the new one.</string>
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
</property>
|
<item>
|
||||||
</widget>
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
</item>
|
<item>
|
||||||
<item>
|
<widget class="QLabel" name="label">
|
||||||
<spacer name="horizontalSpacer_3">
|
<property name="text">
|
||||||
<property name="orientation">
|
<string>NAND Directory</string>
|
||||||
<enum>Qt::Horizontal</enum>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<property name="sizeHint" stdset="0">
|
</item>
|
||||||
<size>
|
<item>
|
||||||
<width>40</width>
|
<widget class="QLineEdit" name="nand_dir_path">
|
||||||
<height>20</height>
|
<property name="enabled">
|
||||||
</size>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="change_nand_dir">
|
<widget class="QPushButton" name="open_nand_dir">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Change</string>
|
<string>Open</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
<item>
|
||||||
</widget>
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
</item>
|
<item>
|
||||||
<item>
|
<widget class="QLabel" name="label_4">
|
||||||
<widget class="QGroupBox" name="sdmc_group">
|
<property name="text">
|
||||||
<property name="title">
|
<string>NOTE: This does not move the contents of the previous directory to the new one.</string>
|
||||||
<string/>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<spacer name="horizontalSpacer_3">
|
||||||
<item>
|
<property name="orientation">
|
||||||
<widget class="QLabel" name="label_2">
|
<enum>Qt::Horizontal</enum>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>SDMC Directory</string>
|
<property name="sizeHint" stdset="0">
|
||||||
</property>
|
<size>
|
||||||
</widget>
|
<width>40</width>
|
||||||
</item>
|
<height>20</height>
|
||||||
<item>
|
</size>
|
||||||
<widget class="QLineEdit" name="sdmc_dir_path">
|
</property>
|
||||||
<property name="enabled">
|
</spacer>
|
||||||
<bool>false</bool>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
</widget>
|
<widget class="QPushButton" name="change_nand_dir">
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string>Change</string>
|
||||||
<widget class="QPushButton" name="open_sdmc_dir">
|
</property>
|
||||||
<property name="text">
|
</widget>
|
||||||
<string>Open</string>
|
</item>
|
||||||
</property>
|
</layout>
|
||||||
</widget>
|
</item>
|
||||||
</item>
|
</layout>
|
||||||
</layout>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<widget class="QGroupBox" name="sdmc_group">
|
||||||
<item>
|
<property name="title">
|
||||||
<widget class="QLabel" name="label_3">
|
<string/>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>NOTE: This does not move the contents of the previous directory to the new one.</string>
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
</property>
|
<item>
|
||||||
</widget>
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
</item>
|
<item>
|
||||||
<item>
|
<widget class="QLabel" name="label_2">
|
||||||
<spacer name="horizontalSpacer_4">
|
<property name="text">
|
||||||
<property name="orientation">
|
<string>SDMC Directory</string>
|
||||||
<enum>Qt::Horizontal</enum>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<property name="sizeHint" stdset="0">
|
</item>
|
||||||
<size>
|
<item>
|
||||||
<width>40</width>
|
<widget class="QLineEdit" name="sdmc_dir_path">
|
||||||
<height>20</height>
|
<property name="enabled">
|
||||||
</size>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="change_sdmc_dir">
|
<widget class="QPushButton" name="open_sdmc_dir">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Change</string>
|
<string>Open</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>NOTE: This does not move the contents of the previous directory to the new one.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="change_sdmc_dir">
|
||||||
|
<property name="text">
|
||||||
|
<string>Change</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -774,6 +774,9 @@ const std::string& GetDefaultUserPath(UserPath path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const void UpdateUserPath(UserPath path, const std::string& filename) {
|
const void UpdateUserPath(UserPath path, const std::string& filename) {
|
||||||
|
if (filename.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!FileUtil::IsDirectory(filename)) {
|
if (!FileUtil::IsDirectory(filename)) {
|
||||||
LOG_ERROR(Common_Filesystem, "Path is not a directory. UserPath: {} filename: {}", path,
|
LOG_ERROR(Common_Filesystem, "Path is not a directory. UserPath: {} filename: {}", path,
|
||||||
filename);
|
filename);
|
||||||
|
|
|
@ -120,8 +120,11 @@ void LogSettings() {
|
||||||
log_setting("Camera_OuterLeftConfig", values.camera_config[OuterLeftCamera]);
|
log_setting("Camera_OuterLeftConfig", values.camera_config[OuterLeftCamera]);
|
||||||
log_setting("Camera_OuterLeftFlip", values.camera_flip[OuterLeftCamera]);
|
log_setting("Camera_OuterLeftFlip", values.camera_flip[OuterLeftCamera]);
|
||||||
log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd);
|
log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd);
|
||||||
log_setting("DataStorage_SdmcDir", FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir));
|
log_setting("DataStorage_UseCustomStorage", values.use_custom_storage);
|
||||||
log_setting("DataStorage_NandDir", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
|
if (values.use_custom_storage) {
|
||||||
|
log_setting("DataStorage_SdmcDir", FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir));
|
||||||
|
log_setting("DataStorage_NandDir", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir));
|
||||||
|
}
|
||||||
log_setting("System_IsNew3ds", values.is_new_3ds);
|
log_setting("System_IsNew3ds", values.is_new_3ds);
|
||||||
log_setting("System_RegionValue", values.region_value);
|
log_setting("System_RegionValue", values.region_value);
|
||||||
log_setting("Debugging_UseGdbstub", values.use_gdbstub);
|
log_setting("Debugging_UseGdbstub", values.use_gdbstub);
|
||||||
|
|
|
@ -155,6 +155,7 @@ struct Values {
|
||||||
|
|
||||||
// Data Storage
|
// Data Storage
|
||||||
bool use_virtual_sd;
|
bool use_virtual_sd;
|
||||||
|
bool use_custom_storage;
|
||||||
|
|
||||||
// System
|
// System
|
||||||
int region_value;
|
int region_value;
|
||||||
|
|
Loading…
Reference in a new issue