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
|
||||
// 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,
|
||||
const std::string& comment,
|
||||
const std::filesystem::path& icon_path,
|
||||
const std::filesystem::path& command,
|
||||
const std::string& arguments, const std::string& categories,
|
||||
const std::string& keywords, const std::string& name) try {
|
||||
const std::string& command, const std::string& arguments,
|
||||
const std::string& categories, const std::string& keywords,
|
||||
const std::string& name, const bool& skip_tryexec) try {
|
||||
#if defined(__linux__) || defined(__FreeBSD__) // Linux and FreeBSD
|
||||
std::filesystem::path shortcut_path_full = shortcut_path / (name + ".desktop");
|
||||
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)) {
|
||||
fmt::print(shortcut_stream, "Icon={}\n", icon_path.string());
|
||||
}
|
||||
fmt::print(shortcut_stream, "TryExec={}\n", command.string());
|
||||
fmt::print(shortcut_stream, "Exec={} {}\n", command.string(), arguments);
|
||||
if (!skip_tryexec) {
|
||||
fmt::print(shortcut_stream, "TryExec={}\n", command);
|
||||
}
|
||||
fmt::print(shortcut_stream, "Exec={} {}\n", command, arguments);
|
||||
if (!categories.empty()) {
|
||||
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,
|
||||
GameListShortcutTarget target) {
|
||||
// Get path to Lime3DS executable
|
||||
const QStringList args = QApplication::arguments();
|
||||
std::filesystem::path 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.string();
|
||||
std::string lime_command{};
|
||||
bool skip_tryexec = false;
|
||||
const char* env_flatpak_id = getenv("FLATPAK_ID");
|
||||
if (env_flatpak_id) {
|
||||
lime_command = fmt::format("flatpak run {}", env_flatpak_id);
|
||||
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
|
||||
@ -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
|
||||
const std::string appimage_ending =
|
||||
std::string(Common::g_scm_rev).substr(0, 9).append(".AppImage");
|
||||
if (lime_command.string().ends_with(appimage_ending) &&
|
||||
!UISettings::values.shortcut_already_warned) {
|
||||
if (lime_command.ends_with(appimage_ending) && !UISettings::values.shortcut_already_warned) {
|
||||
if (CreateShortcutMessagesGUI(this, CREATE_SHORTCUT_MSGBOX_APPIMAGE_VOLATILE_WARNING,
|
||||
qt_game_title)) {
|
||||
return;
|
||||
@ -2003,7 +2012,7 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga
|
||||
const std::string keywords = "3ds;Nintendo;";
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -217,10 +217,10 @@ private:
|
||||
bool MakeShortcutIcoPath(const u64 program_id, const std::string_view game_file_name,
|
||||
std::filesystem::path& out_icon_path);
|
||||
bool CreateShortcutLink(const std::filesystem::path& shortcut_path, const std::string& comment,
|
||||
const std::filesystem::path& icon_path,
|
||||
const std::filesystem::path& command, const std::string& arguments,
|
||||
const std::string& categories, const std::string& keywords,
|
||||
const std::string& name);
|
||||
const std::filesystem::path& icon_path, const std::string& command,
|
||||
const std::string& arguments, const std::string& categories,
|
||||
const std::string& keywords, const std::string& name,
|
||||
const bool& skip_tryexec);
|
||||
|
||||
private slots:
|
||||
void OnStartGame();
|
||||
|
Loading…
Reference in New Issue
Block a user