bar: fix battery charging

This commit is contained in:
2 * r + 2 * t 2025-05-27 11:28:15 +08:00
parent 63da636144
commit 6cd1700603

View file

@ -73,9 +73,8 @@ Item {
sourceComponent: MaterialIcon { sourceComponent: MaterialIcon {
text: { text: {
const device = UPower.displayDevice; const perc = UPower.displayDevice.percentage;
const perc = device.percentage; const charging = !UPower.onBattery;
const charging = device.changeRate > 0;
if (perc === 1) if (perc === 1)
return charging ? "battery_charging_full" : "battery_full"; return charging ? "battery_charging_full" : "battery_full";
let level = Math.floor(perc * 7); let level = Math.floor(perc * 7);
@ -83,7 +82,7 @@ Item {
level--; level--;
return charging ? `battery_charging_${(level + 3) * 10}` : `battery_${level}_bar`; return charging ? `battery_charging_${(level + 3) * 10}` : `battery_${level}_bar`;
} }
color: UPower.displayDevice.percentage > 0.2 || UPower.displayDevice.changeRate > 0 ? root.colour : Colours.palette.m3error color: !UPower.onBattery || UPower.displayDevice.percentage > 0.2 ? root.colour : Colours.palette.m3error
fill: 1 fill: 1
} }
} }