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
This commit is contained in:
Billy Laws 2018-11-03 22:16:07 +01:00 committed by Nicolas Fella
parent 276d18a02a
commit 0b72150ed8
2 changed files with 8 additions and 0 deletions

View file

@ -166,6 +166,13 @@ void SharePlugin::shareUrl(const QUrl& url)
sendPacket(packet); sendPacket(packet);
} }
void SharePlugin::shareText(const QString& text)
{
NetworkPacket packet(PACKET_TYPE_SHARE_REQUEST);
packet.set<QString>(QStringLiteral("text"), text);
sendPacket(packet);
}
QString SharePlugin::dbusPath() const QString SharePlugin::dbusPath() const
{ {
return "/modules/kdeconnect/devices/" + device()->id() + "/share"; return "/modules/kdeconnect/devices/" + device()->id() + "/share";

View file

@ -38,6 +38,7 @@ public:
///Helper method, QDBus won't recognize QUrl ///Helper method, QDBus won't recognize QUrl
Q_SCRIPTABLE void shareUrl(const QString& url) { shareUrl(QUrl(url)); } Q_SCRIPTABLE void shareUrl(const QString& url) { shareUrl(QUrl(url)); }
Q_SCRIPTABLE void shareText(const QString& text);
bool receivePacket(const NetworkPacket& np) override; bool receivePacket(const NetworkPacket& np) override;
void connected() override {} void connected() override {}