Debian Codegraph @

resources/qml/ui/Spinner.qml

raw
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import "./animations"
6 import QtQuick
7 import QtQuick.Effects
8
9 Item {
10 id: spinner
11
12 property int spacing: 0
13 property bool running: true
14 property var foreground: "#333"
15 readonly property int barCount: 6
16 readonly property real a: Math.PI / 6
17 readonly property var colors: ["#c0def5", "#87aade", "white"]
18 readonly property var anims: [anim1, anim2, anim3, anim4, anim5, anim6]
19 readonly property int pauseDuration: barCount * 150
20 readonly property int glowDuration: 300
21
22 height: 40
23 width: barCount * (height * 0.375)
24
25 Row {
26 id: row
27
28 Rectangle {
29 id: rect1
30
31 width: ((spinner.width / spinner.barCount) - (spinner.spacing)) * 1.5
32 height: spinner.height / 3.5
33 color: "white"
34 }
35
36 Rectangle {
37 id: rect2
38
39 width: (spinner.width / spinner.barCount) - spinner.spacing
40 height: spinner.height
41 color: spinner.colors[0]
42 }
43
44 Rectangle {
45 id: rect3
46
47 width: (spinner.width / spinner.barCount) - spinner.spacing
48 height: spinner.height
49 color: spinner.colors[1]
50 }
51
52 Rectangle {
53 id: rect4
54
55 width: (spinner.width / spinner.barCount) - spinner.spacing
56 height: spinner.height
57 color: spinner.colors[2]
58 }
59
60 Rectangle {
61 id: rect5
62
63 width: (spinner.width / (spinner.barCount + 1)) - spinner.spacing
64 height: spinner.height / 3.5
65 color: "white"
66 }
67
68 Rectangle {
69 id: rect6
70
71 width: (spinner.width / spinner.barCount) - spinner.spacing
72 height: spinner.height
73 color: "white"
74 }
75
76 BlinkAnimation {
77 id: anim1
78
79 target: rect1
80 running: spinner.running
81 pauseDuration: spinner.pauseDuration
82 glowDuration: spinner.glowDuration
83 offset: 0 / spinner.barCount
84 }
85
86 BlinkAnimation {
87 id: anim2
88
89 target: rect2
90 running: spinner.running
91 pauseDuration: spinner.pauseDuration
92 glowDuration: spinner.glowDuration
93 offset: 1 / spinner.barCount
94 }
95
96 BlinkAnimation {
97 id: anim3
98
99 target: rect3
100 running: spinner.running
101 pauseDuration: spinner.pauseDuration
102 glowDuration: spinner.glowDuration
103 offset: 2 / spinner.barCount
104 }
105
106 BlinkAnimation {
107 id: anim4
108
109 target: rect4
110 running: spinner.running
111 pauseDuration: spinner.pauseDuration
112 glowDuration: spinner.glowDuration
113 offset: 3 / spinner.barCount
114 }
115
116 BlinkAnimation {
117 id: anim5
118
119 target: rect5
120 running: spinner.running
121 pauseDuration: spinner.pauseDuration
122 glowDuration: spinner.glowDuration
123 offset: 4 / spinner.barCount
124 }
125
126 BlinkAnimation {
127 id: anim6
128
129 target: rect6
130 running: spinner.running
131 pauseDuration: spinner.pauseDuration
132 glowDuration: spinner.glowDuration
133 offset: 5 / spinner.barCount
134 }
135
136 transform: Matrix4x4 {
137 matrix: Qt.matrix4x4(Math.cos(spinner.a), -Math.sin(spinner.a), 0, 0, 0, Math.cos(spinner.a), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
138 }
139
140 }
141
142 MultiEffect {
143 anchors.fill: row
144 blurMax: 14
145 shadowEnabled: true
146 shadowColor: spinner.foreground
147 source: row
148
149 transform: Matrix4x4 {
150 matrix: Qt.matrix4x4(Math.cos(spinner.a), -Math.sin(spinner.a), 0, 0, 0, Math.cos(spinner.a), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
151 }
152
153 }
154
155 }