repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
quickshell/nuguland/features/power/fixtures/load.qml
Rawimport QtQuick
import QtQuick.Window
import Quickshell
import "../../.." as N
import "../../../features/power" as PowerFeature
// `just load-test power`: the registry entry's own panel, bound to the power
// double the load harness overlays. The panel renders its battery, then its
// natural height, which sizes the card, follows the double through desktop,
// devices and an armed confirmation. No UPower, compositor, input, or pixels.
ShellRoot {
id: root
readonly property N.FeatureEntry feature: registry.popup("power")
property int step: 0
// Natural heights seen so far: laptop, desktop, desktop with devices.
property var heights: []
// The overlaid double's fixture surface; production Power has no setBattery.
readonly property var powerDouble: registry.power
function finish(): void {
const panel = loader.item as PowerFeature.PowerPanel;
if (!panel || panel.contentHeight <= 0)
return;
const height = panel.naturalHeight;
const last = root.heights[root.heights.length - 1];
if (root.step === 0 && panel.hasMainBattery) {
root.step = 1;
root.heights = [height];
root.powerDouble.setBattery(false);
} else if (root.step === 1 && !panel.hasMainBattery && height < last) {
root.step = 2;
root.heights = root.heights.concat([height]);
root.powerDouble.setDevices(["fixture mouse", "fixture keyboard", "fixture headset"]);
} else if (root.step === 2 && height > last) {
root.step = 3;
root.heights = root.heights.concat([height]);
root.powerDouble.sessionAction("reboot");
} else if (root.step === 3 && height > last) {
root.step = 4;
root.feature.dismissed();
} else if (root.step === 4 && root.powerDouble.pendingConfirmation === "" && height === last && height + 48 < root.feature.height) {
console.log("load power: PASS");
Qt.quit();
}
}
N.Theme {
id: nuguTheme
}
N.Registry {
id: registry
theme: nuguTheme
}
// Plain Window: Quickshell windows set input masks the offscreen platform rejects.
Window {
width: 352
height: 372
visible: true
color: "transparent"
Loader {
id: loader
anchors.fill: parent
sourceComponent: root.feature ? root.feature.panel : null
}
}
Timer {
interval: 25
running: true
repeat: true
onTriggered: root.finish()
}
Timer {
interval: 5000
running: true
onTriggered: {
console.error("ERROR load power: panel natural height never followed the double");
Qt.quit();
}
}
}