Update battery icon promptly on power changes
This commit is contained in:
@@ -74,9 +74,7 @@ function batteryIcon(device, onBattery, states) {
|
||||
|
||||
if (threshold) return defaultIcons[index]
|
||||
if (d.state === states.FullyCharged) return ""
|
||||
if (d.state === states.Charging) return chargingIcons[index]
|
||||
if (d.state === states.Discharging) return defaultIcons[index]
|
||||
if (!onBattery) return ""
|
||||
if (!onBattery) return chargingIcons[index]
|
||||
return defaultIcons[index]
|
||||
}
|
||||
|
||||
@@ -86,8 +84,8 @@ function modeLabel(device, onBattery, states) {
|
||||
|
||||
var percentage = d.isPresent ? d.percentage : 0
|
||||
if (chargeThresholdActive(d, onBattery, states)) return "Threshold"
|
||||
if (onBattery) return "On battery"
|
||||
if (!onBattery && percentage >= 1) return "Fully charged"
|
||||
if (onBattery || d.state === states.Discharging) return "On battery"
|
||||
return "Charging"
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ Panel {
|
||||
}
|
||||
readonly property bool discharging: {
|
||||
var device = UPower.displayDevice
|
||||
return !!(device && device.isPresent && (UPower.onBattery || device.state === UPowerDeviceState.Discharging))
|
||||
return !!(device && device.isPresent && UPower.onBattery)
|
||||
}
|
||||
readonly property bool chargeThresholdActive: {
|
||||
var device = UPower.displayDevice
|
||||
@@ -76,7 +76,7 @@ Panel {
|
||||
|
||||
readonly property bool charging: {
|
||||
var d = UPower.displayDevice
|
||||
return d && d.isPresent && d.state === UPowerDeviceState.Charging && !root.chargeThresholdActive
|
||||
return d && d.isPresent && !UPower.onBattery && !root.batteryFlowIdle
|
||||
}
|
||||
|
||||
readonly property color batteryFillColor: {
|
||||
|
||||
Reference in New Issue
Block a user