Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions quickshell/Modules/Settings/NetworkTab.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1697,8 +1697,11 @@ Item {
required property int index

readonly property bool isActive: DMSNetworkService.isActiveUuid(modelData.uuid)
readonly property bool isTransient: !!modelData.transient
readonly property bool canExpand: modelData.canExpand !== false
readonly property bool canDelete: modelData.canDelete !== false
readonly property bool isExpanded: networkTab.expandedVpnUuid === modelData.uuid
readonly property var configData: isExpanded ? VPNService.editConfig : null
readonly property var configData: (!isTransient && isExpanded) ? VPNService.editConfig : null

width: parent.width
height: isExpanded ? 56 + vpnExpandedContent.height : 56
Expand Down Expand Up @@ -1745,7 +1748,7 @@ Item {
Column {
spacing: 2
anchors.verticalCenter: parent.verticalCenter
width: parent.width - 20 - 28 - 28 - Theme.spacingS * 4
width: parent.width - 20 - ((canExpand ? 28 : 0) + (canDelete ? 28 : 0)) - Theme.spacingS * 4

StyledText {
text: modelData.name
Expand Down Expand Up @@ -1775,6 +1778,7 @@ Item {
radius: 14
color: vpnExpandBtn.containsMouse ? Theme.surfacePressed : "transparent"
anchors.verticalCenter: parent.verticalCenter
visible: canExpand

DankIcon {
anchors.centerIn: parent
Expand Down Expand Up @@ -1805,6 +1809,7 @@ Item {
radius: 14
color: vpnDeleteBtn.containsMouse ? Theme.errorHover : "transparent"
anchors.verticalCenter: parent.verticalCenter
visible: canDelete

DankIcon {
anchors.centerIn: parent
Expand Down Expand Up @@ -1835,7 +1840,7 @@ Item {
id: vpnExpandedContent
width: parent.width
spacing: Theme.spacingXS
visible: isExpanded
visible: !isTransient && isExpanded

Rectangle {
width: parent.width
Expand Down
41 changes: 40 additions & 1 deletion quickshell/Services/DMSNetworkService.qml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,46 @@ Singleton {
property string pendingVpnUuid: ""
property var vpnBusyStartTime: 0

property alias profiles: root.vpnProfiles
property var profiles: {
const mergedProfiles = vpnProfiles ? vpnProfiles.slice() : [];
const seen = new Set();

for (const profile of mergedProfiles) {
if (profile?.uuid)
seen.add("uuid:" + profile.uuid);
if (profile?.name)
seen.add("name:" + profile.name);
}

for (const active of vpnActive || []) {
const entryUuid = active?.uuid || active?.name || "";
const uuidKey = active?.uuid ? "uuid:" + active.uuid : "";
const nameKey = active?.name ? "name:" + active.name : "";

if ((uuidKey && seen.has(uuidKey)) || (!uuidKey && nameKey && seen.has(nameKey)))
continue;

mergedProfiles.unshift({
uuid: entryUuid,
name: active?.name || I18n.tr("Active VPN"),
serviceType: active?.serviceType || "",
type: active?.type || "",
typeLabel: active?.typeLabel || active?.vpnType || "",
state: active?.state || "",
device: active?.device || "",
transient: true,
canDelete: false,
canExpand: false
});

if (uuidKey)
seen.add(uuidKey);
if (nameKey)
seen.add(nameKey);
}

return mergedProfiles;
}
property alias activeConnections: root.vpnActive
property var activeUuids: vpnActive.map(v => v.uuid).filter(u => !!u)
property var activeNames: vpnActive.map(v => v.name).filter(n => !!n)
Expand Down
2 changes: 2 additions & 0 deletions quickshell/Services/VPNService.qml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ Singleton {
function getVpnTypeFromProfile(profile) {
if (!profile)
return "VPN";
if (profile.typeLabel)
return profile.typeLabel;
if (profile.type === "wireguard")
return "WireGuard";
return getPluginName(profile.serviceType);
Expand Down
11 changes: 8 additions & 3 deletions quickshell/Widgets/VpnProfileDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ Rectangle {

required property var profile
property bool isExpanded: false
readonly property bool isTransient: !!profile?.transient
readonly property bool canExpand: profile?.canExpand !== false
readonly property bool canDelete: profile?.canDelete !== false

signal toggleExpand
signal deleteRequested

readonly property bool isActive: DMSNetworkService.activeUuids?.includes(profile?.uuid) ?? false
readonly property bool isHovered: rowArea.containsMouse || expandBtn.containsMouse || deleteBtn.containsMouse
readonly property var configData: isExpanded ? VPNService.editConfig : null
readonly property var configData: (!isTransient && isExpanded) ? VPNService.editConfig : null
readonly property var configFields: buildConfigFields()

height: isExpanded ? 46 + expandedContent.height : 46
Expand Down Expand Up @@ -114,7 +117,7 @@ Rectangle {
Column {
spacing: 1
anchors.verticalCenter: parent.verticalCenter
width: parent.width - 20 - 28 - 28 - Theme.spacingS * 4
width: parent.width - 20 - ((canExpand ? 28 : 0) + (canDelete ? 28 : 0)) - Theme.spacingS * 4

StyledText {
text: profile?.name ?? ""
Expand Down Expand Up @@ -148,6 +151,7 @@ Rectangle {
radius: 14
color: expandBtn.containsMouse ? Theme.surfacePressed : "transparent"
anchors.verticalCenter: parent.verticalCenter
visible: canExpand

DankIcon {
anchors.centerIn: parent
Expand All @@ -171,6 +175,7 @@ Rectangle {
radius: 14
color: deleteBtn.containsMouse ? Theme.errorHover : "transparent"
anchors.verticalCenter: parent.verticalCenter
visible: canDelete

DankIcon {
anchors.centerIn: parent
Expand Down Expand Up @@ -227,7 +232,7 @@ Rectangle {
Flow {
width: parent.width
spacing: Theme.spacingXS
visible: !VPNService.configLoading && configData
visible: !isTransient && !VPNService.configLoading && configData

Repeater {
model: configFields
Expand Down
Loading