aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/MainWindow.cpp
diff options
context:
space:
mode:
authorleo78913 <leo3758@riseup.net>2022-12-08 10:46:58 -0300
committerleo78913 <leo3758@riseup.net>2022-12-08 20:18:07 -0300
commit37ad1b40d8fc86d746ce89219846582ec641f1e6 (patch)
tree10635db55309615c0bf5174d8386c8764cbefaa9 /launcher/ui/MainWindow.cpp
parent5ae044db93373e20add854e3be48e59e6c38421b (diff)
downloadPrismLauncher-37ad1b40d8fc86d746ce89219846582ec641f1e6.tar.gz
PrismLauncher-37ad1b40d8fc86d746ce89219846582ec641f1e6.tar.bz2
PrismLauncher-37ad1b40d8fc86d746ce89219846582ec641f1e6.zip
fix: fix creating instance shortcuts in flatpak
Signed-off-by: leo78913 <leo3758@riseup.net>
Diffstat (limited to 'launcher/ui/MainWindow.cpp')
-rw-r--r--launcher/ui/MainWindow.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index 91cc5f29..8f156bfb 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -2269,10 +2269,25 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create icon for shortcut."));
return;
}
-
- if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()),
- appPath, { "--launch", m_selectedInstance->id() },
- m_selectedInstance->name(), iconPath)) {
+
+ QString desktopFilePath = FS::PathCombine(desktopPath, m_selectedInstance->name() + ".desktop");
+ QStringList args;
+ if (DesktopServices::isFlatpak()) {
+ QFileDialog fileDialog;
+ // workaround to make sure the portal file dialog opens in the desktop directory
+ fileDialog.setDirectoryUrl(desktopPath);
+ desktopFilePath = fileDialog.getSaveFileName(
+ this, tr("Create Shortcut"), desktopFilePath,
+ tr("Desktop Entries (*.desktop)"));
+ if (desktopFilePath.isEmpty())
+ return; // file dialog canceled by user
+ appPath = "flatpak";
+ QString flatpakAppId = BuildConfig.LAUNCHER_DESKTOPFILENAME;
+ flatpakAppId.remove(".desktop");
+ args.append({ "run", flatpakAppId });
+ }
+ args.append({ "--launch", m_selectedInstance->id() });
+ if (FS::createShortcut(desktopFilePath, appPath, args, m_selectedInstance->name(), iconPath)) {
QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance on your desktop!"));
}
else