From 8ac7922252eb0951f6dc8f77acfce8d5c09f697b Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 11 Jan 2017 18:04:01 +0100 Subject: [PATCH] Implement send file for kdeconnect-indicator --- indicator/deviceindicator.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/indicator/deviceindicator.cpp b/indicator/deviceindicator.cpp index 87737a549..32600d79a 100644 --- a/indicator/deviceindicator.cpp +++ b/indicator/deviceindicator.cpp @@ -19,6 +19,7 @@ */ #include "deviceindicator.h" +#include #include template @@ -97,7 +98,17 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface* device) }); setWhenAvailable(device->hasPlugin("kdeconnect_findmyphone"), [findDevice](bool available) { findDevice->setEnabled(available); }, this); -// addAction(i18n("Send file")); //TODO + auto sendFile = addAction(i18n("Send file")); + connect(sendFile, &QAction::triggered, device, [device, this](){ + const QUrl url = QFileDialog::getOpenFileUrl(parentWidget(), i18n("Select file to send to '%1'", device->name()), QUrl::fromLocalFile(QDir::homePath())); + if (url.isEmpty()) + return; + + QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+device->id()+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl")); + msg.setArguments(QVariantList() << url.toString()); + QDBusConnection::sessionBus().call(msg); + }); + setWhenAvailable(device->hasPlugin("kdeconnect_share"), [sendFile](bool available) { sendFile->setEnabled(available); }, this); addSeparator(); auto unpair = addAction(i18n("Unpair"));