summaryrefslogtreecommitdiff
path: root/widgets/StyledBusyIndicator.qml
blob: 060870f4d0060cd43bd0aa6acc74624df4abd174 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
pragma ComponentBehavior: Bound

import qs.services
import qs.config
import QtQuick
import QtQuick.Controls
import QtQuick.Shapes

BusyIndicator {
    id: root

    property color fgColour: Colours.palette.m3onPrimaryContainer
    property color bgColour: Colours.palette.m3primaryContainer

    background: null

    contentItem: Shape {
        id: shape

        preferredRendererType: Shape.CurveRenderer
        asynchronous: true

        RotationAnimator on rotation {
            from: 0
            to: 180
            running: root.visible && root.running
            loops: Animation.Infinite
            duration: Appearance.anim.durations.extraLarge
            easing.type: Easing.Linear
            easing.bezierCurve: Appearance.anim.curves.expressiveDefaultSpatial
        }

        ShapePath {
            strokeWidth: Math.min(root.implicitWidth, root.implicitHeight) * 0.18
            strokeColor: root.bgColour
            fillColor: "transparent"
            capStyle: ShapePath.RoundCap

            PathAngleArc {
                centerX: shape.width / 2
                centerY: shape.height / 2
                radiusX: root.implicitWidth / 2
                radiusY: root.implicitHeight / 2
                startAngle: 0
                sweepAngle: 360
            }

            Behavior on strokeColor {
                ColorAnimation {
                    duration: Appearance.anim.durations.normal
                    easing.type: Easing.BezierSpline
                    easing.bezierCurve: Appearance.anim.curves.standard
                }
            }
        }

        ShapePath {
            strokeWidth: Math.min(root.implicitWidth, root.implicitHeight) * 0.18
            strokeColor: root.fgColour
            fillColor: "transparent"
            capStyle: ShapePath.RoundCap

            PathAngleArc {
                centerX: shape.width / 2
                centerY: shape.height / 2
                radiusX: root.implicitWidth / 2
                radiusY: root.implicitHeight / 2
                startAngle: -sweepAngle / 2
                sweepAngle: 60
            }

            PathAngleArc {
                centerX: shape.width / 2
                centerY: shape.height / 2
                radiusX: root.implicitWidth / 2
                radiusY: root.implicitHeight / 2
                startAngle: 180 - sweepAngle / 2
                sweepAngle: 60
            }

            Behavior on strokeColor {
                ColorAnimation {
                    duration: Appearance.anim.durations.normal
                    easing.type: Easing.BezierSpline
                    easing.bezierCurve: Appearance.anim.curves.standard
                }
            }
        }
    }
}