kcms/wifi: Fix toggle not updating the first time

Fixes https://invent.kde.org/plasma/plasma-mobile/-/issues/363
This commit is contained in:
Devin Lin 2024-06-27 22:53:29 -04:00
parent 8f9db42e8f
commit 1dfcda39d3

View file

@ -3,7 +3,7 @@
// SPDX-License-Identifier: LGPL-2.0-or-later // SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Controls as Controls import QtQuick.Controls as Controls
import org.kde.plasma.networkmanagement as PlasmaNM import org.kde.plasma.networkmanagement as PlasmaNM
@ -86,7 +86,7 @@ SimpleKCM {
id: wifiSwitch id: wifiSwitch
text: i18n("Wi-Fi") text: i18n("Wi-Fi")
checked: enabledConnections.wirelessEnabled checked: enabledConnections.wirelessEnabled
onClicked: { onCheckedChanged: {
handler.enableWireless(checked); handler.enableWireless(checked);
checked = Qt.binding(() => enabledConnections.wirelessEnabled); checked = Qt.binding(() => enabledConnections.wirelessEnabled);
} }
@ -119,11 +119,11 @@ SimpleKCM {
model: mobileProxyModel model: mobileProxyModel
delegate: ConnectionItemDelegate { delegate: ConnectionItemDelegate {
editMode: root.editMode editMode: root.editMode
// connected or saved // connected or saved
property bool shouldDisplay: (Uuid != "") || ConnectionState === PlasmaNM.Enums.Activated property bool shouldDisplay: (Uuid != "") || ConnectionState === PlasmaNM.Enums.Activated
onShouldDisplayChanged: savedCard.updateCount() onShouldDisplayChanged: savedCard.updateCount()
// separate property for visible since visible is false when the whole card is not visible // separate property for visible since visible is false when the whole card is not visible
visible: shouldDisplay visible: shouldDisplay
} }
@ -159,7 +159,7 @@ SimpleKCM {
property bool shouldDisplay: !((Uuid != "") || ConnectionState === PlasmaNM.Enums.Activated) property bool shouldDisplay: !((Uuid != "") || ConnectionState === PlasmaNM.Enums.Activated)
onShouldDisplayChanged: availableCard.updateCount() onShouldDisplayChanged: availableCard.updateCount()
visible: shouldDisplay visible: shouldDisplay
} }
} }