battery: throttle pulse animation to 20fps

ref #3849
This commit is contained in:
bbedward
2026-10-21 13:59:43 -04:00
parent 28f921fa02
commit 1b59a474dd
+11 -17
View File
@@ -39,26 +39,20 @@ BasePill {
return Qt.rgba(from.r + (to.r - from.r) * progress, from.g + (to.g - from.g) * progress, from.b + (to.b - from.b) * progress, from.a + (to.a - from.a) * progress);
}
SequentialAnimation on criticalPulse {
property int criticalTick: 0
// Stepped on purpose: an Animation repaints the bar at the full refresh rate.
Timer {
interval: 50
repeat: true
running: battery.critical && battery.surfaceLive && !SettingsData.reduceMotion
loops: Animation.Infinite
onRunningChanged: {
if (!running)
battery.criticalPulse = 0;
battery.criticalTick = 0;
battery.criticalPulse = 0;
}
NumberAnimation {
from: 0
to: 1
duration: 1000
easing.type: Easing.Linear
}
NumberAnimation {
from: 1
to: 0
duration: 1000
easing.type: Easing.Linear
onTriggered: {
battery.criticalTick = (battery.criticalTick + 1) % 40;
battery.criticalPulse = 1 - Math.abs(20 - battery.criticalTick) / 20;
}
}