diff options
author | flow <flowlnlnln@gmail.com> | 2022-12-08 17:53:33 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-08 17:53:33 -0800 |
commit | 9ad4ae5340a2a75ae14a9ca8f232855a0ea17d4f (patch) | |
tree | 260c5dfb6eb237aece20e093a1a80d26f39d3e62 /launcher/ui | |
parent | c390e211eee9adbfdcbe9dfb0a2e23303e046920 (diff) | |
parent | 37ad1b40d8fc86d746ce89219846582ec641f1e6 (diff) | |
download | PrismLauncher-9ad4ae5340a2a75ae14a9ca8f232855a0ea17d4f.tar.gz PrismLauncher-9ad4ae5340a2a75ae14a9ca8f232855a0ea17d4f.tar.bz2 PrismLauncher-9ad4ae5340a2a75ae14a9ca8f232855a0ea17d4f.zip |
Merge pull request #568 from leo78913/flatpak-shortcuts
Diffstat (limited to 'launcher/ui')
-rw-r--r-- | launcher/ui/MainWindow.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 6f855f91..cc81d8e3 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2270,10 +2270,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 |