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
This commit is contained in:
Aleix Pol 2015-03-13 00:56:25 +01:00
parent ce2bb1e433
commit 5d8cf9544c
2 changed files with 16 additions and 18 deletions

View file

@ -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();
}
}
}

View file

@ -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