From e872ddc1e731ff603d994ff7283a849f23fea938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Augusto=20C=C3=A9sar=20Dias?= Date: Fri, 6 Mar 2026 20:19:31 +0100 Subject: [PATCH] feature(vpn): add toggle to enable/disable auto connecting (#1925) * feature(vpn): add toggle to enable/disable auto connecting * refresh status after updating --- quickshell/Modules/Settings/NetworkTab.qml | 15 ++++++++++----- quickshell/Services/VPNService.qml | 1 + quickshell/Widgets/VpnProfileDelegate.qml | 15 ++++++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/quickshell/Modules/Settings/NetworkTab.qml b/quickshell/Modules/Settings/NetworkTab.qml index 87ed9705..b9b25661 100644 --- a/quickshell/Modules/Settings/NetworkTab.qml +++ b/quickshell/Modules/Settings/NetworkTab.qml @@ -1935,11 +1935,6 @@ Item { label: I18n.tr("Auth Type"), value: data["connection-type"] }); - fields.push({ - label: I18n.tr("Autoconnect"), - value: configData.autoconnect ? I18n.tr("Yes") : I18n.tr("No") - }); - return fields; } @@ -1978,6 +1973,16 @@ Item { } } + DankToggle { + width: parent.width + text: I18n.tr("Autoconnect") + checked: configData ? (configData.autoconnect || false) : false + visible: !VPNService.configLoading && configData !== null + onToggled: checked => { + VPNService.updateConfig(modelData.uuid, {autoconnect: checked}); + } + } + Item { width: 1 height: Theme.spacingXS diff --git a/quickshell/Services/VPNService.qml b/quickshell/Services/VPNService.qml index e32a64a2..effc54ea 100644 --- a/quickshell/Services/VPNService.qml +++ b/quickshell/Services/VPNService.qml @@ -142,6 +142,7 @@ Singleton { } ToastService.showInfo(I18n.tr("VPN configuration updated")); DMSNetworkService.refreshVpnProfiles(); + getConfig(uuid); configUpdated(); }); } diff --git a/quickshell/Widgets/VpnProfileDelegate.qml b/quickshell/Widgets/VpnProfileDelegate.qml index 0f40e015..060c07f1 100644 --- a/quickshell/Widgets/VpnProfileDelegate.qml +++ b/quickshell/Widgets/VpnProfileDelegate.qml @@ -75,11 +75,6 @@ Rectangle { "label": I18n.tr("Auth Type"), "value": data["connection-type"] }); - fields.push({ - "key": "auto", - "label": I18n.tr("Autoconnect"), - "value": configData.autoconnect ? I18n.tr("Yes") : I18n.tr("No") - }); return fields; } @@ -271,6 +266,16 @@ Rectangle { } } + DankToggle { + width: parent.width + text: I18n.tr("Autoconnect") + checked: configData ? (configData.autoconnect || false) : false + visible: !VPNService.configLoading && configData !== null + onToggled: checked => { + VPNService.updateConfig(profile.uuid, {autoconnect: checked}); + } + } + Item { width: 1 height: Theme.spacingXS