mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-26 19:44:16 +01:00
Fixed shortcuts generated via Flatpak not working
This commit is contained in:
parent
2cd1ea1277
commit
3262515c89
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2014 Citra Emulator Project
|
// Copyright Citra Emulator Project / Lime3DS Emulator Project
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
@ -1764,9 +1764,9 @@ void GMainWindow::OnGameListRemovePlayTimeData(u64 program_id) {
|
|||||||
bool GMainWindow::CreateShortcutLink(const std::filesystem::path& shortcut_path,
|
bool GMainWindow::CreateShortcutLink(const std::filesystem::path& shortcut_path,
|
||||||
const std::string& comment,
|
const std::string& comment,
|
||||||
const std::filesystem::path& icon_path,
|
const std::filesystem::path& icon_path,
|
||||||
const std::filesystem::path& command,
|
const std::string& command, const std::string& arguments,
|
||||||
const std::string& arguments, const std::string& categories,
|
const std::string& categories, const std::string& keywords,
|
||||||
const std::string& keywords, const std::string& name) try {
|
const std::string& name, const bool& skip_tryexec) try {
|
||||||
#if defined(__linux__) || defined(__FreeBSD__) // Linux and FreeBSD
|
#if defined(__linux__) || defined(__FreeBSD__) // Linux and FreeBSD
|
||||||
std::filesystem::path shortcut_path_full = shortcut_path / (name + ".desktop");
|
std::filesystem::path shortcut_path_full = shortcut_path / (name + ".desktop");
|
||||||
std::ofstream shortcut_stream(shortcut_path_full, std::ios::binary | std::ios::trunc);
|
std::ofstream shortcut_stream(shortcut_path_full, std::ios::binary | std::ios::trunc);
|
||||||
@ -1785,8 +1785,10 @@ bool GMainWindow::CreateShortcutLink(const std::filesystem::path& shortcut_path,
|
|||||||
if (std::filesystem::is_regular_file(icon_path)) {
|
if (std::filesystem::is_regular_file(icon_path)) {
|
||||||
fmt::print(shortcut_stream, "Icon={}\n", icon_path.string());
|
fmt::print(shortcut_stream, "Icon={}\n", icon_path.string());
|
||||||
}
|
}
|
||||||
fmt::print(shortcut_stream, "TryExec={}\n", command.string());
|
if (!skip_tryexec) {
|
||||||
fmt::print(shortcut_stream, "Exec={} {}\n", command.string(), arguments);
|
fmt::print(shortcut_stream, "TryExec={}\n", command);
|
||||||
|
}
|
||||||
|
fmt::print(shortcut_stream, "Exec={} {}\n", command, arguments);
|
||||||
if (!categories.empty()) {
|
if (!categories.empty()) {
|
||||||
fmt::print(shortcut_stream, "Categories={}\n", categories);
|
fmt::print(shortcut_stream, "Categories={}\n", categories);
|
||||||
}
|
}
|
||||||
@ -1923,12 +1925,20 @@ bool GMainWindow::MakeShortcutIcoPath(const u64 program_id, const std::string_vi
|
|||||||
|
|
||||||
void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& game_path,
|
void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& game_path,
|
||||||
GameListShortcutTarget target) {
|
GameListShortcutTarget target) {
|
||||||
// Get path to Lime3DS executable
|
std::string lime_command{};
|
||||||
const QStringList args = QApplication::arguments();
|
bool skip_tryexec = false;
|
||||||
std::filesystem::path lime_command = args[0].toStdString();
|
const char* env_flatpak_id = getenv("FLATPAK_ID");
|
||||||
// If relative path, make it an absolute path
|
if (env_flatpak_id) {
|
||||||
if (lime_command.c_str()[0] == '.') {
|
lime_command = fmt::format("flatpak run {}", env_flatpak_id);
|
||||||
lime_command = FileUtil::GetCurrentDir().value_or("") + DIR_SEP + lime_command.string();
|
skip_tryexec = true;
|
||||||
|
} else {
|
||||||
|
// Get path to Lime3DS executable
|
||||||
|
const QStringList args = QApplication::arguments();
|
||||||
|
lime_command = args[0].toStdString();
|
||||||
|
// If relative path, make it an absolute path
|
||||||
|
if (lime_command.c_str()[0] == '.') {
|
||||||
|
lime_command = FileUtil::GetCurrentDir().value_or("") + DIR_SEP + lime_command;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shortcut path
|
// Shortcut path
|
||||||
@ -1984,8 +1994,7 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga
|
|||||||
// Warn once if we are making a shortcut to a volatile AppImage
|
// Warn once if we are making a shortcut to a volatile AppImage
|
||||||
const std::string appimage_ending =
|
const std::string appimage_ending =
|
||||||
std::string(Common::g_scm_rev).substr(0, 9).append(".AppImage");
|
std::string(Common::g_scm_rev).substr(0, 9).append(".AppImage");
|
||||||
if (lime_command.string().ends_with(appimage_ending) &&
|
if (lime_command.ends_with(appimage_ending) && !UISettings::values.shortcut_already_warned) {
|
||||||
!UISettings::values.shortcut_already_warned) {
|
|
||||||
if (CreateShortcutMessagesGUI(this, CREATE_SHORTCUT_MSGBOX_APPIMAGE_VOLATILE_WARNING,
|
if (CreateShortcutMessagesGUI(this, CREATE_SHORTCUT_MSGBOX_APPIMAGE_VOLATILE_WARNING,
|
||||||
qt_game_title)) {
|
qt_game_title)) {
|
||||||
return;
|
return;
|
||||||
@ -2003,7 +2012,7 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga
|
|||||||
const std::string keywords = "3ds;Nintendo;";
|
const std::string keywords = "3ds;Nintendo;";
|
||||||
|
|
||||||
if (CreateShortcutLink(shortcut_path, comment, out_icon_path, lime_command, arguments,
|
if (CreateShortcutLink(shortcut_path, comment, out_icon_path, lime_command, arguments,
|
||||||
categories, keywords, game_title)) {
|
categories, keywords, game_title, skip_tryexec)) {
|
||||||
CreateShortcutMessagesGUI(this, CREATE_SHORTCUT_MSGBOX_SUCCESS, qt_game_title);
|
CreateShortcutMessagesGUI(this, CREATE_SHORTCUT_MSGBOX_SUCCESS, qt_game_title);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -217,10 +217,10 @@ private:
|
|||||||
bool MakeShortcutIcoPath(const u64 program_id, const std::string_view game_file_name,
|
bool MakeShortcutIcoPath(const u64 program_id, const std::string_view game_file_name,
|
||||||
std::filesystem::path& out_icon_path);
|
std::filesystem::path& out_icon_path);
|
||||||
bool CreateShortcutLink(const std::filesystem::path& shortcut_path, const std::string& comment,
|
bool CreateShortcutLink(const std::filesystem::path& shortcut_path, const std::string& comment,
|
||||||
const std::filesystem::path& icon_path,
|
const std::filesystem::path& icon_path, const std::string& command,
|
||||||
const std::filesystem::path& command, const std::string& arguments,
|
const std::string& arguments, const std::string& categories,
|
||||||
const std::string& categories, const std::string& keywords,
|
const std::string& keywords, const std::string& name,
|
||||||
const std::string& name);
|
const bool& skip_tryexec);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void OnStartGame();
|
void OnStartGame();
|
||||||
|
Loading…
Reference in New Issue
Block a user