aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/network/NetworkPage.qml
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-30 17:49:06 +0100
committerDanilo M. <danix@danix.xyz>2026-11-30 17:49:06 +0100
commite07291ee7c0c65f15d8e0d33dac25da8ef935659 (patch)
tree514628a043fae0dc451b7d776d9daaeaf3733449 /desktop/modules/network/NetworkPage.qml
parent2b9c732f0515bf0f6bb7444e10faddfd1ff4e485 (diff)
downloadquickshell-e07291ee7c0c65f15d8e0d33dac25da8ef935659.tar.gz
quickshell-e07291ee7c0c65f15d8e0d33dac25da8ef935659.zip
feat(network): speedtest with live progress, and section headersHEADmaster
A Speedtest section runs ~/bin/speedtest (Ookla's CLI) with --format=jsonl. It streams one event per line, measured at 5 ping, 72 download and 104 upload events with `progress` (0..1) and a running `bandwidth` in bytes/s, then one result. The page shows the phase's progress bar, the live Mbit/s, and both curves on one scale, each stretched to the full width; the graph stays with the result. --accept-license and --accept-gdpr keep a first-run prompt from blocking it. The run and its state live in NetworkModule, which is always active, so a test survives the drawer closing and its result is there on reopen. An exit without a result reports "Speedtest failed (exit N)". The page's titles move to SectionHeader, with Speedtest given one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules/network/NetworkPage.qml')
-rw-r--r--desktop/modules/network/NetworkPage.qml147
1 files changed, 94 insertions, 53 deletions
diff --git a/desktop/modules/network/NetworkPage.qml b/desktop/modules/network/NetworkPage.qml
index e0f32e8..563251e 100644
--- a/desktop/modules/network/NetworkPage.qml
+++ b/desktop/modules/network/NetworkPage.qml
@@ -36,23 +36,7 @@ Column {
// The rates are Perf's, sampled always, so the graph opens on the last
// minute rather than empty.
- Row {
- spacing: 6
-
- Text {
- anchors.verticalCenter: parent.verticalCenter
- text: String.fromCodePoint(0xF012A)
- font { family: Theme.iconFamily; pixelSize: Theme.fontSize - 2 }
- color: Theme.subtext
- }
-
- Text {
- anchors.verticalCenter: parent.verticalCenter
- text: "Traffic · " + Perf.iface
- font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: true }
- color: Theme.subtext
- }
- }
+ SectionHeader { divider: false; glyph: String.fromCodePoint(0xF012A); label: "Traffic · " + Perf.iface }
Canvas {
id: graph
@@ -230,29 +214,105 @@ Column {
}
}
- Rectangle { width: page.width; height: 1; color: Qt.alpha(Theme.text, 0.12) }
+ // --- Speedtest ---
- // --- Wired ---
+ // The run and its result live in the module (see there).
+ SectionHeader { glyph: "\uf0e4"; label: "Speedtest" }
- Row {
- visible: page.net.wiredDevices.length > 0
- spacing: 6
+ Item {
+ width: page.width
+ implicitHeight: Math.max(speedBtn.implicitHeight, speedText.implicitHeight)
- Text {
+ Button {
+ id: speedBtn
anchors.verticalCenter: parent.verticalCenter
- text: "\uef44"
- font { family: Theme.iconFamily; pixelSize: Theme.fontSize - 2 }
- color: Theme.subtext
+ text: page.net.speedRunning ? "Testing…" : "Speedtest"
+ onClicked: if (!page.net.speedRunning) page.net.runSpeedtest()
}
Text {
- anchors.verticalCenter: parent.verticalCenter
- text: "Wired"
- font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: true }
- color: Theme.subtext
+ id: speedText
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ text: {
+ const n = page.net, r = n.speedResult;
+ if (r) return "↓ " + r.down.toFixed(0) + " ↑ " + r.up.toFixed(0)
+ + " Mbit/s · " + r.ping.toFixed(0) + " ms";
+ if (n.speedPhase === "ping") return "Ping…";
+ if (n.speedPhase) return (n.speedPhase === "download" ? "↓ " : "↑ ")
+ + n.speedLive.toFixed(0) + " Mbit/s";
+ return "";
+ }
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
+ font.features: { "tnum": 1 }
+ color: page.net.speedPhase === "download" ? Theme.teal
+ : page.net.speedPhase === "upload" ? Theme.peach : Theme.text
+ }
+ }
+
+ // The current phase's progress, coloured like its curve below.
+ Rectangle {
+ width: page.width
+ height: 4
+ radius: 2
+ visible: page.net.speedRunning
+ color: Qt.alpha(Theme.text, 0.12)
+ Rectangle {
+ width: parent.width * page.net.speedProgress
+ height: parent.height
+ radius: 2
+ color: page.net.speedPhase === "upload" ? Theme.peach
+ : page.net.speedPhase === "download" ? Theme.teal : Theme.subtext
+ Behavior on width { NumberAnimation { duration: 150 } }
}
}
+ // Both runs on one Mbit/s scale, each stretched to the full width, so
+ // their shapes compare directly; drawn live and kept with the result.
+ Canvas {
+ id: speedGraph
+ width: page.width
+ height: 60
+ visible: page.net.speedDown.length > 0
+ onPaint: {
+ const ctx = getContext("2d");
+ ctx.reset();
+ const d = page.net.speedDown, u = page.net.speedUp;
+ const max = Math.max(1, ...d, ...u);
+ const line = (data, color) => {
+ if (data.length < 2) return;
+ ctx.strokeStyle = color;
+ ctx.lineWidth = 1.5;
+ ctx.beginPath();
+ data.forEach((v, i) => {
+ const x = width * i / (data.length - 1);
+ const y = height - 1 - (height - 2) * v / max;
+ if (i) ctx.lineTo(x, y); else ctx.moveTo(x, y);
+ });
+ ctx.stroke();
+ };
+ line(d, Theme.teal);
+ line(u, Theme.peach);
+ }
+ Connections {
+ target: page.net
+ function onSpeedDownChanged() { speedGraph.requestPaint(); }
+ function onSpeedUpChanged() { speedGraph.requestPaint(); }
+ }
+ }
+
+ Text {
+ width: page.width
+ visible: page.net.speedResult !== null
+ text: page.net.speedResult ? page.net.speedResult.server : ""
+ elide: Text.ElideRight
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
+ color: Theme.subtext
+ }
+
+ // --- Wired ---
+
+ SectionHeader { visible: page.net.wiredDevices.length > 0; glyph: "\uef44"; label: "Wired" }
+
Repeater {
model: page.net.wiredDevices
@@ -281,33 +341,14 @@ Column {
}
}
- Rectangle { width: page.width; height: 1; visible: page.net.wiredDevices.length > 0; color: Qt.alpha(Theme.text, 0.12) }
-
// --- Wifi ---
- Item {
- width: page.width
- implicitHeight: Math.max(wifiLabel.implicitHeight, wifiSwitch.implicitHeight)
-
- Text {
- id: wifiLabel
- anchors { left: wifiGlyph.right; leftMargin: 6; verticalCenter: parent.verticalCenter }
- text: "Wi-Fi"
- font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 1; bold: true }
- color: Theme.text
- }
-
- Text {
- id: wifiGlyph
- anchors.verticalCenter: parent.verticalCenter
- text: "\uf1eb"
- font { family: Theme.iconFamily; pixelSize: Theme.fontSize - 2 }
- color: Theme.subtext
- }
+ SectionHeader {
+ glyph: "\uf1eb"
+ label: "Wi-Fi"
Switch {
- id: wifiSwitch
- anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ anchors { right: parent.right; bottom: parent.bottom }
enabled: Networking.wifiHardwareEnabled
checked: page.net.wifiOn
onToggled: on => Networking.wifiEnabled = on