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)
|
||||
: OrgKdeKdeconnectDeviceInterface(activatedService(), "/modules/kdeconnect/devices/"+id, QDBusConnection::sessionBus(), parent)
|
||||
{
|
||||
|
||||
connect(this, &OrgKdeKdeconnectDeviceInterface::pairingChanged, this, &DeviceDbusInterface::pairingChangedProxy);
|
||||
}
|
||||
|
||||
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)
|
||||
: OrgKdeKdeconnectDeviceBatteryInterface(activatedService(), "/modules/kdeconnect/devices/"+id, QDBusConnection::sessionBus(), parent)
|
||||
{
|
||||
|
|
|
@ -47,9 +47,17 @@ class KDECONNECTINTERFACES_EXPORT DeviceDbusInterface
|
|||
: public OrgKdeKdeconnectDeviceInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
// Workaround because OrgKdeKdeconnectDeviceInterface is not generating
|
||||
// the signals for the properties
|
||||
Q_PROPERTY(bool isPaired READ isPaired NOTIFY pairingChangedProxy)
|
||||
public:
|
||||
DeviceDbusInterface(const QString& deviceId, QObject* parent = 0);
|
||||
virtual ~DeviceDbusInterface();
|
||||
|
||||
Q_SCRIPTABLE void pluginCall(const QString &plugin, const QString &method);
|
||||
|
||||
Q_SIGNALS:
|
||||
void pairingChangedProxy(bool paired);
|
||||
};
|
||||
|
||||
class KDECONNECTINTERFACES_EXPORT DeviceBatteryDbusInterface
|
||||
|
|
|
@ -276,8 +276,7 @@ void KdeConnectKcm::save()
|
|||
void KdeConnectKcm::sendPing()
|
||||
{
|
||||
if (!currentDevice) return;
|
||||
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+currentDevice->id()+"/ping", "org.kde.kdeconnect.device.ping", "sendPing");
|
||||
QDBusConnection::sessionBus().call(msg);
|
||||
currentDevice->pluginCall("ping", "sendPing");
|
||||
}
|
||||
|
||||
QSize KdeConnectKcm::sizeHint() const
|
||||
|
|
Loading…
Reference in a new issue