blob: 4fc7991abea76e53deb4da5bc47e0ca568293734 (
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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
import qs.components
import qs.components.controls
import qs.services
import qs.config
import Quickshell.Widgets
import QtQuick
import QtQuick.Layouts
RowLayout {
id: root
required property bool isLarge
spacing: Appearance.spacing.large * (isLarge ? 2 : 1.5)
width: isLarge ? Config.lock.sizes.mediaWidth : Config.lock.sizes.mediaWidthSmall
property real playerProgress: {
const active = Players.active;
return active?.length ? active.position / active.length : 0;
}
Behavior on playerProgress {
NumberAnimation {
duration: Appearance.anim.durations.large
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard
}
}
Timer {
running: Players.active?.isPlaying ?? false
interval: Config.dashboard.mediaUpdateInterval
triggeredOnStart: true
repeat: true
onTriggered: Players.active?.positionChanged()
}
Item {
Layout.alignment: Qt.AlignVCenter
Layout.topMargin: root.isLarge ? 0 : Config.lock.sizes.border / 2
Layout.bottomMargin: root.isLarge ? Config.lock.sizes.border / 2 : 0
Layout.leftMargin: root.isLarge ? 0 : Config.lock.sizes.border / 2
implicitWidth: root.isLarge ? Config.lock.sizes.mediaCoverSize : Config.lock.sizes.mediaCoverSizeSmall
implicitHeight: root.isLarge ? Config.lock.sizes.mediaCoverSize : Config.lock.sizes.mediaCoverSizeSmall
ClippingWrapperRectangle {
anchors.fill: parent
color: Colours.tPalette.m3surfaceContainerHigh
radius: Appearance.rounding.small
rotation: 9
Image {
anchors.fill: parent
source: Players.active?.trackArtUrl ?? ""
asynchronous: true
fillMode: Image.PreserveAspectCrop
sourceSize.width: width
sourceSize.height: height
}
Behavior on color {
ColorAnimation {
duration: Appearance.anim.durations.normal
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard
}
}
}
Rectangle {
anchors.fill: parent
anchors.margins: -1
border.width: Config.lock.sizes.mediaCoverBorder
border.color: Colours.palette.m3primary
color: "transparent"
radius: Appearance.rounding.small
rotation: 9
Behavior on border.color {
ColorAnimation {
duration: Appearance.anim.durations.normal
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard
}
}
}
StyledClippingRect {
anchors.fill: parent
color: Colours.tPalette.m3surfaceContainerHigh
radius: Appearance.rounding.small
border.width: Config.lock.sizes.mediaCoverBorder
border.color: Colours.palette.m3primary
MaterialIcon {
anchors.centerIn: parent
grade: 200
text: "art_track"
color: Colours.palette.m3onSurfaceVariant
font.pointSize: (root.isLarge ? Config.lock.sizes.mediaCoverSize : Config.lock.sizes.mediaCoverSizeSmall) * 0.4
}
Image {
anchors.fill: parent
source: Players.active?.trackArtUrl ?? ""
asynchronous: true
fillMode: Image.PreserveAspectCrop
sourceSize.width: width
sourceSize.height: height
}
}
}
ColumnLayout {
Layout.alignment: Qt.AlignVCenter
Layout.topMargin: root.isLarge ? 0 : Config.lock.sizes.border / 2
Layout.bottomMargin: root.isLarge ? Config.lock.sizes.border / 2 : 0
Layout.rightMargin: root.isLarge ? Config.lock.sizes.border / 2 : 0
Layout.fillWidth: true
spacing: root.isLarge ? Appearance.spacing.small : Appearance.spacing.small / 2
StyledText {
Layout.fillWidth: true
animate: true
text: (Players.active?.trackTitle ?? qsTr("No media")) || qsTr("Unknown title")
color: Colours.palette.m3primary
font.pointSize: root.isLarge ? Appearance.font.size.large : Appearance.font.size.larger
elide: Text.ElideRight
}
StyledText {
Layout.fillWidth: true
animate: true
text: (Players.active?.trackAlbum ?? qsTr("No media")) || qsTr("Unknown album")
color: Colours.palette.m3outline
font.pointSize: root.isLarge ? Appearance.font.size.larger : Appearance.font.size.normal
elide: Text.ElideRight
}
StyledText {
Layout.fillWidth: true
animate: true
text: (Players.active?.trackArtist ?? qsTr("No media")) || qsTr("Unknown artist")
color: Colours.palette.m3secondary
font.pointSize: root.isLarge ? Appearance.font.size.larger : Appearance.font.size.normal
elide: Text.ElideRight
}
RowLayout {
id: controls
Layout.fillWidth: true
spacing: Appearance.spacing.small
StyledSlider {
id: slider
Layout.rightMargin: root.isLarge ? Appearance.spacing.small : 0
Layout.fillWidth: true
implicitHeight: Appearance.padding.normal * 3
value: root.playerProgress
onMoved: {
const active = Players.active;
if (active?.canSeek && active?.positionSupported)
active.position = value * active.length;
}
}
Control {
icon: "skip_previous"
canUse: Players.active?.canGoPrevious ?? false
fontSize: root.isLarge ? Appearance.font.size.extraLarge : Appearance.font.size.large * 1.2
function onClicked(): void {
Players.active?.previous();
}
}
Control {
icon: Players.active?.isPlaying ? "pause" : "play_arrow"
canUse: Players.active?.canTogglePlaying ?? false
fontSize: root.isLarge ? Appearance.font.size.extraLarge : Appearance.font.size.large * 1.2
primary: true
function onClicked(): void {
Players.active?.togglePlaying();
}
}
Control {
icon: "skip_next"
canUse: Players.active?.canGoNext ?? false
fontSize: root.isLarge ? Appearance.font.size.extraLarge : Appearance.font.size.large * 1.2
function onClicked(): void {
Players.active?.next();
}
}
}
}
component Control: StyledRect {
id: control
required property string icon
required property bool canUse
required property int fontSize
property int padding
property bool fill: true
property bool primary
function onClicked(): void {
}
implicitWidth: Math.max(icon.implicitWidth, icon.implicitHeight) + padding * 2
implicitHeight: implicitWidth
radius: Appearance.rounding.full
color: Qt.alpha(Colours.palette.m3primary, primary && canUse ? 1 : 0)
StateLayer {
disabled: !control.canUse
radius: parent.radius
color: control.primary ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface
function onClicked(): void {
control.onClicked();
}
}
MaterialIcon {
id: icon
anchors.centerIn: parent
anchors.horizontalCenterOffset: -font.pointSize * 0.02
anchors.verticalCenterOffset: font.pointSize * 0.02
animate: true
fill: control.fill ? 1 : 0
text: control.icon
color: control.canUse ? control.primary ? Colours.palette.m3onPrimary : Colours.palette.m3onSurface : Colours.palette.m3outline
font.pointSize: control.fontSize
}
}
}
|