battery-wid

This commit is contained in:
Zacharias-Brohn
2026-02-11 16:08:38 +01:00
parent fc3a226b7d
commit a717c8c18c
2 changed files with 4 additions and 5 deletions
+4 -3
View File
@@ -11,12 +11,13 @@ Singleton {
readonly property bool onBattery: UPower.onBattery
readonly property UPowerDevice displayDevice: UPower.displayDevice
property UPowerDevice batteryDevice
property UPowerDevice batteryDevice: findDevice()
function findDevice(): void {
function findDevice(): UPowerDevice {
for ( let i = 0; i < root.devices.length; i++ ) {
console.log(root.devices[i])
if ( root.devices[i].type === "Battery" ) {
root.batteryDevice = root.devices[i];
return root.devices[i];
}
}
}
-2
View File
@@ -12,8 +12,6 @@ Item {
anchors.top: parent.top
anchors.bottom: parent.bottom
Component.onCompleted: UPower.findDevice()
CustomText {
text: UPower.batteryDevice.percentage + "%"
anchors.centerIn: parent