feat: add battery status indicator

This commit is contained in:
Nydragon 2024-10-30 17:26:10 +01:00
parent 74caaa8d0e
commit 37add5008a
Signed by: nydragon
SSH key fingerprint: SHA256:WcjW5NJPQ8Dx4uQDmoIlVPLWE27Od3fxoe0IUvuoPHE

View file

@ -20,6 +20,7 @@ BRectangle {
percentage: UPower.displayDevice?.healthPercentage ?? 0
visible: UPower.displayDevice?.healthSupported ?? false
}
Pill {
id: battery
width: parent.width * (!UPower.displayDevice?.healthSupported || 3 / 5)
@ -29,5 +30,19 @@ BRectangle {
percentage: UPower.displayDevice?.percentage ?? 0
color: 100 * percentage / 360
}
Text {
font.pointSize: 25
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: if (UPower.displayDevice?.state === UPowerDeviceState.Charging)
return "󱐋"
else if (UPower.displayDevice?.state === UPowerDeviceState.PendingCharge && !UPower.onBattery)
return "󰚥"
visible: text
}
}
}