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
This commit is contained in:
parent
cec5d8086a
commit
6712953279
1 changed files with 11 additions and 0 deletions
11
app/main.cpp
11
app/main.cpp
|
@ -11,6 +11,7 @@
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQuickStyle>
|
#include <QQuickStyle>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
#include <KAboutData>
|
#include <KAboutData>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
@ -35,11 +36,21 @@ int main(int argc, char* argv[])
|
||||||
QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
|
QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString urlToShare;
|
||||||
{
|
{
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
|
parser.addPositionalArgument(QStringLiteral("url"), i18n("URL to share"));
|
||||||
aboutData.setupCommandLine(&parser);
|
aboutData.setupCommandLine(&parser);
|
||||||
parser.process(app);
|
parser.process(app);
|
||||||
aboutData.processCommandLine(&parser);
|
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;
|
QQmlApplicationEngine engine;
|
||||||
|
|
Loading…
Reference in a new issue