Fix: Incorrect 0% battery warning at startup
This commit is contained in:
parent
1f0be929d7
commit
c31dc75c63
1 changed files with 8 additions and 2 deletions
|
|
@ -68,14 +68,20 @@ Item {
|
||||||
Connections {
|
Connections {
|
||||||
target: UPower.displayDevice
|
target: UPower.displayDevice
|
||||||
function onPercentageChanged() {
|
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() {
|
function onStateChanged() {
|
||||||
|
var isCharging = UPower.displayDevice.state === UPowerDeviceState.Charging
|
||||||
// Reset notification flag when charging starts
|
// Reset notification flag when charging starts
|
||||||
if (charging) {
|
if (isCharging) {
|
||||||
root.hasNotifiedLowBattery = false
|
root.hasNotifiedLowBattery = false
|
||||||
}
|
}
|
||||||
|
// Also re-evaluate maybeNotify, as state might have changed
|
||||||
|
var currentPercent = UPower.displayDevice.percentage * 100
|
||||||
|
root.maybeNotify(currentPercent, isCharging)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue