mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Fix high cpu on busyindicators.
This commit is contained in:
parent
c585de7291
commit
592ca0874b
1 changed files with 81 additions and 75 deletions
|
|
@ -6,79 +6,85 @@ import Common.Styles 1.0
|
|||
// =============================================================================
|
||||
|
||||
BusyIndicator {
|
||||
id: busyIndicator
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
property color color: BusyIndicatorStyle.color
|
||||
|
||||
readonly property int _rotation: 360
|
||||
readonly property int _size: width < height ? width : height
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
visible: running
|
||||
|
||||
contentItem: Item {
|
||||
x: parent.width / 2 - width / 2
|
||||
y: parent.height / 2 - height / 2
|
||||
|
||||
height: _size
|
||||
width: _size
|
||||
|
||||
Item {
|
||||
id: item
|
||||
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Animation.
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
RotationAnimator {
|
||||
duration: BusyIndicatorStyle.duration
|
||||
loops: Animation.Infinite
|
||||
running: true
|
||||
target: item
|
||||
|
||||
from: 0
|
||||
to: busyIndicator._rotation
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Items to draw.
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
Repeater {
|
||||
id: repeater
|
||||
|
||||
model: BusyIndicatorStyle.nSpheres
|
||||
|
||||
Rectangle {
|
||||
x: item.width / 2 - width / 2
|
||||
y: item.height / 2 - height / 2
|
||||
|
||||
height: item.height / 3
|
||||
width: item.width / 3
|
||||
|
||||
color: busyIndicator.color
|
||||
radius: (width > height ? width : height) / 2
|
||||
|
||||
transform: [
|
||||
Translate {
|
||||
y: busyIndicator._size / 2
|
||||
},
|
||||
Rotation {
|
||||
angle: index / repeater.count * busyIndicator._rotation
|
||||
origin {
|
||||
x: width / 2
|
||||
y: height / 2
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
id: busyIndicator
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
property color color: BusyIndicatorStyle.color
|
||||
|
||||
readonly property int _rotation: 360
|
||||
readonly property int _size: width < height ? width : height
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
visible: running
|
||||
|
||||
contentItem: Item {
|
||||
x: parent.width / 2 - width / 2
|
||||
y: parent.height / 2 - height / 2
|
||||
|
||||
height: _size
|
||||
width: _size
|
||||
|
||||
Item {
|
||||
id: item
|
||||
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
opacity: busyIndicator.running ? 1 : 0
|
||||
// -----------------------------------------------------------------------
|
||||
// Animation.
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
Behavior on opacity {
|
||||
OpacityAnimator {
|
||||
duration: 250
|
||||
}
|
||||
}
|
||||
|
||||
RotationAnimator {
|
||||
duration: BusyIndicatorStyle.duration
|
||||
loops: Animation.Infinite
|
||||
running: busyIndicator.visible
|
||||
target: item
|
||||
|
||||
from: 0
|
||||
to: busyIndicator._rotation
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Items to draw.
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
Repeater {
|
||||
id: repeater
|
||||
|
||||
model: BusyIndicatorStyle.nSpheres
|
||||
|
||||
Rectangle {
|
||||
x: item.width / 2 - width / 2
|
||||
y: item.height / 2 - height / 2
|
||||
|
||||
height: item.height / 3
|
||||
width: item.width / 3
|
||||
|
||||
color: busyIndicator.color
|
||||
radius: (width > height ? width : height) / 2
|
||||
|
||||
transform: [
|
||||
Translate {
|
||||
y: busyIndicator._size / 2
|
||||
},
|
||||
Rotation {
|
||||
angle: index / repeater.count * busyIndicator._rotation
|
||||
origin {
|
||||
x: width / 2
|
||||
y: height / 2
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue