From 9d7f0c48cebec02aaf2ca780b89a763ce91f8624 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 28 Jan 2026 19:21:44 +1100 Subject: internal: format --- utils/NetworkConnection.qml | 56 ++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 31 deletions(-) (limited to 'utils') diff --git a/utils/NetworkConnection.qml b/utils/NetworkConnection.qml index c7595b1..e55b87b 100644 --- a/utils/NetworkConnection.qml +++ b/utils/NetworkConnection.qml @@ -5,18 +5,18 @@ import QtQuick /** * NetworkConnection - * + * * Centralized utility for network connection logic. Provides a single source of truth * for connecting to wireless networks, eliminating code duplication across * controlcenter components and bar popouts. - * + * * Usage: * ```qml * import qs.utils - * + * * // With Session object (controlcenter) * NetworkConnection.handleConnect(network, session); - * + * * // Without Session object (bar popouts) - provide password dialog callback * NetworkConnection.handleConnect(network, null, (network) => { * // Show password dialog @@ -32,7 +32,7 @@ QtObject { * Handle network connection with automatic disconnection if needed. * If there's an active network different from the target, disconnects first, * then connects to the target network. - * + * * @param network The network object to connect to (must have ssid property) * @param session Optional Session object (for controlcenter - must have network property with showPasswordDialog and pendingNetwork) * @param onPasswordNeeded Optional callback function(network) called when password is needed (for bar popouts) @@ -56,7 +56,7 @@ QtObject { * Connect to a wireless network. * Handles both secured and open networks, checks for saved profiles, * and shows password dialog if needed. - * + * * @param network The network object to connect to (must have ssid, isSecure, bssid properties) * @param session Optional Session object (for controlcenter - must have network property with showPasswordDialog and pendingNetwork) * @param onPasswordNeeded Optional callback function(network) called when password is needed (for bar popouts) @@ -73,30 +73,25 @@ QtObject { Nmcli.connectToNetwork(network.ssid, "", network.bssid, null); } else { // Use password check with callback - Nmcli.connectToNetworkWithPasswordCheck( - network.ssid, - network.isSecure, - (result) => { - if (result.needsPassword) { - // Clear pending connection if exists - if (Nmcli.pendingConnection) { - Nmcli.connectionCheckTimer.stop(); - Nmcli.immediateCheckTimer.stop(); - Nmcli.immediateCheckTimer.checkCount = 0; - Nmcli.pendingConnection = null; - } - - // Handle password dialog - use session if available, otherwise use callback - if (session && session.network) { - session.network.showPasswordDialog = true; - session.network.pendingNetwork = network; - } else if (onPasswordNeeded) { - onPasswordNeeded(network); - } + Nmcli.connectToNetworkWithPasswordCheck(network.ssid, network.isSecure, result => { + if (result.needsPassword) { + // Clear pending connection if exists + if (Nmcli.pendingConnection) { + Nmcli.connectionCheckTimer.stop(); + Nmcli.immediateCheckTimer.stop(); + Nmcli.immediateCheckTimer.checkCount = 0; + Nmcli.pendingConnection = null; } - }, - network.bssid - ); + + // Handle password dialog - use session if available, otherwise use callback + if (session && session.network) { + session.network.showPasswordDialog = true; + session.network.pendingNetwork = network; + } else if (onPasswordNeeded) { + onPasswordNeeded(network); + } + } + }, network.bssid); } } else { Nmcli.connectToNetwork(network.ssid, "", network.bssid, null); @@ -106,7 +101,7 @@ QtObject { /** * Connect to a wireless network with a provided password. * Used by password dialogs when the user has already entered a password. - * + * * @param network The network object to connect to (must have ssid, bssid properties) * @param password The password to use for connection * @param onResult Optional callback function(result) called with connection result @@ -119,4 +114,3 @@ QtObject { Nmcli.connectToNetwork(network.ssid, password || "", network.bssid || "", onResult || null); } } - -- cgit v1.2.3-freya