┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Lohnau <[email protected]>2020-04-13 15:29:50 +0200
committerAlexander Lohnau <[email protected]>2020-04-13 21:23:52 +0200
commit514d9c8fc9705f76fda8f22c70730fb9c383c95a (patch)
tree083f698c349bea964bb42f8032bc4b7d47b13264
parent35b4c6d4df1281afd621374e686f19e654ad7bae (diff)
Dolphin Services: Launch Deb/Rpm archives with QDesktopServices
Summary: When you are inside the services store and you choose to install a deb/rpm package they open in the default application (mostlikely a package installer utility like discover). PS: I have written some ideas/questions, maybe you can comment on them :-) ? Test Plan: Tests still pass, try out what was described in the summary. A product which has a deb/rpm package is for example: `Jetbrains Dolphin Plugin` Reviewers: #dolphin, elvisangelaccio, ngraham, aspotashev Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D28795
-rw-r--r--src/settings/services/servicemenuinstaller/CMakeLists.txt1
-rw-r--r--src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp9
2 files changed, 9 insertions, 1 deletions
diff --git a/src/settings/services/servicemenuinstaller/CMakeLists.txt b/src/settings/services/servicemenuinstaller/CMakeLists.txt
index b5591cad7..988899936 100644
--- a/src/settings/services/servicemenuinstaller/CMakeLists.txt
+++ b/src/settings/services/servicemenuinstaller/CMakeLists.txt
@@ -4,6 +4,7 @@ add_definitions(-DTRANSLATION_DOMAIN=\"dolphin_servicemenuinstaller\")
add_executable(servicemenuinstaller servicemenuinstaller.cpp)
target_link_libraries(servicemenuinstaller PRIVATE
Qt5::Core
+ Qt5::Gui
KF5::I18n
)
install(TARGETS servicemenuinstaller ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp b/src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp
index e3866a6ae..73882e8c2 100644
--- a/src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp
+++ b/src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp
@@ -25,6 +25,9 @@
#include <QDirIterator>
#include <QCommandLineParser>
#include <QMimeDatabase>
+#include <QUrl>
+#include <QDesktopServices>
+#include <QGuiApplication>
#include <KLocalizedString>
@@ -201,6 +204,10 @@ bool cmdInstall(const QString &archive, QString &errorText)
return false;
}
} else {
+ const QStringList binaryPackages = {"application/vnd.debian.binary-package", "application/x-rpm"};
+ if (binaryPackages.contains(QMimeDatabase().mimeTypeForFile(archive).name())) {
+ return QDesktopServices::openUrl(QUrl(archive));
+ }
const QString dir = generateDirPath(archive);
if (QFile::exists(dir)) {
if (!QDir(dir).removeRecursively()) {
@@ -318,7 +325,7 @@ bool cmdUninstall(const QString &archive, QString &errorText)
int main(int argc, char *argv[])
{
- QCoreApplication app(argc, argv);
+ QGuiApplication app(argc, argv);
QCommandLineParser parser;
parser.addPositionalArgument(QStringLiteral("command"), i18nc("@info:shell", "Command to execute: install or uninstall."));