Merge pull request #241 from lonerOrz/fix/power

Fix: Incorrect 0% battery warning at startup
This commit is contained in:
Lysec 2025-09-09 18:20:35 +02:00 committed by GitHub
commit fb3c2f3bb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -68,14 +68,20 @@ Item {
Connections {
target: UPower.displayDevice
function onPercentageChanged() {
root.maybeNotify(percent, charging)
var currentPercent = UPower.displayDevice.percentage * 100
var isCharging = UPower.displayDevice.state === UPowerDeviceState.Charging
root.maybeNotify(currentPercent, isCharging)
}
function onStateChanged() {
var isCharging = UPower.displayDevice.state === UPowerDeviceState.Charging
// Reset notification flag when charging starts
if (charging) {
if (isCharging) {
root.hasNotifiedLowBattery = false
}
// Also re-evaluate maybeNotify, as state might have changed
var currentPercent = UPower.displayDevice.percentage * 100
root.maybeNotify(currentPercent, isCharging)
}
}