From 0b72150ed83f98b8915d89acb4d671732224e9c5 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sat, 3 Nov 2018 22:16:07 +0100 Subject: [PATCH] Add support for sharing text via qml Summary: This allows you to send a text string from qml, this can be used in the plasmoid and qml app. Reviewers: nicolasfella Reviewed By: nicolasfella Subscribers: kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D16640 --- plugins/share/shareplugin.cpp | 7 +++++++ plugins/share/shareplugin.h | 1 + 2 files changed, 8 insertions(+) diff --git a/plugins/share/shareplugin.cpp b/plugins/share/shareplugin.cpp index 356b1ec60..ad92bde91 100644 --- a/plugins/share/shareplugin.cpp +++ b/plugins/share/shareplugin.cpp @@ -166,6 +166,13 @@ void SharePlugin::shareUrl(const QUrl& url) sendPacket(packet); } +void SharePlugin::shareText(const QString& text) +{ + NetworkPacket packet(PACKET_TYPE_SHARE_REQUEST); + packet.set(QStringLiteral("text"), text); + sendPacket(packet); +} + QString SharePlugin::dbusPath() const { return "/modules/kdeconnect/devices/" + device()->id() + "/share"; diff --git a/plugins/share/shareplugin.h b/plugins/share/shareplugin.h index 2a9debeb5..92faff40d 100644 --- a/plugins/share/shareplugin.h +++ b/plugins/share/shareplugin.h @@ -38,6 +38,7 @@ public: ///Helper method, QDBus won't recognize QUrl Q_SCRIPTABLE void shareUrl(const QString& url) { shareUrl(QUrl(url)); } + Q_SCRIPTABLE void shareText(const QString& text); bool receivePacket(const NetworkPacket& np) override; void connected() override {}