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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
import QtQml 2.15
import QtQuick 2.15
import QtQuick.Layouts 1.2
import QtGraphicalEffects 1.15
import Style 1.0
RowLayout {
id: unifiedSearchResultSkeletonItemDetails
property int textLeftMargin: Style.unifiedSearchResultTextLeftMargin
property int textRightMargin: Style.unifiedSearchResultTextRightMargin
property int iconWidth: Style.unifiedSearchResultIconWidth
property int iconLeftMargin: Style.unifiedSearchResultIconLeftMargin
property int titleFontSize: Style.unifiedSearchResultTitleFontSize
property int sublineFontSize: Style.unifiedSearchResultSublineFontSize
Accessible.role: Accessible.ListItem
Accessible.name: qsTr("Search result skeleton.").arg(model.index)
height: Style.trayWindowHeaderHeight
/*
* An overview of what goes on here:
*
* We want to provide the user with a loading animation of a unified search result list item "skeleton".
* This skeleton has a square and two rectangles that are meant to represent the icon and the text of a
* real search result.
*
* We also want to provide a nice animation that has a dark gradient moving over these shapes. To do so,
* we very simply create rectangles that have a gradient going transparent->dark->dark->transparent, and
* overlay them over the shapes beneath.
*
* We then use NumberAnimations to move these gradients left-to-right over the base shapes below. Since
* the gradient rectangles are child elements of the base-color rectangles which they move over, as long
* as we ensure that the parent rectangle has the "clip" property enabled this will look nice and won't
* spill over onto other elements.
*
* We also want to make sure that, even though these gradient rectangles are separate, it looks as it is
* one single gradient sweeping over the base color components
*/
property color baseGradientColor: Style.lightHover
property color progressGradientColor: Style.darkMode ? Qt.lighter(baseGradientColor, 1.2) : Qt.darker(baseGradientColor, 1.1)
property int animationRectangleWidth: Style.trayWindowWidth
property int animationStartX: -animationRectangleWidth
property int animationEndX: animationRectangleWidth
Component {
id: gradientAnimationRectangle
Rectangle {
width: unifiedSearchResultSkeletonItemDetails.animationRectangleWidth
height: parent.height
gradient: Gradient {
orientation: Gradient.Horizontal
GradientStop {
position: 0
color: "transparent"
}
GradientStop {
position: 0.4
color: unifiedSearchResultSkeletonItemDetails.progressGradientColor
}
GradientStop {
position: 0.6
color: unifiedSearchResultSkeletonItemDetails.progressGradientColor
}
GradientStop {
position: 1.0
color: "transparent"
}
}
NumberAnimation on x {
from: unifiedSearchResultSkeletonItemDetails.animationStartX
to: unifiedSearchResultSkeletonItemDetails.animationEndX
duration: 1000
loops: Animation.Infinite
running: true
}
}
}
Item {
Layout.preferredWidth: unifiedSearchResultSkeletonItemDetails.iconWidth
Layout.preferredHeight: unifiedSearchResultSkeletonItemDetails.iconWidth
Layout.leftMargin: unifiedSearchResultSkeletonItemDetails.iconLeftMargin
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
Rectangle {
id: unifiedSearchResultSkeletonThumbnail
anchors.fill: parent
color: unifiedSearchResultSkeletonItemDetails.baseGradientColor
clip: true
visible: false
Loader {
x: mapFromItem(unifiedSearchResultSkeletonItemDetails, 0, 0).x
height: parent.height
sourceComponent: gradientAnimationRectangle
}
}
Rectangle {
id: unifiedSearchResultSkeletonThumbnailMask
anchors.fill: unifiedSearchResultSkeletonThumbnail
color: "white"
radius: 100
visible: false
}
OpacityMask {
anchors.fill: unifiedSearchResultSkeletonThumbnail
source: unifiedSearchResultSkeletonThumbnail
maskSource: unifiedSearchResultSkeletonThumbnailMask
}
}
Column {
id: unifiedSearchResultSkeletonTextContainer
Layout.fillWidth: true
Layout.leftMargin: unifiedSearchResultSkeletonItemDetails.textLeftMargin
Layout.rightMargin: unifiedSearchResultSkeletonItemDetails.textRightMargin
spacing: Style.standardSpacing
Item {
height: unifiedSearchResultSkeletonItemDetails.titleFontSize
width: parent.width
Rectangle {
id: unifiedSearchResultSkeletonTitleText
anchors.fill: parent
color: unifiedSearchResultSkeletonItemDetails.baseGradientColor
clip: true
visible: false
Loader {
x: mapFromItem(unifiedSearchResultSkeletonItemDetails, 0, 0).x
height: parent.height
sourceComponent: gradientAnimationRectangle
}
}
Rectangle {
id: unifiedSearchResultSkeletonTitleTextMask
anchors.fill: unifiedSearchResultSkeletonTitleText
color: "white"
radius: Style.veryRoundedButtonRadius
visible: false
}
OpacityMask {
anchors.fill: unifiedSearchResultSkeletonTitleText
source: unifiedSearchResultSkeletonTitleText
maskSource: unifiedSearchResultSkeletonTitleTextMask
}
}
Item {
height: unifiedSearchResultSkeletonItemDetails.sublineFontSize
width: parent.width
Rectangle {
id: unifiedSearchResultSkeletonTextSubline
anchors.fill: parent
color: unifiedSearchResultSkeletonItemDetails.baseGradientColor
clip: true
visible: false
Loader {
x: mapFromItem(unifiedSearchResultSkeletonItemDetails, 0, 0).x
height: parent.height
sourceComponent: gradientAnimationRectangle
}
}
Rectangle {
id: unifiedSearchResultSkeletonTextSublineMask
anchors.fill: unifiedSearchResultSkeletonTextSubline
color: "white"
radius: Style.veryRoundedButtonRadius
visible: false
}
OpacityMask {
anchors.fill:unifiedSearchResultSkeletonTextSubline
source: unifiedSearchResultSkeletonTextSubline
maskSource: unifiedSearchResultSkeletonTextSublineMask
}
}
}
}
|