QML-ify
Add API to call random public plugin methods qdbusxml2cpp is not generating the Q_PROPERTY attribute. For now [1], add it ourselves by addding a proxy signal. REVIEW: 124077
This commit is contained in:
parent
cee2c6b057
commit
7c2e2fb726
3 changed files with 16 additions and 3 deletions
|
@ -40,7 +40,7 @@ DaemonDbusInterface::~DaemonDbusInterface()
|
||||||
DeviceDbusInterface::DeviceDbusInterface(const QString& id, QObject* parent)
|
DeviceDbusInterface::DeviceDbusInterface(const QString& id, QObject* parent)
|
||||||
: OrgKdeKdeconnectDeviceInterface(activatedService(), "/modules/kdeconnect/devices/"+id, QDBusConnection::sessionBus(), parent)
|
: OrgKdeKdeconnectDeviceInterface(activatedService(), "/modules/kdeconnect/devices/"+id, QDBusConnection::sessionBus(), parent)
|
||||||
{
|
{
|
||||||
|
connect(this, &OrgKdeKdeconnectDeviceInterface::pairingChanged, this, &DeviceDbusInterface::pairingChangedProxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceDbusInterface::~DeviceDbusInterface()
|
DeviceDbusInterface::~DeviceDbusInterface()
|
||||||
|
@ -48,6 +48,12 @@ DeviceDbusInterface::~DeviceDbusInterface()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceDbusInterface::pluginCall(const QString &plugin, const QString &method)
|
||||||
|
{
|
||||||
|
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+id()+'/'+plugin, "org.kde.kdeconnect.device."+plugin, method);
|
||||||
|
QDBusConnection::sessionBus().asyncCall(msg);
|
||||||
|
}
|
||||||
|
|
||||||
DeviceBatteryDbusInterface::DeviceBatteryDbusInterface(const QString& id, QObject* parent)
|
DeviceBatteryDbusInterface::DeviceBatteryDbusInterface(const QString& id, QObject* parent)
|
||||||
: OrgKdeKdeconnectDeviceBatteryInterface(activatedService(), "/modules/kdeconnect/devices/"+id, QDBusConnection::sessionBus(), parent)
|
: OrgKdeKdeconnectDeviceBatteryInterface(activatedService(), "/modules/kdeconnect/devices/"+id, QDBusConnection::sessionBus(), parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,9 +47,17 @@ class KDECONNECTINTERFACES_EXPORT DeviceDbusInterface
|
||||||
: public OrgKdeKdeconnectDeviceInterface
|
: public OrgKdeKdeconnectDeviceInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
// Workaround because OrgKdeKdeconnectDeviceInterface is not generating
|
||||||
|
// the signals for the properties
|
||||||
|
Q_PROPERTY(bool isPaired READ isPaired NOTIFY pairingChangedProxy)
|
||||||
public:
|
public:
|
||||||
DeviceDbusInterface(const QString& deviceId, QObject* parent = 0);
|
DeviceDbusInterface(const QString& deviceId, QObject* parent = 0);
|
||||||
virtual ~DeviceDbusInterface();
|
virtual ~DeviceDbusInterface();
|
||||||
|
|
||||||
|
Q_SCRIPTABLE void pluginCall(const QString &plugin, const QString &method);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void pairingChangedProxy(bool paired);
|
||||||
};
|
};
|
||||||
|
|
||||||
class KDECONNECTINTERFACES_EXPORT DeviceBatteryDbusInterface
|
class KDECONNECTINTERFACES_EXPORT DeviceBatteryDbusInterface
|
||||||
|
|
|
@ -276,8 +276,7 @@ void KdeConnectKcm::save()
|
||||||
void KdeConnectKcm::sendPing()
|
void KdeConnectKcm::sendPing()
|
||||||
{
|
{
|
||||||
if (!currentDevice) return;
|
if (!currentDevice) return;
|
||||||
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+currentDevice->id()+"/ping", "org.kde.kdeconnect.device.ping", "sendPing");
|
currentDevice->pluginCall("ping", "sendPing");
|
||||||
QDBusConnection::sessionBus().call(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize KdeConnectKcm::sizeHint() const
|
QSize KdeConnectKcm::sizeHint() const
|
||||||
|
|
Loading…
Reference in a new issue