Compare commits
10 Commits
features/m
...
a0b9ea29fe
| Author | SHA1 | Date | |
|---|---|---|---|
| a0b9ea29fe | |||
| 007843db6e | |||
| 764652d826 | |||
| 8dedfe30fa | |||
| bc54a4b5b7 | |||
| d306270dc8 | |||
| 03b043d9d3 | |||
| 1ff92f3b79 | |||
| c64cf5ff12 | |||
| 9e532023bd |
@@ -14,6 +14,9 @@ hl.on("hyprland.start", function()
|
|||||||
hl.exec_cmd("dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP")
|
hl.exec_cmd("dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP")
|
||||||
hl.exec_cmd("systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP")
|
hl.exec_cmd("systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP")
|
||||||
|
|
||||||
|
-- Sunshine
|
||||||
|
hl.exec_cmd("sleep 1 && hyprctl output create headless")
|
||||||
|
|
||||||
-- Polkit (Polkit Gnome / KDE)
|
-- Polkit (Polkit Gnome / KDE)
|
||||||
hl.exec_cmd(scriptsDir .. "/Polkit.sh")
|
hl.exec_cmd(scriptsDir .. "/Polkit.sh")
|
||||||
|
|
||||||
@@ -23,7 +26,7 @@ hl.on("hyprland.start", function()
|
|||||||
-- hl.exec_cmd("ags")
|
-- hl.exec_cmd("ags")
|
||||||
-- hl.exec_cmd("blueman-applet")
|
-- hl.exec_cmd("blueman-applet")
|
||||||
-- hl.exec_cmd("rog-control-center")
|
-- hl.exec_cmd("rog-control-center")
|
||||||
hl.exec_cmd("waybar")
|
-- hl.exec_cmd("waybar")
|
||||||
hl.exec_cmd("qs") -- quickshell AGS Desktop Overview alternative
|
hl.exec_cmd("qs") -- quickshell AGS Desktop Overview alternative
|
||||||
|
|
||||||
-- clipboard manager
|
-- clipboard manager
|
||||||
@@ -31,7 +34,10 @@ hl.on("hyprland.start", function()
|
|||||||
hl.exec_cmd("wl-paste --type image --watch cliphist store")
|
hl.exec_cmd("wl-paste --type image --watch cliphist store")
|
||||||
|
|
||||||
-- Starting hypridle to start hyprlock
|
-- Starting hypridle to start hyprlock
|
||||||
hl.exec_cmd("hypridle")
|
-- hl.exec_cmd("hypridle")
|
||||||
|
|
||||||
|
-- Sunshine for streaming media
|
||||||
|
h1.exec_cmd("sunshine")
|
||||||
|
|
||||||
-- Float + center the Bitwarden extension pop-out (window rules can't catch it — see the script)
|
-- Float + center the Bitwarden extension pop-out (window rules can't catch it — see the script)
|
||||||
hl.exec_cmd(scriptsDir .. "/FloatBitwardenPopup.sh")
|
hl.exec_cmd(scriptsDir .. "/FloatBitwardenPopup.sh")
|
||||||
|
|||||||
@@ -11,4 +11,5 @@
|
|||||||
hl.monitor({ output = "desc:LG Electronics LG ULTRAWIDE 0x0002E68A", mode = "2560x1080@60.00000", position = "1920x-740", scale = 1.00000000, transform = 3, vrr = 0 })
|
hl.monitor({ output = "desc:LG Electronics LG ULTRAWIDE 0x0002E68A", mode = "2560x1080@60.00000", position = "1920x-740", scale = 1.00000000, transform = 3, vrr = 0 })
|
||||||
hl.monitor({ output = "desc:HP Inc. HP 524pf VNG447017D", mode = "1920x1080@100.00000", position = "-1920x0", scale = 1.00000000, transform = 0, vrr = 0 })
|
hl.monitor({ output = "desc:HP Inc. HP 524pf VNG447017D", mode = "1920x1080@100.00000", position = "-1920x0", scale = 1.00000000, transform = 0, vrr = 0 })
|
||||||
hl.monitor({ output = "desc:Acer Technologies VG240Y S 0x126191DE", mode = "1920x1080@165.00301", position = "0x0", scale = 1.00000000, transform = 0, vrr = 1, bitdepth = 10, cm = "wide" })
|
hl.monitor({ output = "desc:Acer Technologies VG240Y S 0x126191DE", mode = "1920x1080@165.00301", position = "0x0", scale = 1.00000000, transform = 0, vrr = 1, bitdepth = 10, cm = "wide" })
|
||||||
|
hl.monitor({ output = "HEADLESS-1", mode = "1728x1080@60.00000", position = "4480x0", scale = 1.00000000, transform = 0, vrr = 0 })
|
||||||
-- <<<<< TUI AUTO END
|
-- <<<<< TUI AUTO END
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
hl.workspace_rule({ workspace = 1, monitor = "DP-2", default = true })
|
hl.workspace_rule({ workspace = 1, monitor = "DP-2", default = true })
|
||||||
hl.workspace_rule({ workspace = 2, monitor = "DP-1", default = true })
|
hl.workspace_rule({ workspace = 2, monitor = "DP-1", default = true })
|
||||||
hl.workspace_rule({ workspace = 3, monitor = "HDMI-A-1", default = true })
|
hl.workspace_rule({ workspace = 3, monitor = "HDMI-A-1", default = true })
|
||||||
|
hl.workspace_rule({ workspace = 9, monitor = "HEADLESS-1", default = true })
|
||||||
-- hl.workspace_rule({ workspace = 4, monitor = "eDP-1" })
|
-- hl.workspace_rule({ workspace = 4, monitor = "eDP-1" })
|
||||||
-- hl.workspace_rule({ workspace = 5, monitor = "DP-2" })
|
-- hl.workspace_rule({ workspace = 5, monitor = "DP-2" })
|
||||||
-- hl.workspace_rule({ workspace = 6, monitor = "DP-2" })
|
-- hl.workspace_rule({ workspace = 6, monitor = "DP-2" })
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import QtQuick
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
|
import Quickshell.Io
|
||||||
import Quickshell.Services.UPower
|
import Quickshell.Services.UPower
|
||||||
import "../../config"
|
import "../../config"
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ import "../../config"
|
|||||||
// Nerd Font ones. The charge-threshold ("Holding"/limited-charge) concept from
|
// Nerd Font ones. The charge-threshold ("Holding"/limited-charge) concept from
|
||||||
// the original is hardware-specific (vendor charge-limit sysfs knobs) and has
|
// the original is hardware-specific (vendor charge-limit sysfs knobs) and has
|
||||||
// no equivalent in Quickshell's UPower binding, so it's dropped rather than
|
// no equivalent in Quickshell's UPower binding, so it's dropped rather than
|
||||||
// guessed at; "Battery health" (device.healthPercentage) is shown in its
|
// guessed at; "Battery health" (computed from sysfs energy_full/design) is shown in its
|
||||||
// place, using data UPower actually reports.
|
// place, using data UPower actually reports.
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
@@ -51,10 +52,162 @@ Item {
|
|||||||
readonly property real fraction: root.batteryPresent ? Math.max(0, Math.min(1, root.device.percentage)) : 0
|
readonly property real fraction: root.batteryPresent ? Math.max(0, Math.min(1, root.device.percentage)) : 0
|
||||||
readonly property bool low: root.batteryPresent && root.fraction <= 0.15 && !root.charging
|
readonly property bool low: root.batteryPresent && root.fraction <= 0.15 && !root.charging
|
||||||
|
|
||||||
|
// Quickshell's UPower binding has no charge-cycle property (see the
|
||||||
|
// file-header comment on why the old charge-until threshold was
|
||||||
|
// dropped) — it comes straight from sysfs instead.
|
||||||
|
//
|
||||||
|
// device.nativePath turned out to be empty on real hardware (tested
|
||||||
|
// live), so rather than build a path from it, a shell glob finds
|
||||||
|
// whichever BAT* directory actually exists — same shell-out-to-a-CLI
|
||||||
|
// convention TailscaleIndicator.qml uses for its own live stats.
|
||||||
|
// This barely changes during a session, so one read at startup is
|
||||||
|
// enough; no polling timer.
|
||||||
|
property int cycleCount: -1
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: cycleCountProc
|
||||||
|
command: ["sh", "-c", "cat \"$(ls -d /sys/class/power_supply/BAT* 2>/dev/null | head -n1)/cycle_count\" 2>/dev/null"]
|
||||||
|
running: root.batteryPresent
|
||||||
|
stdout: StdioCollector {
|
||||||
|
id: cycleCountCollector
|
||||||
|
onStreamFinished: {
|
||||||
|
const n = parseInt(cycleCountCollector.text.trim(), 10)
|
||||||
|
root.cycleCount = (isNaN(n) || n <= 0) ? -1 : n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// device.healthPercentage/healthSupported come from upowerd over D-Bus,
|
||||||
|
// and upowerd has been observed reporting energy-full as a flat 0 (a
|
||||||
|
// live daemon glitch, `upower -i` shows it too) while sysfs still has
|
||||||
|
// the real numbers underneath — same class of unreliability that put
|
||||||
|
// cycle_count on sysfs above instead of trusting upowerd's own
|
||||||
|
// charge-cycles field. Health is computed the same way UPower computes
|
||||||
|
// it (current full-charge capacity over the battery's original design
|
||||||
|
// capacity), just read directly so a daemon hiccup doesn't blank it.
|
||||||
|
property real energyFullWh: -1
|
||||||
|
property real energyFullDesignWh: -1
|
||||||
|
readonly property real healthPercent: (root.energyFullWh > 0 && root.energyFullDesignWh > 0)
|
||||||
|
? Math.min(100, (root.energyFullWh / root.energyFullDesignWh) * 100) : -1
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: energyFullProc
|
||||||
|
command: ["sh", "-c", "cat \"$(ls -d /sys/class/power_supply/BAT* 2>/dev/null | head -n1)/energy_full\" 2>/dev/null"]
|
||||||
|
running: root.batteryPresent
|
||||||
|
stdout: StdioCollector {
|
||||||
|
id: energyFullCollector
|
||||||
|
onStreamFinished: {
|
||||||
|
const n = parseFloat(energyFullCollector.text.trim())
|
||||||
|
root.energyFullWh = (isNaN(n) || n <= 0) ? -1 : (n / 1000000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: energyFullDesignProc
|
||||||
|
command: ["sh", "-c", "cat \"$(ls -d /sys/class/power_supply/BAT* 2>/dev/null | head -n1)/energy_full_design\" 2>/dev/null"]
|
||||||
|
running: root.batteryPresent
|
||||||
|
stdout: StdioCollector {
|
||||||
|
id: energyFullDesignCollector
|
||||||
|
onStreamFinished: {
|
||||||
|
const n = parseFloat(energyFullDesignCollector.text.trim())
|
||||||
|
root.energyFullDesignWh = (isNaN(n) || n <= 0) ? -1 : (n / 1000000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// device.timeToFull/timeToEmpty are computed by Quickshell from
|
||||||
|
// energy/energyCapacity/changeRate — when upowerd's EnergyFull glitches
|
||||||
|
// to 0 (the same daemon flake HEALTH routes around above), that formula
|
||||||
|
// divides by a bogus capacity and comes out negative rather than a
|
||||||
|
// real estimate (confirmed live: timeToFull sat at -3751 while `upower
|
||||||
|
// -i` itself still reported a normal 26.7 minutes). This recomputes
|
||||||
|
// the same estimate straight from sysfs as a fallback, only used when
|
||||||
|
// Quickshell's own value isn't positive. Unlike cycle_count/design
|
||||||
|
// capacity above, energy_now and power_now change continuously while
|
||||||
|
// (dis)charging, so this polls on a timer instead of reading once.
|
||||||
|
property real sysfsEnergyNowWh: -1
|
||||||
|
property real sysfsPowerNowW: -1
|
||||||
|
|
||||||
|
readonly property real fallbackTimeToFullSeconds: (root.sysfsPowerNowW > 0 && root.energyFullWh > 0 && root.sysfsEnergyNowWh >= 0)
|
||||||
|
? Math.max(0, (root.energyFullWh - root.sysfsEnergyNowWh) / root.sysfsPowerNowW * 3600) : -1
|
||||||
|
readonly property real fallbackTimeToEmptySeconds: (root.sysfsPowerNowW > 0 && root.sysfsEnergyNowWh > 0)
|
||||||
|
? (root.sysfsEnergyNowWh / root.sysfsPowerNowW * 3600) : -1
|
||||||
|
|
||||||
|
// Prefers upowerd's own live estimate when it's sane; only falls back
|
||||||
|
// to the sysfs-computed one when upowerd's has gone zero/negative.
|
||||||
|
readonly property real timeRemainingSeconds: {
|
||||||
|
const primary = root.onBattery ? root.device.timeToEmpty : root.device.timeToFull
|
||||||
|
if (primary > 0) return primary
|
||||||
|
return root.onBattery ? root.fallbackTimeToEmptySeconds : root.fallbackTimeToFullSeconds
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: sysfsRateTimer
|
||||||
|
interval: 15000
|
||||||
|
repeat: true
|
||||||
|
running: root.batteryPresent
|
||||||
|
triggeredOnStart: true
|
||||||
|
onTriggered: {
|
||||||
|
if (!sysfsEnergyNowProc.running) sysfsEnergyNowProc.running = true
|
||||||
|
if (!sysfsPowerNowProc.running) sysfsPowerNowProc.running = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: sysfsEnergyNowProc
|
||||||
|
command: ["sh", "-c", "cat \"$(ls -d /sys/class/power_supply/BAT* 2>/dev/null | head -n1)/energy_now\" 2>/dev/null"]
|
||||||
|
stdout: StdioCollector {
|
||||||
|
id: sysfsEnergyNowCollector
|
||||||
|
onStreamFinished: {
|
||||||
|
const n = parseFloat(sysfsEnergyNowCollector.text.trim())
|
||||||
|
root.sysfsEnergyNowWh = (isNaN(n) || n < 0) ? -1 : (n / 1000000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: sysfsPowerNowProc
|
||||||
|
command: ["sh", "-c", "cat \"$(ls -d /sys/class/power_supply/BAT* 2>/dev/null | head -n1)/power_now\" 2>/dev/null"]
|
||||||
|
stdout: StdioCollector {
|
||||||
|
id: sysfsPowerNowCollector
|
||||||
|
onStreamFinished: {
|
||||||
|
const n = parseFloat(sysfsPowerNowCollector.text.trim())
|
||||||
|
root.sysfsPowerNowW = (isNaN(n) || n <= 0) ? -1 : (n / 1000000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Raw UPower state string (Charging/Discharging/PendingCharge/…) — more
|
||||||
|
// granular than modeLabel below, which collapses those down to the
|
||||||
|
// three phrases the hero text and STATE row show.
|
||||||
|
readonly property string rawStateLabel: root.batteryPresent
|
||||||
|
? UPowerDeviceState.toString(root.deviceState) : "—"
|
||||||
|
|
||||||
|
// Material Symbols' charging glyphs aren't an evenly-spaced "_bar"
|
||||||
|
// scale like the non-charging ones below — they're fixed at these
|
||||||
|
// seven breakpoints (confirmed against the installed font's ligature
|
||||||
|
// table), so this picks the highest one at or below the current
|
||||||
|
// percentage rather than rounding to an index.
|
||||||
|
function chargingIcon(fraction) {
|
||||||
|
const percent = fraction * 100
|
||||||
|
const thresholds = [20, 30, 50, 60, 80, 90, 100]
|
||||||
|
const icons = [
|
||||||
|
"battery_charging_20", "battery_charging_30", "battery_charging_50", "battery_charging_60",
|
||||||
|
"battery_charging_80", "battery_charging_90", "battery_charging_full"
|
||||||
|
]
|
||||||
|
for (let i = thresholds.length - 1; i >= 0; i--) {
|
||||||
|
if (percent >= thresholds[i]) return icons[i]
|
||||||
|
}
|
||||||
|
// Below 20% there's no lower charging glyph — it's still the
|
||||||
|
// truthful floor of what's available while current is flowing in.
|
||||||
|
return icons[0]
|
||||||
|
}
|
||||||
|
|
||||||
function batteryIcon() {
|
function batteryIcon() {
|
||||||
if (!root.batteryPresent) return "battery_unknown"
|
if (!root.batteryPresent) return "battery_unknown"
|
||||||
if (root.fullyCharged) return "battery_full"
|
if (root.fullyCharged) return "battery_full"
|
||||||
if (root.charging) return "battery_charging_full"
|
if (root.charging) return root.chargingIcon(root.fraction)
|
||||||
if (root.fraction <= 0.1) return "battery_alert"
|
if (root.fraction <= 0.1) return "battery_alert"
|
||||||
const bars = ["battery_0_bar", "battery_1_bar", "battery_2_bar", "battery_3_bar", "battery_4_bar", "battery_5_bar", "battery_full"]
|
const bars = ["battery_0_bar", "battery_1_bar", "battery_2_bar", "battery_3_bar", "battery_4_bar", "battery_5_bar", "battery_full"]
|
||||||
return bars[Math.max(0, Math.min(bars.length - 1, Math.round(root.fraction * (bars.length - 1))))]
|
return bars[Math.max(0, Math.min(bars.length - 1, Math.round(root.fraction * (bars.length - 1))))]
|
||||||
@@ -74,6 +227,32 @@ Item {
|
|||||||
return root.onBattery ? "On battery" : "Charging"
|
return root.onBattery ? "On battery" : "Charging"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Info grid rows — same shape as NetworkIndicator.qml's statRows/
|
||||||
|
// statCells: a flat label/value list, flattened again into individual
|
||||||
|
// grid cells (label, value, label, value, …) so a 4-column GridLayout
|
||||||
|
// lays them out as two label/value pairs per row.
|
||||||
|
readonly property var statRows: [
|
||||||
|
{
|
||||||
|
label: "HEALTH",
|
||||||
|
value: root.healthPercent > 0 ? Math.round(root.healthPercent) + "%" : "—"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: root.onBattery ? "TIME LEFT" : "TIME TO FULL",
|
||||||
|
value: root.batteryPresent ? root.formatDuration(root.timeRemainingSeconds) : "—"
|
||||||
|
},
|
||||||
|
{ label: "STATUS", value: root.rawStateLabel },
|
||||||
|
{ label: "CYCLES", value: root.cycleCount > 0 ? String(root.cycleCount) : "—" }
|
||||||
|
]
|
||||||
|
|
||||||
|
readonly property var statCells: {
|
||||||
|
const cells = []
|
||||||
|
for (let i = 0; i < root.statRows.length; i++) {
|
||||||
|
cells.push({ text: root.statRows[i].label, isLabel: true })
|
||||||
|
cells.push({ text: root.statRows[i].value, isLabel: false })
|
||||||
|
}
|
||||||
|
return cells
|
||||||
|
}
|
||||||
|
|
||||||
// Cute rotating status phrases while current is actually flowing —
|
// Cute rotating status phrases while current is actually flowing —
|
||||||
// ported as-is from omarchy's power panel, which pairs the same phrase
|
// ported as-is from omarchy's power panel, which pairs the same phrase
|
||||||
// sets with the same charging/on-battery states.
|
// sets with the same charging/on-battery states.
|
||||||
@@ -142,6 +321,34 @@ Item {
|
|||||||
return entries
|
return entries
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Automatic power profile --------------------------------------
|
||||||
|
// Battery-state-driven, on top of the manual picker above: below 20%
|
||||||
|
// → Power Saver (protect what's left), plugged in → Performance,
|
||||||
|
// unplugged and healthy → Balanced. Low battery wins even if a weak
|
||||||
|
// charger is still plugged in — running low is the more urgent signal.
|
||||||
|
// Performance only gets requested when the daemon actually reports it
|
||||||
|
// as available, falling back to Balanced instead of erroring on
|
||||||
|
// hardware without a performance profile (e.g. the ERROR this exact
|
||||||
|
// widget hit before power-profiles-daemon was installed).
|
||||||
|
//
|
||||||
|
// This only ever writes when the *target* changes (crossing the 20%
|
||||||
|
// line, plugging/unplugging) rather than on every poll, so a manual
|
||||||
|
// pick from the buttons above still sticks until the next real
|
||||||
|
// transition instead of being fought immediately.
|
||||||
|
readonly property int desiredProfile: {
|
||||||
|
if (root.fraction <= 0.20) return PowerProfile.PowerSaver
|
||||||
|
if (!root.onBattery) return PowerProfiles.hasPerformanceProfile ? PowerProfile.Performance : PowerProfile.Balanced
|
||||||
|
return PowerProfile.Balanced
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyDesiredProfile() {
|
||||||
|
if (!root.batteryPresent) return
|
||||||
|
if (PowerProfiles.profile !== root.desiredProfile) PowerProfiles.profile = root.desiredProfile
|
||||||
|
}
|
||||||
|
|
||||||
|
onDesiredProfileChanged: root.applyDesiredProfile()
|
||||||
|
Component.onCompleted: Qt.callLater(root.applyDesiredProfile)
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: label
|
id: label
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
@@ -217,33 +424,16 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
component StatRow: RowLayout {
|
|
||||||
id: statRow
|
|
||||||
width: parent.width
|
|
||||||
property string label: ""
|
|
||||||
property string value: ""
|
|
||||||
Text {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: statRow.label
|
|
||||||
font.family: Appearance.fontFamily
|
|
||||||
font.pixelSize: Appearance.fontSizeSmall
|
|
||||||
color: Colors.muted
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
text: statRow.value
|
|
||||||
font.family: Appearance.fontFamily
|
|
||||||
font.pixelSize: Appearance.fontSizeSmall
|
|
||||||
color: Colors.muted
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Panel -----------------------------------------------------------
|
// --- Panel -----------------------------------------------------------
|
||||||
|
|
||||||
PopupWindow {
|
PopupWindow {
|
||||||
id: panel
|
id: panel
|
||||||
visible: false
|
visible: false
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
readonly property int contentWidth: 244
|
// Wider than before (244) to give the 2-column info grid's
|
||||||
|
// label/value pairs enough room per half without eliding —
|
||||||
|
// same reasoning as NetworkIndicator.qml's own wider panel.
|
||||||
|
readonly property int contentWidth: 280
|
||||||
readonly property int contentPadding: 16
|
readonly property int contentPadding: 16
|
||||||
implicitWidth: contentWidth + contentPadding * 2
|
implicitWidth: contentWidth + contentPadding * 2
|
||||||
implicitHeight: mainColumn.implicitHeight + contentPadding * 2
|
implicitHeight: mainColumn.implicitHeight + contentPadding * 2
|
||||||
@@ -350,34 +540,27 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stats
|
// Stats — a 2-column, 2-row info grid, same layout
|
||||||
RowLayout {
|
// NetworkIndicator.qml uses for its own live stats: a
|
||||||
|
// 4-column GridLayout fed a flattened label/value/label/value
|
||||||
|
// list, so each row holds two label/value pairs side by side
|
||||||
|
// with the values right-aligned against their own half.
|
||||||
|
GridLayout {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: 16
|
columns: 4
|
||||||
|
columnSpacing: 12
|
||||||
|
rowSpacing: 5
|
||||||
|
|
||||||
Column {
|
Repeater {
|
||||||
Layout.fillWidth: true
|
model: root.statCells
|
||||||
spacing: 4
|
Text {
|
||||||
StatRow { label: "STATE"; value: root.modeLabel }
|
required property var modelData
|
||||||
StatRow {
|
Layout.fillWidth: !modelData.isLabel
|
||||||
label: "HEALTH"
|
horizontalAlignment: modelData.isLabel ? Text.AlignLeft : Text.AlignRight
|
||||||
value: (root.batteryPresent && root.device.healthSupported)
|
text: modelData.text
|
||||||
? Math.round(root.device.healthPercentage) + "%" : "—"
|
font.family: Appearance.fontFamily
|
||||||
}
|
font.pixelSize: Appearance.fontSizeSmall
|
||||||
}
|
color: modelData.isLabel ? Colors.muted : Colors.foreground
|
||||||
|
|
||||||
Column {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
spacing: 4
|
|
||||||
StatRow {
|
|
||||||
label: root.onBattery ? "TIME LEFT" : "TIME TO FULL"
|
|
||||||
value: root.batteryPresent
|
|
||||||
? root.formatDuration(root.onBattery ? root.device.timeToEmpty : root.device.timeToFull)
|
|
||||||
: "—"
|
|
||||||
}
|
|
||||||
StatRow {
|
|
||||||
label: "RATE"
|
|
||||||
value: root.batteryPresent ? Math.abs(root.device.changeRate).toFixed(1) + " W" : "—"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,9 +45,41 @@ Item {
|
|||||||
// to connect once the current one has finished disconnecting.
|
// to connect once the current one has finished disconnecting.
|
||||||
property string pendingConnect: ""
|
property string pendingConnect: ""
|
||||||
|
|
||||||
// Surfaced under the header for a failed connect/disconnect; cleared
|
// Surfaced under each provider's own row for a failed connect/
|
||||||
// automatically after a few seconds.
|
// disconnect/settings change; cleared automatically after a few
|
||||||
property string actionStatus: ""
|
// seconds. Kept separate per provider so an error from one doesn't
|
||||||
|
// show up hanging under the other's row.
|
||||||
|
property string mullvadActionStatus: ""
|
||||||
|
property string protonActionStatus: ""
|
||||||
|
|
||||||
|
// --- Mullvad advanced options (auto-connect, relay location, multihop) --
|
||||||
|
// ProtonVPN's CLI is plain-text-only and far less predictable across
|
||||||
|
// versions, so this extra panel is Mullvad-specific rather than a
|
||||||
|
// second ProviderRow feature.
|
||||||
|
|
||||||
|
property bool mullvadOptionsOpen: false
|
||||||
|
property bool mullvadAutoConnect: false
|
||||||
|
property bool mullvadMultihop: false
|
||||||
|
// Human-readable current relay constraint, e.g. "Any" or "Sweden" —
|
||||||
|
// resolved from `relay get`'s "country xx[ city yyy]" syntax against
|
||||||
|
// mullvadCountries once that list has loaded.
|
||||||
|
property string mullvadLocationLabel: "Any"
|
||||||
|
property string mullvadEntryLabel: "Any"
|
||||||
|
// [{name, code}], parsed from `mullvad relay list` and cached for the
|
||||||
|
// life of the panel — the full relay list rarely changes and re-parsing
|
||||||
|
// ~50 countries on every open would just be wasted work.
|
||||||
|
property var mullvadCountries: []
|
||||||
|
// "" | "exit" | "entry" — which location field's picker is open, if any.
|
||||||
|
property string mullvadPickerTarget: ""
|
||||||
|
property string mullvadPickerFilter: ""
|
||||||
|
|
||||||
|
readonly property var mullvadFilteredCountries: {
|
||||||
|
const f = root.mullvadPickerFilter.trim().toLowerCase()
|
||||||
|
if (!f) return root.mullvadCountries
|
||||||
|
return root.mullvadCountries.filter(function(c) {
|
||||||
|
return c.name.toLowerCase().indexOf(f) !== -1 || c.code.indexOf(f) !== -1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function shortLine(text) {
|
function shortLine(text) {
|
||||||
const line = String(text || "").trim().split("\n")[0] || ""
|
const line = String(text || "").trim().split("\n")[0] || ""
|
||||||
@@ -82,6 +114,95 @@ Item {
|
|||||||
VpnExclusivity.protonConnected = root.protonState === "connected"
|
VpnExclusivity.protonConnected = root.protonState === "connected"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyMullvadAutoConnect(text) {
|
||||||
|
const m = String(text || "").match(/autoconnect:\s*(on|off)/i)
|
||||||
|
root.mullvadAutoConnect = !!m && m[1].toLowerCase() === "on"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolves relay get's "any" / "country xx" / "country xx city yyy" /
|
||||||
|
// bare-hostname syntax into a display label. Falls back to the raw
|
||||||
|
// country code (or the raw string) when mullvadCountries hasn't loaded
|
||||||
|
// yet, rather than showing nothing.
|
||||||
|
function describeMullvadLocation(raw) {
|
||||||
|
const s = String(raw || "").trim()
|
||||||
|
if (!s || s === "any") return "Any"
|
||||||
|
const m = s.match(/^country\s+([a-z]{2})\b/i)
|
||||||
|
if (!m) return s
|
||||||
|
const code = m[1].toLowerCase()
|
||||||
|
const country = root.mullvadCountries.find(function(c) { return c.code === code })
|
||||||
|
return country ? country.name : code.toUpperCase()
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyMullvadRelay(text) {
|
||||||
|
const body = String(text || "")
|
||||||
|
const locMatch = body.match(/^\s*Location:\s*(.+)$/mi)
|
||||||
|
const multihopMatch = body.match(/^\s*Multihop state:\s*(\w+)/mi)
|
||||||
|
const entryMatch = body.match(/^\s*Multihop entry:\s*(.+)$/mi)
|
||||||
|
root.mullvadMultihop = !!multihopMatch && multihopMatch[1].toLowerCase() === "enabled"
|
||||||
|
root.mullvadLocationLabel = root.describeMullvadLocation(locMatch ? locMatch[1].trim() : "")
|
||||||
|
root.mullvadEntryLabel = root.describeMullvadLocation(entryMatch ? entryMatch[1].trim() : "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only country-level lines are of interest ("Sweden (se)", flush left) —
|
||||||
|
// city ("\tGothenburg (got) @ ...") and server lines are indented and
|
||||||
|
// their parenthesised code is never exactly two letters, so the regex
|
||||||
|
// alone is enough to tell them apart without checking indentation.
|
||||||
|
function applyMullvadCountries(text) {
|
||||||
|
const lines = String(text || "").split("\n")
|
||||||
|
const countries = []
|
||||||
|
for (const line of lines) {
|
||||||
|
const m = line.match(/^(\S.*) \(([a-z]{2})\)\s*$/)
|
||||||
|
if (m) countries.push({ name: m[1].trim(), code: m[2] })
|
||||||
|
}
|
||||||
|
countries.sort(function(a, b) { return a.name.localeCompare(b.name) })
|
||||||
|
root.mullvadCountries = countries
|
||||||
|
// Re-resolve any labels already showing raw codes now that names
|
||||||
|
// are available.
|
||||||
|
if (!mullvadRelayGetProc.running) mullvadRelayGetProc.running = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function openMullvadOptions() {
|
||||||
|
root.mullvadOptionsOpen = !root.mullvadOptionsOpen
|
||||||
|
if (root.mullvadOptionsOpen) {
|
||||||
|
if (!mullvadAutoConnectGetProc.running) mullvadAutoConnectGetProc.running = true
|
||||||
|
if (!mullvadRelayGetProc.running) mullvadRelayGetProc.running = true
|
||||||
|
if (root.mullvadCountries.length === 0 && !mullvadRelayListProc.running) mullvadRelayListProc.running = true
|
||||||
|
} else {
|
||||||
|
root.mullvadPickerTarget = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openMullvadPicker(target) {
|
||||||
|
root.mullvadPickerFilter = ""
|
||||||
|
root.mullvadPickerTarget = root.mullvadPickerTarget === target ? "" : target
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickMullvadLocation(code) {
|
||||||
|
const target = root.mullvadPickerTarget
|
||||||
|
root.mullvadPickerTarget = ""
|
||||||
|
root.setMullvadLocation(target, code)
|
||||||
|
}
|
||||||
|
|
||||||
|
function setMullvadAutoConnect(on) {
|
||||||
|
if (mullvadAutoConnectSetProc.running) return
|
||||||
|
mullvadAutoConnectSetProc.command = ["mullvad", "auto-connect", "set", on ? "on" : "off"]
|
||||||
|
mullvadAutoConnectSetProc.running = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function setMullvadMultihop(on) {
|
||||||
|
if (mullvadRelaySetProc.running) return
|
||||||
|
mullvadRelaySetProc.command = ["mullvad", "relay", "set", "multihop", on ? "on" : "off"]
|
||||||
|
mullvadRelaySetProc.running = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function setMullvadLocation(target, code) {
|
||||||
|
if (mullvadRelaySetProc.running) return
|
||||||
|
mullvadRelaySetProc.command = target === "entry"
|
||||||
|
? ["mullvad", "relay", "set", "entry", "location", code]
|
||||||
|
: ["mullvad", "relay", "set", "location", code]
|
||||||
|
mullvadRelaySetProc.running = true
|
||||||
|
}
|
||||||
|
|
||||||
function refreshMullvad() {
|
function refreshMullvad() {
|
||||||
if (!root.mullvadInstalled) {
|
if (!root.mullvadInstalled) {
|
||||||
if (!mullvadWhichProc.running) mullvadWhichProc.running = true
|
if (!mullvadWhichProc.running) mullvadWhichProc.running = true
|
||||||
@@ -197,8 +318,8 @@ Item {
|
|||||||
stderr: StdioCollector { id: mullvadConnectErr }
|
stderr: StdioCollector { id: mullvadConnectErr }
|
||||||
onExited: (exitCode, exitStatus) => {
|
onExited: (exitCode, exitStatus) => {
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
root.actionStatus = "Mullvad: " + root.shortLine(mullvadConnectErr.text || "connect failed")
|
root.mullvadActionStatus = root.shortLine(mullvadConnectErr.text || "Connect failed")
|
||||||
actionStatusTimer.restart()
|
mullvadActionStatusTimer.restart()
|
||||||
} else if (!tailscaleDownProc.running) {
|
} else if (!tailscaleDownProc.running) {
|
||||||
tailscaleDownProc.running = true
|
tailscaleDownProc.running = true
|
||||||
}
|
}
|
||||||
@@ -213,8 +334,8 @@ Item {
|
|||||||
stderr: StdioCollector { id: mullvadDisconnectErr }
|
stderr: StdioCollector { id: mullvadDisconnectErr }
|
||||||
onExited: (exitCode, exitStatus) => {
|
onExited: (exitCode, exitStatus) => {
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
root.actionStatus = "Mullvad: " + root.shortLine(mullvadDisconnectErr.text || "disconnect failed")
|
root.mullvadActionStatus = root.shortLine(mullvadDisconnectErr.text || "Disconnect failed")
|
||||||
actionStatusTimer.restart()
|
mullvadActionStatusTimer.restart()
|
||||||
}
|
}
|
||||||
root.refreshMullvad()
|
root.refreshMullvad()
|
||||||
if (root.pendingConnect === "mullvad") { root.pendingConnect = ""; root.connectMullvad() }
|
if (root.pendingConnect === "mullvad") { root.pendingConnect = ""; root.connectMullvad() }
|
||||||
@@ -229,6 +350,77 @@ Item {
|
|||||||
onTriggered: if (mullvadStatusProc.running) mullvadStatusProc.running = false
|
onTriggered: if (mullvadStatusProc.running) mullvadStatusProc.running = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Mullvad advanced options: auto-connect, relay location, multihop --
|
||||||
|
// Only queried while the options section is open (see
|
||||||
|
// root.openMullvadOptions), not on the regular status poll — these
|
||||||
|
// don't change on their own the way tunnel state does.
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: mullvadAutoConnectGetProc
|
||||||
|
command: ["mullvad", "auto-connect", "get"]
|
||||||
|
stdout: StdioCollector {
|
||||||
|
id: mullvadAutoConnectGetCollector
|
||||||
|
onStreamFinished: root.applyMullvadAutoConnect(mullvadAutoConnectGetCollector.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: mullvadAutoConnectSetProc
|
||||||
|
stdout: StdioCollector {}
|
||||||
|
stderr: StdioCollector { id: mullvadAutoConnectSetErr }
|
||||||
|
onExited: (exitCode, exitStatus) => {
|
||||||
|
if (exitCode !== 0) {
|
||||||
|
root.mullvadActionStatus = root.shortLine(mullvadAutoConnectSetErr.text || "Auto-connect change failed")
|
||||||
|
mullvadActionStatusTimer.restart()
|
||||||
|
}
|
||||||
|
if (!mullvadAutoConnectGetProc.running) mullvadAutoConnectGetProc.running = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: mullvadRelayGetProc
|
||||||
|
command: ["mullvad", "relay", "get"]
|
||||||
|
stdout: StdioCollector {
|
||||||
|
id: mullvadRelayGetCollector
|
||||||
|
onStreamFinished: root.applyMullvadRelay(mullvadRelayGetCollector.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: mullvadRelayListProc
|
||||||
|
command: ["mullvad", "relay", "list"]
|
||||||
|
stdout: StdioCollector {
|
||||||
|
id: mullvadRelayListCollector
|
||||||
|
onStreamFinished: root.applyMullvadCountries(mullvadRelayListCollector.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: mullvadRelaySetProc
|
||||||
|
stdout: StdioCollector {}
|
||||||
|
stderr: StdioCollector { id: mullvadRelaySetErr }
|
||||||
|
onExited: (exitCode, exitStatus) => {
|
||||||
|
if (exitCode !== 0) {
|
||||||
|
root.mullvadActionStatus = root.shortLine(mullvadRelaySetErr.text || "Relay change failed")
|
||||||
|
mullvadActionStatusTimer.restart()
|
||||||
|
}
|
||||||
|
if (!mullvadRelayGetProc.running) mullvadRelayGetProc.running = true
|
||||||
|
// Relay constraint changes don't take effect on an already-open
|
||||||
|
// tunnel by themselves — kick a reconnect so switching location/
|
||||||
|
// multihop while connected actually moves the tunnel, instead of
|
||||||
|
// silently only applying on the next manual reconnect.
|
||||||
|
if (root.mullvadState === "connected" && !mullvadReconnectProc.running) mullvadReconnectProc.running = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: mullvadReconnectProc
|
||||||
|
command: ["mullvad", "reconnect"]
|
||||||
|
stdout: StdioCollector {}
|
||||||
|
stderr: StdioCollector {}
|
||||||
|
onExited: (exitCode, exitStatus) => root.refreshMullvad()
|
||||||
|
}
|
||||||
|
|
||||||
// --- ProtonVPN ---------------------------------------------------------
|
// --- ProtonVPN ---------------------------------------------------------
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
@@ -261,8 +453,8 @@ Item {
|
|||||||
stderr: StdioCollector { id: protonConnectErr }
|
stderr: StdioCollector { id: protonConnectErr }
|
||||||
onExited: (exitCode, exitStatus) => {
|
onExited: (exitCode, exitStatus) => {
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
root.actionStatus = "ProtonVPN: " + root.shortLine(protonConnectErr.text || "connect failed")
|
root.protonActionStatus = root.shortLine(protonConnectErr.text || "Connect failed")
|
||||||
actionStatusTimer.restart()
|
protonActionStatusTimer.restart()
|
||||||
} else if (!tailscaleDownProc.running) {
|
} else if (!tailscaleDownProc.running) {
|
||||||
tailscaleDownProc.running = true
|
tailscaleDownProc.running = true
|
||||||
}
|
}
|
||||||
@@ -277,8 +469,8 @@ Item {
|
|||||||
stderr: StdioCollector { id: protonDisconnectErr }
|
stderr: StdioCollector { id: protonDisconnectErr }
|
||||||
onExited: (exitCode, exitStatus) => {
|
onExited: (exitCode, exitStatus) => {
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
root.actionStatus = "ProtonVPN: " + root.shortLine(protonDisconnectErr.text || "disconnect failed")
|
root.protonActionStatus = root.shortLine(protonDisconnectErr.text || "Disconnect failed")
|
||||||
actionStatusTimer.restart()
|
protonActionStatusTimer.restart()
|
||||||
}
|
}
|
||||||
root.refreshProton()
|
root.refreshProton()
|
||||||
if (root.pendingConnect === "mullvad") { root.pendingConnect = ""; root.connectMullvad() }
|
if (root.pendingConnect === "mullvad") { root.pendingConnect = ""; root.connectMullvad() }
|
||||||
@@ -305,10 +497,17 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: actionStatusTimer
|
id: mullvadActionStatusTimer
|
||||||
interval: 4000
|
interval: 4000
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: root.actionStatus = ""
|
onTriggered: root.mullvadActionStatus = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: protonActionStatusTimer
|
||||||
|
interval: 4000
|
||||||
|
repeat: false
|
||||||
|
onTriggered: root.protonActionStatus = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Bar icon ------------------------------------------------------------
|
// --- Bar icon ------------------------------------------------------------
|
||||||
@@ -416,7 +615,13 @@ Item {
|
|||||||
property string detailText: ""
|
property string detailText: ""
|
||||||
property string state: "disconnected"
|
property string state: "disconnected"
|
||||||
property bool installed: true
|
property bool installed: true
|
||||||
|
// When true, shows a chevron that expands a provider-specific
|
||||||
|
// options section below this row (used for Mullvad's advanced
|
||||||
|
// options; ProtonVPN's row leaves this false).
|
||||||
|
property bool expandable: false
|
||||||
|
property bool expanded: false
|
||||||
signal toggle()
|
signal toggle()
|
||||||
|
signal expandToggle()
|
||||||
width: parent ? parent.width : 0
|
width: parent ? parent.width : 0
|
||||||
radius: 0
|
radius: 0
|
||||||
implicitHeight: rowContent.implicitHeight + 12
|
implicitHeight: rowContent.implicitHeight + 12
|
||||||
@@ -477,8 +682,90 @@ Item {
|
|||||||
busy: provRow.state === "connecting" || provRow.state === "disconnecting"
|
busy: provRow.state === "connecting" || provRow.state === "disconnecting"
|
||||||
onToggled: provRow.toggle()
|
onToggled: provRow.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
visible: provRow.expandable
|
||||||
|
text: provRow.expanded ? "expand_less" : "expand_more"
|
||||||
|
font.family: Appearance.iconFontFamilyRounded
|
||||||
|
font.variableAxes: Appearance.iconFontAxes
|
||||||
|
font.pixelSize: 15
|
||||||
|
color: expandMouse.containsMouse ? Colors.foreground : Colors.muted
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: expandMouse
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: -5
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: provRow.expandToggle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A single clickable "Location: Sweden ›" row inside the Mullvad
|
||||||
|
// options section — used for both the exit location and (when multihop
|
||||||
|
// is on) the entry location. Clicking routes back to root, which opens
|
||||||
|
// the shared country picker below rather than each field owning one.
|
||||||
|
component LocationField: Item {
|
||||||
|
id: locField
|
||||||
|
property string fieldLabel: ""
|
||||||
|
property string valueText: "Any"
|
||||||
|
property bool open: false
|
||||||
|
signal clicked()
|
||||||
|
width: parent ? parent.width : 0
|
||||||
|
implicitHeight: locRow.implicitHeight
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: locRow
|
||||||
|
width: parent.width
|
||||||
|
spacing: 6
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: locField.fieldLabel
|
||||||
|
font.family: Appearance.fontFamily
|
||||||
|
font.pixelSize: Appearance.fontSizeSmall
|
||||||
|
color: Colors.muted
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
elide: Text.ElideRight
|
||||||
|
text: locField.valueText
|
||||||
|
font.family: Appearance.fontFamily
|
||||||
|
font.pixelSize: Appearance.fontSizeSmall
|
||||||
|
font.bold: true
|
||||||
|
color: Colors.foreground
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
text: locField.open ? "expand_less" : "chevron_right"
|
||||||
|
font.family: Appearance.iconFontFamilyRounded
|
||||||
|
font.variableAxes: Appearance.iconFontAxes
|
||||||
|
font.pixelSize: 14
|
||||||
|
color: Colors.muted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: locField.clicked()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A failed connect/disconnect/settings-change message, shown directly
|
||||||
|
// under the provider row it came from rather than in one shared line
|
||||||
|
// for both providers — keeps an error attributed to whichever CLI it
|
||||||
|
// actually came from.
|
||||||
|
component StatusLine: Text {
|
||||||
|
property string message: ""
|
||||||
|
visible: message !== ""
|
||||||
|
width: parent ? parent.width : 0
|
||||||
|
text: message
|
||||||
|
font.family: Appearance.fontFamily
|
||||||
|
font.pixelSize: Appearance.fontSizeSmall
|
||||||
|
color: Colors.muted
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
|
||||||
// --- Panel -----------------------------------------------------------
|
// --- Panel -----------------------------------------------------------
|
||||||
|
|
||||||
@@ -494,7 +781,18 @@ Item {
|
|||||||
NumberAnimation { duration: Appearance.animationDuration; easing.type: Easing.OutCubic }
|
NumberAnimation { duration: Appearance.animationDuration; easing.type: Easing.OutCubic }
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibleChanged: if (visible) root.refresh()
|
// Leaving mullvadOptionsOpen itself alone across opens (it's a
|
||||||
|
// deliberate "keep this expanded" choice), but the country picker
|
||||||
|
// is transient state scoped to one visit — closing the panel with
|
||||||
|
// it open would otherwise leave a stale filter/list waiting.
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (visible) {
|
||||||
|
root.refresh()
|
||||||
|
} else {
|
||||||
|
root.mullvadPickerTarget = ""
|
||||||
|
root.mullvadPickerFilter = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
anchor {
|
anchor {
|
||||||
window: root.barWindow
|
window: root.barWindow
|
||||||
@@ -548,28 +846,202 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
|
||||||
visible: root.actionStatus !== ""
|
|
||||||
width: parent.width
|
|
||||||
text: root.actionStatus
|
|
||||||
font.family: Appearance.fontFamily
|
|
||||||
font.pixelSize: Appearance.fontSizeSmall
|
|
||||||
color: Colors.muted
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
}
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: 2
|
spacing: 2
|
||||||
|
|
||||||
|
// Mullvad's connect row and its advanced options share a
|
||||||
|
// single bordered card — the border wraps the whole
|
||||||
|
// section (row, status line, and options together) and
|
||||||
|
// grows to include the options/picker as they open,
|
||||||
|
// rather than the options having a separate box of
|
||||||
|
// their own below an unbordered connect row.
|
||||||
|
Rectangle {
|
||||||
|
width: parent.width
|
||||||
|
radius: 0
|
||||||
|
color: Colors.background
|
||||||
|
border.color: Colors.muted
|
||||||
|
border.width: 1
|
||||||
|
implicitHeight: mullvadSectionColumn.implicitHeight + 16
|
||||||
|
clip: true
|
||||||
|
// Without this, the card snapped to its new size
|
||||||
|
// instantly while the popup around it was still
|
||||||
|
// animating open, so the border visibly lagged
|
||||||
|
// behind (or cut off) content like the country
|
||||||
|
// picker appearing/disappearing beneath it.
|
||||||
|
Behavior on implicitHeight {
|
||||||
|
NumberAnimation { duration: Appearance.animationDuration; easing.type: Easing.OutCubic }
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: mullvadSectionColumn
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.margins: 8
|
||||||
|
spacing: 8
|
||||||
|
|
||||||
ProviderRow {
|
ProviderRow {
|
||||||
label: "Mullvad"
|
label: "Mullvad"
|
||||||
subIcon: "gpp_good"
|
subIcon: "gpp_good"
|
||||||
state: root.mullvadState
|
state: root.mullvadState
|
||||||
detailText: root.mullvadDetail
|
detailText: root.mullvadDetail
|
||||||
installed: root.mullvadInstalled
|
installed: root.mullvadInstalled
|
||||||
|
expandable: root.mullvadInstalled
|
||||||
|
expanded: root.mullvadOptionsOpen
|
||||||
onToggle: root.toggleMullvad()
|
onToggle: root.toggleMullvad()
|
||||||
|
onExpandToggle: root.openMullvadOptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusLine { message: root.mullvadActionStatus }
|
||||||
|
|
||||||
|
// Advanced options — auto-connect, exit/entry
|
||||||
|
// relay location, multihop.
|
||||||
|
Column {
|
||||||
|
id: mullvadOptionsColumn
|
||||||
|
width: parent.width
|
||||||
|
visible: root.mullvadOptionsOpen && root.mullvadInstalled
|
||||||
|
spacing: 8
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
width: parent.width
|
||||||
|
Text {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: "Auto-connect"
|
||||||
|
font.family: Appearance.fontFamily
|
||||||
|
font.pixelSize: Appearance.fontSizeSmall
|
||||||
|
color: Colors.foreground
|
||||||
|
}
|
||||||
|
ToggleSwitch {
|
||||||
|
checked: root.mullvadAutoConnect
|
||||||
|
busy: mullvadAutoConnectSetProc.running
|
||||||
|
onToggled: root.setMullvadAutoConnect(!root.mullvadAutoConnect)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
width: parent.width
|
||||||
|
Text {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: "Multihop"
|
||||||
|
font.family: Appearance.fontFamily
|
||||||
|
font.pixelSize: Appearance.fontSizeSmall
|
||||||
|
color: Colors.foreground
|
||||||
|
}
|
||||||
|
ToggleSwitch {
|
||||||
|
checked: root.mullvadMultihop
|
||||||
|
busy: mullvadRelaySetProc.running
|
||||||
|
onToggled: root.setMullvadMultihop(!root.mullvadMultihop)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LocationField {
|
||||||
|
fieldLabel: root.mullvadMultihop ? "Exit" : "Location"
|
||||||
|
valueText: root.mullvadLocationLabel
|
||||||
|
open: root.mullvadPickerTarget === "exit"
|
||||||
|
onClicked: root.openMullvadPicker("exit")
|
||||||
|
}
|
||||||
|
|
||||||
|
LocationField {
|
||||||
|
visible: root.mullvadMultihop
|
||||||
|
fieldLabel: "Entry"
|
||||||
|
valueText: root.mullvadEntryLabel
|
||||||
|
open: root.mullvadPickerTarget === "entry"
|
||||||
|
onClicked: root.openMullvadPicker("entry")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shared country picker for whichever LocationField
|
||||||
|
// was last clicked — filter box plus a capped,
|
||||||
|
// scrollable list ("Any" always pinned first).
|
||||||
|
Column {
|
||||||
|
width: parent.width
|
||||||
|
visible: root.mullvadPickerTarget !== ""
|
||||||
|
spacing: 6
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: parent.width
|
||||||
|
implicitHeight: 24
|
||||||
|
radius: 0
|
||||||
|
color: Colors.surface
|
||||||
|
border.color: Colors.muted
|
||||||
|
border.width: 1
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 6
|
||||||
|
visible: mullvadFilterInput.text.length === 0
|
||||||
|
text: "Search country…"
|
||||||
|
font.family: Appearance.fontFamily
|
||||||
|
font.pixelSize: Appearance.fontSizeSmall
|
||||||
|
color: Colors.muted
|
||||||
|
}
|
||||||
|
|
||||||
|
TextInput {
|
||||||
|
id: mullvadFilterInput
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 6
|
||||||
|
color: Colors.foreground
|
||||||
|
font.family: Appearance.fontFamily
|
||||||
|
font.pixelSize: Appearance.fontSizeSmall
|
||||||
|
clip: true
|
||||||
|
focus: root.mullvadPickerTarget !== ""
|
||||||
|
text: root.mullvadPickerFilter
|
||||||
|
onTextChanged: root.mullvadPickerFilter = text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Flickable {
|
||||||
|
id: mullvadPickerFlick
|
||||||
|
width: parent.width
|
||||||
|
height: Math.min(mullvadPickerColumn.implicitHeight, 150)
|
||||||
|
contentWidth: width
|
||||||
|
contentHeight: mullvadPickerColumn.implicitHeight
|
||||||
|
clip: true
|
||||||
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: mullvadPickerColumn
|
||||||
|
width: mullvadPickerFlick.width
|
||||||
|
spacing: 1
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: [{ name: "Any", code: "any" }].concat(root.mullvadFilteredCountries)
|
||||||
|
Rectangle {
|
||||||
|
required property var modelData
|
||||||
|
width: parent.width
|
||||||
|
implicitHeight: 22
|
||||||
|
radius: 0
|
||||||
|
color: countryMouse.containsMouse ? Colors.primary : "transparent"
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.leftMargin: 4
|
||||||
|
anchors.rightMargin: 4
|
||||||
|
elide: Text.ElideRight
|
||||||
|
text: modelData.name
|
||||||
|
font.family: Appearance.fontFamily
|
||||||
|
font.pixelSize: Appearance.fontSizeSmall
|
||||||
|
color: countryMouse.containsMouse ? Colors.primaryText : Colors.foreground
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: countryMouse
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: root.pickMullvadLocation(modelData.code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ProviderRow {
|
ProviderRow {
|
||||||
label: "ProtonVPN"
|
label: "ProtonVPN"
|
||||||
subIcon: "gpp_good"
|
subIcon: "gpp_good"
|
||||||
@@ -578,6 +1050,8 @@ Item {
|
|||||||
installed: root.protonInstalled
|
installed: root.protonInstalled
|
||||||
onToggle: root.toggleProton()
|
onToggle: root.toggleProton()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusLine { message: root.protonActionStatus }
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ import "./modules/osd"
|
|||||||
|
|
||||||
ShellRoot {
|
ShellRoot {
|
||||||
Variants {
|
Variants {
|
||||||
model: Quickshell.screens
|
// Exclude the Sunshine headless virtual monitor — nobody ever sees a
|
||||||
|
// bar there, but PanelWindow's exclusiveZone still reserves space for
|
||||||
|
// it, which left a black strip cut out of Steam Big Picture's
|
||||||
|
// fullscreen area on that output.
|
||||||
|
model: Quickshell.screens.filter(s => !s.name.startsWith("HEADLESS"))
|
||||||
|
|
||||||
Bar {
|
Bar {
|
||||||
required property var modelData
|
required property var modelData
|
||||||
|
|||||||
Reference in New Issue
Block a user