Add QML support for shareplugin
Summary: This will allow it to be used in the plasmoid and QML app via dbus. Reviewers: nicolasfella Reviewed By: nicolasfella Subscribers: kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D16551
This commit is contained in:
parent
bf03990b75
commit
5c86da54aa
4 changed files with 27 additions and 0 deletions
|
@ -90,6 +90,11 @@ QObject* createRemoteCommandsInterface(const QVariant& deviceId)
|
||||||
return new RemoteCommandsDbusInterface(deviceId.toString());
|
return new RemoteCommandsDbusInterface(deviceId.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject* createShareInterface(const QVariant& deviceId)
|
||||||
|
{
|
||||||
|
return new ShareDbusInterface(deviceId.toString());
|
||||||
|
}
|
||||||
|
|
||||||
void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
|
void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
|
||||||
{
|
{
|
||||||
qmlRegisterType<DevicesModel>(uri, 1, 0, "DevicesModel");
|
qmlRegisterType<DevicesModel>(uri, 1, 0, "DevicesModel");
|
||||||
|
@ -103,6 +108,7 @@ void KdeConnectDeclarativePlugin::registerTypes(const char* uri)
|
||||||
qmlRegisterUncreatableType<RemoteKeyboardDbusInterface>(uri, 1, 0, "RemoteKeyboardDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
|
qmlRegisterUncreatableType<RemoteKeyboardDbusInterface>(uri, 1, 0, "RemoteKeyboardDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
|
||||||
qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "DeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
|
qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "DeviceDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
|
||||||
qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "RemoteCommandsDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
|
qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "RemoteCommandsDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
|
||||||
|
qmlRegisterUncreatableType<DeviceDbusInterface>(uri, 1, 0, "ShareDbusInterface", QStringLiteral("You're not supposed to instantiate interfaces"));
|
||||||
qmlRegisterSingletonType<DaemonDbusInterface>(uri, 1, 0, "DaemonDbusInterface",
|
qmlRegisterSingletonType<DaemonDbusInterface>(uri, 1, 0, "DaemonDbusInterface",
|
||||||
[](QQmlEngine*, QJSEngine*) -> QObject* {
|
[](QQmlEngine*, QJSEngine*) -> QObject* {
|
||||||
return new DaemonDbusInterface;
|
return new DaemonDbusInterface;
|
||||||
|
@ -149,4 +155,7 @@ void KdeConnectDeclarativePlugin::initializeEngine(QQmlEngine* engine, const cha
|
||||||
|
|
||||||
engine->rootContext()->setContextProperty(QStringLiteral("RemoteCommandsDbusInterfaceFactory")
|
engine->rootContext()->setContextProperty(QStringLiteral("RemoteCommandsDbusInterfaceFactory")
|
||||||
, new ObjectFactory(engine, createRemoteCommandsInterface));
|
, new ObjectFactory(engine, createRemoteCommandsInterface));
|
||||||
|
|
||||||
|
engine->rootContext()->setContextProperty(QStringLiteral("ShareDbusInterfaceFactory")
|
||||||
|
, new ObjectFactory(engine, createShareInterface));
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ geninterface(${CMAKE_SOURCE_DIR}/plugins/remotecommands/remotecommandsplugin.h r
|
||||||
geninterface(${CMAKE_SOURCE_DIR}/plugins/remotekeyboard/remotekeyboardplugin.h remotekeyboardinterface)
|
geninterface(${CMAKE_SOURCE_DIR}/plugins/remotekeyboard/remotekeyboardplugin.h remotekeyboardinterface)
|
||||||
geninterface(${CMAKE_SOURCE_DIR}/plugins/sms/smsplugin.h smsinterface)
|
geninterface(${CMAKE_SOURCE_DIR}/plugins/sms/smsplugin.h smsinterface)
|
||||||
geninterface(${CMAKE_SOURCE_DIR}/plugins/sms/conversationsdbusinterface.h conversationsinterface)
|
geninterface(${CMAKE_SOURCE_DIR}/plugins/sms/conversationsdbusinterface.h conversationsinterface)
|
||||||
|
geninterface(${CMAKE_SOURCE_DIR}/plugins/share/shareplugin.h shareinterface)
|
||||||
|
|
||||||
|
|
||||||
add_library(kdeconnectinterfaces SHARED ${libkdeconnect_SRC})
|
add_library(kdeconnectinterfaces SHARED ${libkdeconnect_SRC})
|
||||||
|
|
|
@ -182,3 +182,10 @@ SmsDbusInterface::SmsDbusInterface(const QString& deviceId, QObject* parent):
|
||||||
}
|
}
|
||||||
|
|
||||||
SmsDbusInterface::~SmsDbusInterface() = default;
|
SmsDbusInterface::~SmsDbusInterface() = default;
|
||||||
|
|
||||||
|
ShareDbusInterface::ShareDbusInterface(const QString& deviceId, QObject* parent):
|
||||||
|
OrgKdeKdeconnectDeviceShareInterface(DaemonDbusInterface::activatedService(), "/modules/kdeconnect/devices/" + deviceId + "/share", QDBusConnection::sessionBus(), parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ShareDbusInterface::~ShareDbusInterface() = default;
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "interfaces/remotekeyboardinterface.h"
|
#include "interfaces/remotekeyboardinterface.h"
|
||||||
#include "interfaces/smsinterface.h"
|
#include "interfaces/smsinterface.h"
|
||||||
#include "interfaces/conversationsinterface.h"
|
#include "interfaces/conversationsinterface.h"
|
||||||
|
#include "interfaces/shareinterface.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
|
||||||
|
@ -219,6 +220,15 @@ public:
|
||||||
~SmsDbusInterface() override;
|
~SmsDbusInterface() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class KDECONNECTINTERFACES_EXPORT ShareDbusInterface
|
||||||
|
: public OrgKdeKdeconnectDeviceShareInterface
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ShareDbusInterface(const QString& deviceId, QObject* parent = nullptr);
|
||||||
|
~ShareDbusInterface() override;
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T, typename W>
|
template <typename T, typename W>
|
||||||
static void setWhenAvailable(const QDBusPendingReply<T>& pending, W func, QObject* parent)
|
static void setWhenAvailable(const QDBusPendingReply<T>& pending, W func, QObject* parent)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue