From 6712953279d38a9e2798c69557f4ec8e77b27d87 Mon Sep 17 00:00:00 2001 From: Piyush Aggarwal Date: Wed, 14 Jul 2021 09:14:12 +0530 Subject: [PATCH] kdeconnect-app: add CLI option to allow starting handler via app this feature is important to enable sendTo-menu-like integration in the Microsoft Store build --- app/main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/main.cpp b/app/main.cpp index 49bd26515..a726638a8 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -35,11 +36,21 @@ int main(int argc, char* argv[]) QQuickStyle::setStyle(QStringLiteral("org.kde.desktop")); } + QString urlToShare; { QCommandLineParser parser; + parser.addPositionalArgument(QStringLiteral("url"), i18n("URL to share")); aboutData.setupCommandLine(&parser); parser.process(app); aboutData.processCommandLine(&parser); + if (parser.positionalArguments().count() == 1) { + urlToShare = parser.positionalArguments().constFirst(); + const QString kdeconnectHandlerExecutable = QStandardPaths::findExecutable(QStringLiteral("kdeconnect-handler"), { QCoreApplication::applicationDirPath() }); + if (!kdeconnectHandlerExecutable.isEmpty()) { + QProcess::startDetached(kdeconnectHandlerExecutable, { urlToShare }); + return 0; // exit the app once kdeconnect-handler is started + } + } } QQmlApplicationEngine engine;