mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-01-07 15:48:12 +01:00
Fixed incorrect applications directory path while using Flatpak build
This commit is contained in:
parent
3262515c89
commit
a573f0f036
@ -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 <array>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
@ -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) {
|
||||
|
@ -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 <array>
|
||||
@ -207,6 +210,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
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -1947,8 +1947,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
|
||||
|
@ -1,10 +1,13 @@
|
||||
// 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 <array>
|
||||
#include <cmath>
|
||||
#include <QPainter>
|
||||
#include <QStandardPaths>
|
||||
#include "common/common_paths.h"
|
||||
#include "common/file_util.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/loader/smdh.h"
|
||||
#include "lime_qt/util/util.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
|
||||
}
|
@ -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<u8>& 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();
|
||||
|
Loading…
Reference in New Issue
Block a user