From 6b067b4a978ebb50f9056c683513084d2ba18148 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Wed, 27 Dec 2023 18:19:04 -0500 Subject: [PATCH] kcms/wifi: Don't show available card if there are no connections --- kcms/wifi/ui/ConnectionItemDelegate.qml | 2 +- kcms/wifi/ui/main.qml | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/kcms/wifi/ui/ConnectionItemDelegate.qml b/kcms/wifi/ui/ConnectionItemDelegate.qml index 91bfe94e..1d4878f8 100644 --- a/kcms/wifi/ui/ConnectionItemDelegate.qml +++ b/kcms/wifi/ui/ConnectionItemDelegate.qml @@ -13,7 +13,7 @@ import org.kde.ksvg as KSvg import org.kde.kirigamiaddons.formcard 1 as FormCard FormCard.AbstractFormDelegate { - id: delegate + id: root property bool editMode property var map : [] diff --git a/kcms/wifi/ui/main.qml b/kcms/wifi/ui/main.qml index 1401ec87..bd623fd3 100644 --- a/kcms/wifi/ui/main.qml +++ b/kcms/wifi/ui/main.qml @@ -124,7 +124,7 @@ SimpleKCM { onShouldDisplayChanged: savedCard.updateCount() // separate property for visible since visible is false when the whole card is not visible - visible: (Uuid != "") || ConnectionState === PlasmaNM.Enums.Activated + visible: shouldDisplay } } } @@ -135,13 +135,31 @@ SimpleKCM { } FormCard.FormCard { - visible: enabledConnections.wirelessEnabled + id: availableCard + visible: enabledConnections.wirelessEnabled && count > 0 + + // number of visible entries + property int count: 0 + function updateCount() { + count = 0; + for (let i = 0; i < availableRepeater.count; i++) { + let item = availableRepeater.itemAt(i); + if (item && item.shouldDisplay) { + count++; + } + } + } Repeater { + id: availableRepeater model: mobileProxyModel delegate: ConnectionItemDelegate { editMode: root.editMode - visible: !((Uuid != "") || ConnectionState === PlasmaNM.Enums.Activated) + + property bool shouldDisplay: !((Uuid != "") || ConnectionState === PlasmaNM.Enums.Activated) + onShouldDisplayChanged: availableCard.updateCount() + + visible: shouldDisplay } }