From b69247b4e5ef0ebab58edc639c9d0d094b1a0cde Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sun, 21 Aug 2016 18:57:27 +0200 Subject: [PATCH] Don't force the creation of a DeviceInterface for every pluginchecker Create one per device and share it --- app/qml/PluginItem.qml | 2 +- plasmoid/declarativeplugin/qml/PluginChecker.qml | 4 +--- plasmoid/package/contents/ui/Battery.qml | 5 ++--- plasmoid/package/contents/ui/DeviceDelegate.qml | 12 +++++------- plasmoid/package/contents/ui/FindMyPhone.qml | 5 ++--- plasmoid/package/contents/ui/Sftp.qml | 5 ++--- 6 files changed, 13 insertions(+), 20 deletions(-) diff --git a/app/qml/PluginItem.qml b/app/qml/PluginItem.qml index ec6afde75..cf96aad34 100644 --- a/app/qml/PluginItem.qml +++ b/app/qml/PluginItem.qml @@ -32,7 +32,7 @@ Kirigami.BasicListItem readonly property var checker: PluginChecker { id: checker - deviceId: deviceView.currentDevice.id() + device: deviceView.currentDevice } visible: checker.available onClicked: { diff --git a/plasmoid/declarativeplugin/qml/PluginChecker.qml b/plasmoid/declarativeplugin/qml/PluginChecker.qml index 194b4fb6a..dfd1114e7 100644 --- a/plasmoid/declarativeplugin/qml/PluginChecker.qml +++ b/plasmoid/declarativeplugin/qml/PluginChecker.qml @@ -26,14 +26,12 @@ QtObject { id: root - property string deviceId: "" + property alias device: conn.target property string pluginName: "" property bool available: false - readonly property alias device: conn.target readonly property Connections connection: Connections { id: conn - target: DeviceDbusInterfaceFactory.create(root.deviceId) onPluginsChanged: pluginsChanged() } diff --git a/plasmoid/package/contents/ui/Battery.qml b/plasmoid/package/contents/ui/Battery.qml index 02bf7cf91..2dd9aca38 100644 --- a/plasmoid/package/contents/ui/Battery.qml +++ b/plasmoid/package/contents/ui/Battery.qml @@ -27,8 +27,7 @@ QtObject { id: root - property alias deviceId: checker.deviceId - readonly property alias device: checker.device + property alias device: checker.device readonly property alias available: checker.available readonly property PluginChecker pluginChecker: PluginChecker { @@ -55,7 +54,7 @@ QtObject { onAvailableChanged: { if (available) { - battery = DeviceBatteryDbusInterfaceFactory.create(deviceId) + battery = DeviceBatteryDbusInterfaceFactory.create(device.id()) battery.stateChanged.connect(function(c) {charging = c}) battery.chargeChanged.connect(function(c) {charge = c}) diff --git a/plasmoid/package/contents/ui/DeviceDelegate.qml b/plasmoid/package/contents/ui/DeviceDelegate.qml index a4f70eb30..e9419e7eb 100644 --- a/plasmoid/package/contents/ui/DeviceDelegate.qml +++ b/plasmoid/package/contents/ui/DeviceDelegate.qml @@ -27,10 +27,8 @@ import org.kde.kdeconnect 1.0 PlasmaComponents.ListItem { id: root - property string deviceId: model.deviceId - + readonly property QtObject device: DeviceDbusInterfaceFactory.create(model.deviceId) - Column { width: parent.width @@ -53,7 +51,7 @@ PlasmaComponents.ListItem { FindMyPhone { id: findmyphone - deviceId: root.deviceId + device: root.device } id: ring @@ -71,7 +69,7 @@ PlasmaComponents.ListItem { Sftp { id: sftp - deviceId: root.deviceId + device: root.device } id: browse @@ -93,7 +91,7 @@ PlasmaComponents.ListItem Battery { id: battery - deviceId: root.deviceId + device: root.device } sectionDelegate: true @@ -129,7 +127,7 @@ PlasmaComponents.ListItem id: notificationsView model: NotificationsModel { id: notificationsModel - deviceId: root.deviceId + deviceId: root.device.id() } delegate: PlasmaComponents.ListItem { PlasmaComponents.Label { diff --git a/plasmoid/package/contents/ui/FindMyPhone.qml b/plasmoid/package/contents/ui/FindMyPhone.qml index 3a23fde76..846c15308 100644 --- a/plasmoid/package/contents/ui/FindMyPhone.qml +++ b/plasmoid/package/contents/ui/FindMyPhone.qml @@ -27,8 +27,7 @@ QtObject { id: root - property alias deviceId: checker.deviceId - readonly property alias device: checker.device + property alias device: checker.device readonly property alias available: checker.available readonly property PluginChecker pluginChecker: PluginChecker { @@ -46,7 +45,7 @@ QtObject { onAvailableChanged: { if (available) { - findMyPhone = FindMyPhoneDbusInterfaceFactory.create(deviceId) + findMyPhone = FindMyPhoneDbusInterfaceFactory.create(device.id()) } else { findMyPhone = null } diff --git a/plasmoid/package/contents/ui/Sftp.qml b/plasmoid/package/contents/ui/Sftp.qml index fd817e567..e3fc65f6b 100644 --- a/plasmoid/package/contents/ui/Sftp.qml +++ b/plasmoid/package/contents/ui/Sftp.qml @@ -27,8 +27,7 @@ QtObject { id: root - property alias deviceId: checker.deviceId - readonly property alias device: checker.device + property alias device: checker.device readonly property alias available: checker.available readonly property PluginChecker pluginChecker: PluginChecker { @@ -45,7 +44,7 @@ QtObject { onAvailableChanged: { if (available) { - sftp = SftpDbusInterfaceFactory.create(deviceId) + sftp = SftpDbusInterfaceFactory.create(device.id()) } else { sftp = null }