Update main.cpp

This code will attempt to use QStandardPaths to find the applications directory. If that fails, it will resort to using the ~/.local/share/applications directory, which is a common location for application shortcuts in Linux.
This commit is contained in:
DanielSvoboda 2023-10-12 01:56:10 -03:00 committed by GitHub
parent 32da76d4f2
commit 863dfa81e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2882,7 +2882,14 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga
case GameListShortcutTarget::Applications: {
const QString applications_path =
QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation);
target_directory = applications_path.toUtf8().toStdString();
if (applications_path.isEmpty()) {
const char* home = std::getenv("HOME");
if (home != nullptr) {
target_directory = std::filesystem::path(home) / ".local/share/applications";
}
} else {
target_directory = applications_path.toUtf8().toStdString();
}
break;
}
default: