[plasmoid] Add Photo to Plasmoid menu
Adds a menu entry to ask the remote device to take a photo to the Plasmoid menu
This commit is contained in:
parent
1f5fd06924
commit
4ecf463cd1
6 changed files with 78 additions and 6 deletions
|
@ -79,6 +79,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char *uri)
|
||||||
"RemoteSystemVolumeInterface",
|
"RemoteSystemVolumeInterface",
|
||||||
QStringLiteral("You're not supposed to instantiate interfaces"));
|
QStringLiteral("You're not supposed to instantiate interfaces"));
|
||||||
qmlRegisterUncreatableType<ShareDbusInterface>(uri, 1, 0, "ShareDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
|
qmlRegisterUncreatableType<ShareDbusInterface>(uri, 1, 0, "ShareDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
|
||||||
|
qmlRegisterUncreatableType<PhotoDbusInterface>(uri, 1, 0, "PhotoDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
|
||||||
qmlRegisterUncreatableType<BigscreenDbusInterface>(uri, 1, 0, "BigscreenDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
|
qmlRegisterUncreatableType<BigscreenDbusInterface>(uri, 1, 0, "BigscreenDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
|
||||||
qmlRegisterSingletonType<DaemonDbusInterface>(uri, 1, 0, "DaemonDbusInterface", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
qmlRegisterSingletonType<DaemonDbusInterface>(uri, 1, 0, "DaemonDbusInterface", [](QQmlEngine *, QJSEngine *) -> QObject * {
|
||||||
return new DaemonDbusInterface;
|
return new DaemonDbusInterface;
|
||||||
|
@ -116,6 +117,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char *uri)
|
||||||
registerFactory<SmsDbusInterface>(uri, "SmsDbusInterfaceFactory");
|
registerFactory<SmsDbusInterface>(uri, "SmsDbusInterfaceFactory");
|
||||||
registerFactory<RemoteCommandsDbusInterface>(uri, "RemoteCommandsDbusInterfaceFactory");
|
registerFactory<RemoteCommandsDbusInterface>(uri, "RemoteCommandsDbusInterfaceFactory");
|
||||||
registerFactory<ShareDbusInterface>(uri, "ShareDbusInterfaceFactory");
|
registerFactory<ShareDbusInterface>(uri, "ShareDbusInterfaceFactory");
|
||||||
|
registerFactory<PhotoDbusInterface>(uri, "PhotoDbusInterfaceFactory");
|
||||||
registerFactory<RemoteSystemVolumeDbusInterface>(uri, "RemoteSystemVolumeDbusInterfaceFactory");
|
registerFactory<RemoteSystemVolumeDbusInterface>(uri, "RemoteSystemVolumeDbusInterfaceFactory");
|
||||||
registerFactory<BigscreenDbusInterface>(uri, "BigscreenDbusInterfaceFactory");
|
registerFactory<BigscreenDbusInterface>(uri, "BigscreenDbusInterfaceFactory");
|
||||||
registerFactory<VirtualmonitorDbusInterface>(uri, "VirtualmonitorDbusInterfaceFactory");
|
registerFactory<VirtualmonitorDbusInterface>(uri, "VirtualmonitorDbusInterfaceFactory");
|
||||||
|
|
|
@ -57,6 +57,7 @@ geninterface(${PROJECT_SOURCE_DIR}/plugins/share/shareplugin.h shareinterface)
|
||||||
geninterface(${PROJECT_SOURCE_DIR}/plugins/remotesystemvolume/remotesystemvolumeplugin.h remotesystemvolumeinterface)
|
geninterface(${PROJECT_SOURCE_DIR}/plugins/remotesystemvolume/remotesystemvolumeplugin.h remotesystemvolumeinterface)
|
||||||
geninterface(${PROJECT_SOURCE_DIR}/plugins/bigscreen/bigscreenplugin.h bigscreeninterface)
|
geninterface(${PROJECT_SOURCE_DIR}/plugins/bigscreen/bigscreenplugin.h bigscreeninterface)
|
||||||
geninterface(${PROJECT_SOURCE_DIR}/plugins/virtualmonitor/virtualmonitorplugin.h virtualmonitorinterface)
|
geninterface(${PROJECT_SOURCE_DIR}/plugins/virtualmonitor/virtualmonitorplugin.h virtualmonitorinterface)
|
||||||
|
geninterface(${PROJECT_SOURCE_DIR}/plugins/photo/photoplugin.h photointerface)
|
||||||
|
|
||||||
add_library(kdeconnectinterfaces ${libkdeconnect_SRC})
|
add_library(kdeconnectinterfaces ${libkdeconnect_SRC})
|
||||||
set_target_properties(kdeconnectinterfaces PROPERTIES
|
set_target_properties(kdeconnectinterfaces PROPERTIES
|
||||||
|
|
|
@ -227,11 +227,15 @@ ShareDbusInterface::ShareDbusInterface(const QString &deviceId, QObject *parent)
|
||||||
|
|
||||||
ShareDbusInterface::~ShareDbusInterface() = default;
|
ShareDbusInterface::~ShareDbusInterface() = default;
|
||||||
|
|
||||||
RemoteSystemVolumeDbusInterface::RemoteSystemVolumeDbusInterface(const QString &deviceId, QObject *parent)
|
PhotoDbusInterface::PhotoDbusInterface(const QString& deviceId, QObject* parent):
|
||||||
: OrgKdeKdeconnectDeviceRemotesystemvolumeInterface(DaemonDbusInterface::activatedService(),
|
OrgKdeKdeconnectDevicePhotoInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/photo"), QDBusConnection::sessionBus(), parent)
|
||||||
QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotesystemvolume"),
|
{
|
||||||
QDBusConnection::sessionBus(),
|
}
|
||||||
parent)
|
|
||||||
|
PhotoDbusInterface::~PhotoDbusInterface() = default;
|
||||||
|
|
||||||
|
RemoteSystemVolumeDbusInterface::RemoteSystemVolumeDbusInterface(const QString& deviceId, QObject* parent):
|
||||||
|
OrgKdeKdeconnectDeviceRemotesystemvolumeInterface(DaemonDbusInterface::activatedService(), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/remotesystemvolume"), QDBusConnection::sessionBus(), parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "shareinterface.h"
|
#include "shareinterface.h"
|
||||||
#include "smsinterface.h"
|
#include "smsinterface.h"
|
||||||
#include "virtualmonitorinterface.h"
|
#include "virtualmonitorinterface.h"
|
||||||
|
#include "photointerface.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Using these "proxy" classes just in case we need to rename the
|
* Using these "proxy" classes just in case we need to rename the
|
||||||
|
@ -229,7 +230,17 @@ public:
|
||||||
~ShareDbusInterface() override;
|
~ShareDbusInterface() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KDECONNECTINTERFACES_EXPORT RemoteSystemVolumeDbusInterface : public OrgKdeKdeconnectDeviceRemotesystemvolumeInterface
|
class KDECONNECTINTERFACES_EXPORT PhotoDbusInterface
|
||||||
|
: public OrgKdeKdeconnectDevicePhotoInterface
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit PhotoDbusInterface(const QString& deviceId, QObject* parent = nullptr);
|
||||||
|
~PhotoDbusInterface() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KDECONNECTINTERFACES_EXPORT RemoteSystemVolumeDbusInterface
|
||||||
|
: public OrgKdeKdeconnectDeviceRemotesystemvolumeInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -170,6 +170,28 @@ PlasmaComponents.ListItem
|
||||||
onClicked: fileDialog.open()
|
onClicked: fileDialog.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Photo
|
||||||
|
PlasmaComponents.MenuItem
|
||||||
|
{
|
||||||
|
FileDialog {
|
||||||
|
id: photoFileDialog
|
||||||
|
title: i18n("Save As")
|
||||||
|
folder: shortcuts.pictures
|
||||||
|
selectMultiple: false
|
||||||
|
selectExisting: false
|
||||||
|
onAccepted: {
|
||||||
|
var path = photoFileDialog.fileUrl.toString();
|
||||||
|
photo.plugin.requestPhoto(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
id: takePhoto
|
||||||
|
icon: "camera-photo-symbolic"
|
||||||
|
visible: photo.available
|
||||||
|
text: i18n("Take a photo")
|
||||||
|
onClicked: photoFileDialog.open()
|
||||||
|
}
|
||||||
|
|
||||||
//Find my phone
|
//Find my phone
|
||||||
PlasmaComponents.MenuItem
|
PlasmaComponents.MenuItem
|
||||||
{
|
{
|
||||||
|
@ -407,5 +429,11 @@ PlasmaComponents.ListItem
|
||||||
id: share
|
id: share
|
||||||
device: root.device
|
device: root.device
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Photo
|
||||||
|
Photo {
|
||||||
|
id: photo
|
||||||
|
device: root.device
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
plasmoid/package/contents/ui/Photo.qml
Normal file
26
plasmoid/package/contents/ui/Photo.qml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/**
|
||||||
|
* SPDX-FileCopyrightText: 2022 Kareem Abduljaleel <karemjaleel34@gmail.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.1
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
|
import org.kde.kdeconnect 1.0
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property alias device: checker.device
|
||||||
|
readonly property alias available: checker.available
|
||||||
|
|
||||||
|
readonly property PluginChecker pluginChecker: PluginChecker {
|
||||||
|
id: checker
|
||||||
|
pluginName: "photo"
|
||||||
|
}
|
||||||
|
|
||||||
|
property variant plugin: available ? PhotoDbusInterfaceFactory.create(device.id()) : null
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue