From e0873304d16a6fb5492b290b8512d51f5773b9fb Mon Sep 17 00:00:00 2001 From: zach Date: Thu, 2 Jul 2026 21:53:42 +0200 Subject: [PATCH] add sorting by strength --- Helpers/Network.qml | 43 ++++++++++++----------- Modules/SysTray/Popouts/NetworkPopout.qml | 8 +++-- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Helpers/Network.qml b/Helpers/Network.qml index 7b3a0bc..593c34d 100644 --- a/Helpers/Network.qml +++ b/Helpers/Network.qml @@ -7,28 +7,25 @@ import QtQuick Singleton { id: root - readonly property list devices: Networking.devices.values - readonly property list networks: { - const list = [] - for (const d of wifiDevices) - list.push(...d.networks.values) - return list; - } - property bool scanning: false - readonly property list wifiDevices: devices.filter(d => wifiDevice(d)) - readonly property bool wifiEnabled: Networking.wifiEnabled property bool active: false - - onActiveChanged: { - for (const d of wifiDevices) - d.scannerEnabled = active; - } + readonly property list devices: Networking.devices.values + readonly property list knownNetworks: networks.filter(n => n.known) // Original code readonly property list netDevice: Networking.devices.values readonly property string networkName: getNetworkName() + readonly property list networks: { + const list = []; + for (const d of wifiDevices) + list.push(...d.networks.values); + return list; + } readonly property list nicNames: networkInterfaceCardNames() + property bool scanning: false + readonly property list unknownNetworks: networks.filter(n => !n.known) + readonly property list wifiDevices: devices.filter(d => wifiDevice(d)) + readonly property bool wifiEnabled: Networking.wifiEnabled // Useless will prob remove function getConnectedDevices() { @@ -52,6 +49,12 @@ Singleton { return "Failed network name"; } + // + + function isSecure(security): bool { + return (security === WifiSecurityType.WpaPsk || security === WifiSecurityType.Wpa2Psk || security === WifiSecurityType.Sae); + } + // Searches wired/wireless devices and sets them in a list function networkInterfaceCardNames() { let nicList = []; @@ -62,11 +65,6 @@ Singleton { return nicList; } - // - - function isSecure(security): bool { - return (security === WifiSecurityType.WpaPsk || security === WifiSecurityType.Wpa2Psk || security === WifiSecurityType.Sae); - } function setScan(value: bool): void { for (const d of wifiDevices) { @@ -81,4 +79,9 @@ Singleton { function wifiDevice(dev): bool { return dev.type === DeviceType.Wifi; } + + onActiveChanged: { + for (const d of wifiDevices) + d.scannerEnabled = active; + } } diff --git a/Modules/SysTray/Popouts/NetworkPopout.qml b/Modules/SysTray/Popouts/NetworkPopout.qml index 12c63ef..853ced4 100644 --- a/Modules/SysTray/Popouts/NetworkPopout.qml +++ b/Modules/SysTray/Popouts/NetworkPopout.qml @@ -68,7 +68,9 @@ CustomClippingRect { Repeater { model: ScriptModel { - values: [...Network.networks].filter(n => n.known) + values: [...Network.knownNetworks].sort((a, b) => { + return a.signalStrength - b.signalStrength; + }) } RowLayout { @@ -159,7 +161,9 @@ CustomClippingRect { id: networkRepeater model: ScriptModel { - values: [...Network.networks].filter(n => !n.known) + values: [...Network.unknownNetworks].sort((a, b) => { + return a.signalStrength - b.signalStrength; + }) } RowLayout {