From e10b098ed34c8b46309e3f79e8429fbf5b3c896f Mon Sep 17 00:00:00 2001 From: Piyush Aggarwal Date: Sat, 12 Jun 2021 17:03:40 +0530 Subject: [PATCH] systray: add photo plugin to systray actions --- indicator/deviceindicator.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/indicator/deviceindicator.cpp b/indicator/deviceindicator.cpp index a818b07ad..56f2de29f 100644 --- a/indicator/deviceindicator.cpp +++ b/indicator/deviceindicator.cpp @@ -7,11 +7,14 @@ #include "deviceindicator.h" #include +#include +#include #include #include "interfaces/dbusinterfaces.h" #include +#include #include DeviceIndicator::DeviceIndicator(DeviceDbusInterface* device) @@ -60,6 +63,15 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface* device) }); setWhenAvailable(device->hasPlugin(QStringLiteral("kdeconnect_findmyphone")), [findDevice](bool available) { findDevice->setVisible(available); }, this); + // Get a photo + auto getPhoto = addAction(QIcon::fromTheme(QStringLiteral("camera-photo")), i18n("Get a photo")); + connect(getPhoto, &QAction::triggered, this, [device](){ + QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device->id() + QStringLiteral("/photo"), QStringLiteral("org.kde.kdeconnect.device.photo"), QStringLiteral("requestPhoto")); + msg.setArguments({QStandardPaths::standardLocations(QStandardPaths::DownloadLocation).first() + QDateTime::currentDateTime().toString(QStringLiteral("/dd-MM-yy_hh-mm-ss.png"))}); + blockOnReply(DBusHelper::sessionBus().asyncCall(msg)); + }); + setWhenAvailable(device->hasPlugin(QStringLiteral("kdeconnect_photo")), [getPhoto](bool available) { getPhoto->setVisible(available); }, this); + // Send file const QString kdeconnectHandlerExecutable = QStandardPaths::findExecutable(QStringLiteral("kdeconnect-handler")); if (!kdeconnectHandlerExecutable.isEmpty()) {