From 5d8cf9544c0df2352a43f9ee487cedcb4c45a785 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Fri, 13 Mar 2015 00:56:25 +0100 Subject: [PATCH] Fix how the plasmoid status is specified No need to show the FullRepresentation to figure out the status of the plasmoid. Moves the code back to the main.qml file so that we're always tracking if there's actually paired devices. REVIEW: 122912 --- .../package/contents/ui/FullRepresentation.qml | 18 +----------------- plasmoid/package/contents/ui/main.qml | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/plasmoid/package/contents/ui/FullRepresentation.qml b/plasmoid/package/contents/ui/FullRepresentation.qml index 98e2e0349..99f25ed31 100644 --- a/plasmoid/package/contents/ui/FullRepresentation.qml +++ b/plasmoid/package/contents/ui/FullRepresentation.qml @@ -26,6 +26,7 @@ import org.kde.kdeconnect 1.0 as KdeConnect Item { id: kdeconnect + property alias devicesModel: devicesView.model PlasmaExtras.Heading { width: parent.width @@ -44,15 +45,6 @@ Item { } */ - function shouldPlasmoidBeShown() - { - if (devicesView.count > 0) { - plasmoid.status = PlasmaCore.Types.ActiveStatus; - } else { - plasmoid.status = PlasmaCore.Types.PassiveStatus; - } - } - PlasmaExtras.ScrollArea { id: dialogItem anchors.fill: parent @@ -60,15 +52,7 @@ Item { ListView { id: devicesView anchors.fill: parent - model: KdeConnect.DevicesModel { - id: connectDeviceModel - displayFilter: KdeConnect.DevicesModel.StatusPaired | KdeConnect.DevicesModel.StatusReachable - - } delegate: DeviceDelegate { } - onCountChanged: shouldPlasmoidBeShown() - Component.onCompleted: shouldPlasmoidBeShown(); } } - } diff --git a/plasmoid/package/contents/ui/main.qml b/plasmoid/package/contents/ui/main.qml index 71e66b1d5..3e3be274e 100644 --- a/plasmoid/package/contents/ui/main.qml +++ b/plasmoid/package/contents/ui/main.qml @@ -32,8 +32,22 @@ Item return (plasmoid.formFactor == PlasmaCore.Types.Vertical || plasmoid.formFactor == PlasmaCore.Types.Horizontal); } + DevicesModel { + id: connectDeviceModel + displayFilter: DevicesModel.StatusPaired | DevicesModel.StatusReachable + + } + + Binding { + target: plasmoid + property: "status" + value: (connectDeviceModel.count > 0) ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus + } + Plasmoid.compactRepresentation: CompactRepresentation {} - Plasmoid.fullRepresentation: FullRepresentation {} + Plasmoid.fullRepresentation: FullRepresentation { + devicesModel: connectDeviceModel + } Plasmoid.preferredRepresentation: isConstrained() ? Plasmoid.compactRepresentation : Plasmoid.fullRepresentation