do not show the path if it is not added

This commit is contained in:
connlost 2024-10-10 23:00:17 +08:00
parent 420e4c04ad
commit 70cb429bc2
3 changed files with 7 additions and 3 deletions

View File

@ -325,11 +325,13 @@ void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
main_window_geometry_w = w;
main_window_geometry_h = h;
}
void addGameInstallDir(const std::filesystem::path& dir) {
bool addGameInstallDir(const std::filesystem::path& dir) {
if (std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir) ==
settings_install_dirs.end()) {
settings_install_dirs.push_back(dir);
return true;
}
return false;
}
void removeGameInstallDir(const std::filesystem::path& dir) {
auto iterator = std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir);

View File

@ -85,7 +85,7 @@ bool vkCrashDiagnosticEnabled();
// Gui
void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h);
void addGameInstallDir(const std::filesystem::path& dir);
bool addGameInstallDir(const std::filesystem::path& dir);
void removeGameInstallDir(const std::filesystem::path& dir);
void setAddonInstallDir(const std::filesystem::path& dir);
void setMainWindowTheme(u32 theme);

View File

@ -236,7 +236,9 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
QFileDialog::getExistingDirectory(this, tr("Directory to install games"));
auto file_path = Common::FS::PathFromQString(file_path_string);
if (!file_path.empty()) {
Config::addGameInstallDir(file_path);
if (!Config::addGameInstallDir(file_path)) {
return;
}
QListWidgetItem* item = new QListWidgetItem(file_path_string);
ui->gameFoldersListWidget->addItem(item);
}