battery shows how much time is left

This commit is contained in:
lucy 2025-12-31 11:23:48 +01:00
parent b4e7d9c42a
commit 6aefb0eb18

View File

@ -35,12 +35,14 @@ Rectangle {
Text { Text {
id: botText id: botText
property var timeToEmpty: UPower.displayDevice.timeToEmpty / 60 / 60 property var timeToEmpty: UPower.displayDevice.timeToEmpty / 60 / 60
property var timeToFull: UPower.displayDevice.timeToFull / 60 / 60
property bool isCharging: UPower.displayDevice.state === UPowerDeviceState.Charging
font.weight: 600 font.weight: 600
font.family: Settings.font font.family: Settings.font
font.pixelSize: Settings.fontSize - 2 font.pixelSize: Settings.fontSize - 2
opacity: 0.7 opacity: 0.7
color: Colors.foreground color: Colors.foreground
text: timeToEmpty.toFixed(1) + "h left" text: isCharging ? timeToFull.toFixed(1) + "h to full" : timeToEmpty.toFixed(1) + "h left"
} }
} }
} }