diff --git a/plasmoid/package/contents/ui/Battery.qml b/plasmoid/package/contents/ui/Battery.qml index 50adcd8c6..5559f9760 100644 --- a/plasmoid/package/contents/ui/Battery.qml +++ b/plasmoid/package/contents/ui/Battery.qml @@ -28,12 +28,12 @@ QtObject { id: root property string deviceId: "" + property variant device: DeviceDbusInterfaceFactory.create(deviceId) property bool available: false + property bool charging: false property int charge: -1 property string displayString: (available && charge > -1) ? ((charging) ? (i18n("Charging, %1").arg(charge)) : (i18n("Discharging, %1").arg(charge))) : i18n("No info") - - property variant device: DeviceDbusInterfaceFactory.create(deviceId) property variant battery: null property variant nested1: DBusAsyncResponse { @@ -48,6 +48,7 @@ QtObject { onSuccess: root.charge = result } + /* Note: magically called by qml */ onAvailableChanged: { if (available) { battery = DeviceBatteryDbusInterfaceFactory.create(deviceId) diff --git a/plasmoid/package/contents/ui/DeviceDelegate.qml b/plasmoid/package/contents/ui/DeviceDelegate.qml index a58255cec..372a1b63e 100644 --- a/plasmoid/package/contents/ui/DeviceDelegate.qml +++ b/plasmoid/package/contents/ui/DeviceDelegate.qml @@ -36,21 +36,22 @@ PlasmaComponents.ListItem Row { PlasmaComponents.Label { - width: parent.width - browse.width + width: browse.visible? parent.width - browse.width : parent.width horizontalAlignment: Text.AlignHCenter text: display } PlasmaComponents.Button { - id: browse - iconSource: "document-open-folder" - Sftp { id: sftp deviceId: root.deviceId } + id: browse + iconSource: "document-open-folder" + visible: sftp.available + onClicked: { sftp.browse() } @@ -63,12 +64,12 @@ PlasmaComponents.ListItem //Battery PlasmaComponents.ListItem { - + Battery { id: battery deviceId: root.deviceId } - + sectionDelegate: true visible: battery.available PlasmaComponents.Label { @@ -80,7 +81,7 @@ PlasmaComponents.ListItem anchors.right: parent.right } } - + //Notifications PlasmaComponents.ListItem { visible: notificationsModel.count>0 @@ -122,11 +123,9 @@ PlasmaComponents.ListItem onClicked: dbusInterface.dismiss(); } } - //FIXME - //Repeater.onItemAdded: plasmoid.status = "NeedsAttentionStatus"; } - //TODO: Other information could be displayed here + //NOTE: More information could be displayed here } } diff --git a/plasmoid/package/contents/ui/Sftp.qml b/plasmoid/package/contents/ui/Sftp.qml index e42dc6baf..cd9760414 100644 --- a/plasmoid/package/contents/ui/Sftp.qml +++ b/plasmoid/package/contents/ui/Sftp.qml @@ -28,29 +28,24 @@ QtObject { id: root property string deviceId: "" - property bool isMounted: false - property variant sftp: SftpDbusInterfaceFactory.create(deviceId) + property variant device: DeviceDbusInterfaceFactory.create(deviceId) + property bool available: false + property bool isMounted: false + property variant sftp: null property variant nested: DBusAsyncResponse { id: startupCheck onSuccess: (result) ? root.mounted() : root.unmounted() onError: root.error(message) } - + signal mounted signal unmounted signal error(string message) onMounted: isMounted = true onUnmounted: isMounted = false - - Component.onCompleted: { - sftp.mounted.connect(mounted) - sftp.unmounted.connect(unmounted) - - startupCheck.setPendingCall(sftp.isMounted()) - } - + function browse() { startupCheck.setPendingCall(sftp.startBrowsing()) } @@ -58,5 +53,36 @@ QtObject { function unmount() { sftp.unmount() } + + Component.onCompleted: { + device.pluginsChanged.connect(pluginsChanged) + device.pluginsChanged() + } + + /* Note: magically called by qml */ + onAvailableChanged: { + if (available) { + sftp = SftpDbusInterfaceFactory.create(deviceId) + + sftp.mounted.connect(mounted) + sftp.unmounted.connect(unmounted) + + startupCheck.setPendingCall(sftp.isMounted()) + } + else { + sftp = null + } + } + function pluginsChanged() { + var result = DBusResponseWaiter.waitForReply(device.hasPlugin("kdeconnect_sftp")) + + if (result && result != "error") { + available = true + } + else { + available = false + } + } + }