diff options
| author | ATMDA <atdma2600@gmail.com> | 2025-11-14 17:42:49 -0500 |
|---|---|---|
| committer | ATMDA <atdma2600@gmail.com> | 2025-11-14 17:42:49 -0500 |
| commit | 45ef91998e4586dbf16c6ea3db0a9f4e19f4487e (patch) | |
| tree | 4268a84251bb975731a840c0c9ef2b9136c43625 /modules/bar/popouts/Network.qml | |
| parent | controlcenter: minor tidying (capitalization and filename) (diff) | |
| download | caelestia-shell-45ef91998e4586dbf16c6ea3db0a9f4e19f4487e.tar.gz caelestia-shell-45ef91998e4586dbf16c6ea3db0a9f4e19f4487e.tar.bz2 caelestia-shell-45ef91998e4586dbf16c6ea3db0a9f4e19f4487e.zip | |
tray: wireless password input popout
Diffstat (limited to 'modules/bar/popouts/Network.qml')
| -rw-r--r-- | modules/bar/popouts/Network.qml | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/modules/bar/popouts/Network.qml b/modules/bar/popouts/Network.qml index b807ce4..93ff867 100644 --- a/modules/bar/popouts/Network.qml +++ b/modules/bar/popouts/Network.qml @@ -12,8 +12,12 @@ import QtQuick.Layouts ColumnLayout { id: root + required property Item wrapper + property string connectingToSsid: "" property string view: "wireless" // "wireless" or "ethernet" + property var passwordNetwork: null + property bool showPasswordDialog: false spacing: Appearance.spacing.small width: Config.bar.sizes.networkWidth @@ -129,7 +133,27 @@ ColumnLayout { Nmcli.disconnectFromNetwork(); } else { root.connectingToSsid = networkItem.modelData.ssid; - Nmcli.connectToNetwork(networkItem.modelData.ssid, "", networkItem.modelData.bssid, null); + // Check if network is secure + if (networkItem.modelData.isSecure) { + // Try to connect first - will show password dialog if password is needed + Nmcli.connectToNetwork(networkItem.modelData.ssid, "", networkItem.modelData.bssid, (result) => { + if (result && result.needsPassword) { + // Password is required - show password dialog + root.passwordNetwork = networkItem.modelData; + root.showPasswordDialog = true; + root.wrapper.currentName = "wirelesspassword"; + } else if (result && result.success) { + // Connection successful with saved password + root.connectingToSsid = ""; + } else { + // Connection failed for other reasons + root.connectingToSsid = ""; + } + }); + } else { + // Open network, no password needed + Nmcli.connectToNetwork(networkItem.modelData.ssid, "", networkItem.modelData.bssid, null); + } } } } @@ -329,6 +353,15 @@ ColumnLayout { function onActiveChanged(): void { if (Nmcli.active && root.connectingToSsid === Nmcli.active.ssid) { root.connectingToSsid = ""; + // Close password dialog if we successfully connected + if (root.showPasswordDialog && root.passwordNetwork && + Nmcli.active.ssid === root.passwordNetwork.ssid) { + root.showPasswordDialog = false; + root.passwordNetwork = null; + if (root.wrapper.currentName === "wirelesspassword") { + root.wrapper.currentName = "network"; + } + } } } @@ -338,6 +371,17 @@ ColumnLayout { } } + Connections { + target: root.wrapper + function onCurrentNameChanged(): void { + // Clear password network when leaving password dialog + if (root.wrapper.currentName !== "wirelesspassword" && root.showPasswordDialog) { + root.showPasswordDialog = false; + root.passwordNetwork = null; + } + } + } + component Toggle: RowLayout { required property string label property alias checked: toggle.checked |