[PC3/BusyIndicator] Avoid running invisible animation

Running is a property managed by a state machine. It is bound in the
transition between states. We don't run a transition to get to the first
state.

These transitions aren't needed and can be written away simplifying the
code considerably in the process.

This means krunner is invisibly animating at 60fps constantly even when
it's not doing anything.
This commit is contained in:
David Edmundson 2020-09-05 12:23:02 +01:00
parent 37a95de3f3
commit 7b6191f440

View File

@ -31,6 +31,15 @@ T.BusyIndicator {
implicitWidth: PlasmaCore.Units.gridUnit * 2
implicitHeight: implicitWidth
visible: opacity > 0
opacity: control.running ? 1.0 : 0.0
Behavior on opacity {
OpacityAnimator {
duration: PlasmaCore.Units.shortDuration
easing.type: Easing.OutQuad
}
}
PlasmaCore.SvgItem {
id: busyIndicatorSvgItem
@ -52,69 +61,8 @@ T.BusyIndicator {
to: 360
duration: 2000
loops: Animation.Infinite
running: visible
}
}
}
state: control.running ? "running" : "hidden"
states: [
State {
name: "hidden"
PropertyChanges {
target: contentItem
opacity: 0
}
},
State {
name: "running"
PropertyChanges {
target: contentItem
opacity: 1
}
}
]
transitions: [
Transition {
from: "*"
to: "hidden"
SequentialAnimation {
OpacityAnimator {
duration: PlasmaCore.Units.shortDuration
easing.type: Easing.OutQuad
}
PropertyAction {
target: contentItem
property: "visible"
value: false
}
}
PropertyAction {
target: rotationAnimator
property: "running"
value: false
}
},
Transition {
from: "*"
to: "running"
PropertyAction {
target: rotationAnimator
property: "running"
value: true
}
SequentialAnimation {
PropertyAction {
target: contentItem
property: "visible"
value: true
}
OpacityAnimator {
duration: PlasmaCore.Units.shortDuration
easing.type: Easing.OutQuad
}
}
}
]
}