diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index 54c643d41..9c79baeda 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -1,4 +1,4 @@ -// Copyright Citra Emulator Project / Lime3DS Emulator Project +// Copyright 2014 Citra Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index ad4162384..cdd4040e8 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -1882,8 +1882,7 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga shortcut_path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).toStdString(); } else if (target == GameListShortcutTarget::Applications) { - shortcut_path = - QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation).toStdString(); + shortcut_path = GetApplicationsDirectory(); } // Icon path and title diff --git a/src/citra_qt/util/util.cpp b/src/citra_qt/util/util.cpp index 280ea0929..413e94abc 100644 --- a/src/citra_qt/util/util.cpp +++ b/src/citra_qt/util/util.cpp @@ -1,11 +1,14 @@ -// Copyright 2015 Citra Emulator Project +// Copyright Citra Emulator Project / Lime3DS Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. #include #include #include +#include #include "citra_qt/util/util.h" +#include "common/common_paths.h" +#include "common/file_util.h" #include "common/logging/log.h" #include "core/loader/smdh.h" @@ -160,3 +163,15 @@ bool SaveIconToFile(const std::filesystem::path& icon_path, const QImage& image) return false; #endif } + +const std::string GetApplicationsDirectory() { +// This alternate method is required for Flatpak compatibility as +// QStandardPaths::ApplicationsLocation returns a path inside the Flatpak data directory instead of +// $HOME/.local/share +#if defined(__linux__) || defined(__FreeBSD__) + return FileUtil::GetHomeDirectory() + DIR_SEP + ".local" + DIR_SEP + "share" + DIR_SEP + + "applications"; +#else + return QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation).toStdString(); +#endif +} \ No newline at end of file diff --git a/src/citra_qt/util/util.h b/src/citra_qt/util/util.h index 67bd51a90..428d69ffd 100644 --- a/src/citra_qt/util/util.h +++ b/src/citra_qt/util/util.h @@ -1,4 +1,4 @@ -// Copyright 2015 Citra Emulator Project +// Copyright Citra Emulator Project / Lime3DS Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -36,3 +36,8 @@ QPixmap GetQPixmapFromSMDH(const std::vector& smdh_data); * @return bool If the operation succeeded */ [[nodiscard]] bool SaveIconToFile(const std::filesystem::path& icon_path, const QImage& image); + +/** + * @return The user’s applications directory + */ +[[nodiscard]] const std::string GetApplicationsDirectory(); diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 88fb2e324..e1f3f9809 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -1,7 +1,10 @@ -// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project +// Copyright Citra Emulator Project / Lime3DS Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +// Copyright Dolphin Emulator Project +// Licensed under GPLv2 or any later version + #include #include #include @@ -707,8 +710,8 @@ std::string AppDataRoamingDirectory() { /** * @return The user’s home directory on POSIX systems */ -static const std::string& GetHomeDirectory() { - static std::string home_path; +const std::string GetHomeDirectory() { + std::string home_path; if (home_path.empty()) { const char* envvar = getenv("HOME"); if (envvar) { diff --git a/src/common/file_util.h b/src/common/file_util.h index fdacd7a42..4c168b0df 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -1,7 +1,10 @@ -// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project +// Copyright Citra Emulator Project / Lime3DS Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +// Copyright Dolphin Emulator Project +// Licensed under GPLv2 or any later version + #pragma once #include @@ -204,6 +207,7 @@ void UpdateUserPath(UserPath path, const std::string& filename); [[nodiscard]] const std::string& GetExeDirectory(); [[nodiscard]] std::string AppDataRoamingDirectory(); #else +[[nodiscard]] const std::string GetHomeDirectory(); [[nodiscard]] const std::string GetUserDirectory(const std::string& envvar); #endif