-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPanel.qml
More file actions
385 lines (358 loc) · 13.2 KB
/
Copy pathPanel.qml
File metadata and controls
385 lines (358 loc) · 13.2 KB
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
import QtQuick
import qs.Commons
import qs.Ui
import "Model.js" as Model
// Popup for the cliamp bar widget: scrubber, transport, shuffle/repeat,
// volume, and the yt-radio toggle. Loaded by BarWidget's Loader (not a
// manifest kind), same pattern as manuel-artia.eva-deadline.
Panel {
id: root
moduleName: "io.github.cache21.cliamp"
ipcTarget: "" // Service owns the "io.github.cache21.cliamp" IPC target
property var anchorItem: null
readonly property var svc: bar && bar.shell ? bar.shell.serviceFor("io.github.cache21.cliamp") : null
readonly property bool active: !!svc && svc.running
readonly property bool hasDuration: !!svc && svc.durationSec > 0
readonly property string panelArtUrl: (svc && svc.running) ? Model.artUrl(svc.snapshot) : ""
readonly property string panelArtFallback: (svc && svc.running) ? Model.artUrlFallback(svc.snapshot) : ""
readonly property bool showPanelSpectrum: setting("showPanelSpectrum", true) === true
readonly property bool showPanelSearch: setting("showPanelSearch", true) === true
readonly property int searchResultCount: Math.max(5, Math.min(25, Number(setting("searchResultCount", 12))))
property bool searchMode: false
// Hold the shared visstream on the service only while the popup is open.
property bool visHeld: false
onOpenedChanged: {
if (!svc) return
if (!opened) root.searchMode = false
if (opened && !visHeld) { svc.acquireVis(); visHeld = true }
else if (!opened && visHeld) { svc.releaseVis(); visHeld = false }
}
Component.onDestruction: if (visHeld && svc) svc.releaseVis()
KeyboardPanel {
id: panel
anchorItem: root.anchorItem
owner: root
bar: root.bar
open: root.opened
focusTarget: keyCatcher
contentWidth: panel.fittedContentWidth(Style.space(340))
contentHeight: panel.fittedContentHeight(column.implicitHeight, Style.space(560))
PanelKeyCatcher {
id: keyCatcher
anchors.fill: parent
blocked: root.searchMode
onCloseRequested: root.close()
onTextKey: function (t) {
if (t === "/") { root.searchMode = true; return }
if (!root.svc) return
if (t === " ") root.svc.playPause()
else if (t === "n") root.svc.next()
else if (t === "p") root.svc.previous()
else if (t === "s") root.svc.toggleShuffle()
else if (t === "r") root.svc.cycleRepeat()
}
Column {
id: column
width: parent.width
spacing: Style.space(12)
// ---- header ----
Row {
width: parent.width
spacing: Style.space(12)
// Cover art (YouTube Music thumbnail or embedded art).
BorderSurface {
id: art
width: Style.space(84)
height: Style.space(84)
visible: root.active
radius: Style.space(4)
color: Style.normalFillFor(root.bar.foreground, Color.accent)
borderSpec: Border.controlSpec("normal", root.bar.foreground, Color.accent)
Image {
id: artImage
anchors.fill: parent
anchors.margins: Style.space(2)
readonly property string primary: root.panelArtUrl
source: primary
onPrimaryChanged: source = primary
onStatusChanged: {
if (status === Image.Error && source === primary && root.panelArtFallback)
source = root.panelArtFallback
}
sourceSize.width: 240
sourceSize.height: 240
fillMode: Image.PreserveAspectCrop
asynchronous: true
cache: true
visible: source !== "" && status === Image.Ready
}
Text {
anchors.centerIn: parent
visible: !artImage.visible
text: ""
color: Qt.darker(root.bar.foreground, 1.2)
font.family: root.bar.fontFamily
font.pixelSize: Style.font.displayLarge
}
}
Column {
width: parent.width - (art.visible ? art.width + Style.space(12) : 0)
spacing: Style.space(4)
anchors.verticalCenter: art.visible ? art.verticalCenter : undefined
Text {
width: parent.width
text: root.active ? (root.svc.title || root.svc.station || "cliamp") : "cliamp no está corriendo"
color: root.bar.foreground
font.family: root.bar.fontFamily
font.pixelSize: Style.font.title
font.bold: true
wrapMode: Text.WordWrap
maximumLineCount: 2
elide: Text.ElideRight
}
Text {
width: parent.width
visible: root.active && root.svc.artist !== ""
text: root.svc ? root.svc.artist : ""
color: Qt.darker(root.bar.foreground, 1.3)
font.family: root.bar.fontFamily
font.pixelSize: Style.font.subtitle
elide: Text.ElideRight
}
Text {
width: parent.width
visible: root.active && root.svc.themeName !== ""
text: root.svc ? ("Tema: " + root.svc.themeName) : ""
color: Qt.darker(root.bar.foreground, 1.5)
font.family: root.bar.fontFamily
font.pixelSize: Style.font.caption
}
}
}
// ---- youtube search ----
Button {
visible: root.showPanelSearch && root.active && !root.searchMode
iconText: "" // nf-md-magnify
text: "Buscar en YouTube"
leftAlign: true
bordered: true
foreground: root.bar.foreground
fontFamily: root.bar.fontFamily
onClicked: root.searchMode = true
}
Search {
id: search
width: parent.width
visible: root.searchMode
active: root.searchMode
bar: root.bar
svc: root.svc
resultCount: root.searchResultCount
onExitRequested: {
root.searchMode = false
Qt.callLater(keyCatcher.forceActiveFocus)
}
}
// ---- player controls (hidden while searching) ----
Column {
id: controls
width: parent.width
spacing: Style.space(12)
visible: !root.searchMode
// ---- spectrum ----
Spectrum {
width: parent.width
height: Style.space(56)
visible: root.active && root.showPanelSpectrum && root.svc.visBands.length > 0
peaks: true
bands: root.svc ? root.svc.visBands : []
// barColor left at the Spectrum default (theme accent).
gap: Math.max(1, Style.space(3))
minBar: 2
}
PanelSeparator { foreground: root.bar.foreground }
// ---- progress ----
Column {
width: parent.width
spacing: Style.space(4)
visible: root.active
PanelSlider {
id: progress
width: parent.width
bar: root.bar
visible: root.hasDuration
minimum: 0
maximum: root.hasDuration ? root.svc.durationSec : 1
value: root.svc ? root.svc.positionSec : 0
step: 5
onReleased: function (v) { if (root.svc) root.svc.seekTo(v) }
}
Row {
width: parent.width
visible: root.hasDuration
Text {
text: Model.fmtTime(root.svc ? root.svc.positionSec : 0)
color: Qt.darker(root.bar.foreground, 1.4)
font.family: root.bar.fontFamily
font.pixelSize: Style.font.caption
}
Item { width: parent.width - 2 * Style.space(48); height: 1 }
Text {
horizontalAlignment: Text.AlignRight
text: Model.fmtTime(root.svc ? root.svc.durationSec : 0)
color: Qt.darker(root.bar.foreground, 1.4)
font.family: root.bar.fontFamily
font.pixelSize: Style.font.caption
}
}
Text {
visible: !root.hasDuration
text: "En vivo"
color: Qt.darker(root.bar.foreground, 1.4)
font.family: root.bar.fontFamily
font.pixelSize: Style.font.caption
}
}
// ---- transport ----
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: Style.space(6)
enabled: root.active
Button {
iconText: "" // nf-md-skip_previous
foreground: root.bar.foreground
fontFamily: root.bar.fontFamily
bordered: true
onClicked: if (root.svc) root.svc.previous()
}
Button {
iconText: root.active && root.svc.state === "playing" ? "" : ""
foreground: root.bar.foreground
fontFamily: root.bar.fontFamily
bordered: true
onClicked: if (root.svc) root.svc.playPause()
}
Button {
iconText: "" // nf-md-skip_next
foreground: root.bar.foreground
fontFamily: root.bar.fontFamily
bordered: true
onClicked: if (root.svc) root.svc.next()
}
Button {
iconText: "" // nf-md-stop
foreground: root.bar.foreground
fontFamily: root.bar.fontFamily
bordered: true
onClicked: if (root.svc) root.svc.stop()
}
}
// ---- modes ----
Row {
width: parent.width
spacing: Style.space(10)
enabled: root.active
Text {
text: "Aleatorio"
color: root.bar.foreground
font.family: root.bar.fontFamily
font.pixelSize: Style.font.body
anchors.verticalCenter: parent.verticalCenter
}
ToggleSwitch {
anchors.verticalCenter: parent.verticalCenter
checked: root.active && root.svc.shuffle
foreground: root.bar.foreground
onToggled: if (root.svc) root.svc.toggleShuffle()
}
Item { width: Style.space(12); height: 1 }
Text {
text: "Repetir"
color: root.bar.foreground
font.family: root.bar.fontFamily
font.pixelSize: Style.font.body
anchors.verticalCenter: parent.verticalCenter
}
Button {
anchors.verticalCenter: parent.verticalCenter
text: Model.repeatLabel(root.svc ? root.svc.repeat : "off")
foreground: root.bar.foreground
fontFamily: root.bar.fontFamily
bordered: true
onClicked: if (root.svc) root.svc.cycleRepeat()
}
}
// ---- volume ----
Column {
width: parent.width
spacing: Style.space(4)
enabled: root.active
Row {
width: parent.width
Text {
text: "Volumen"
color: root.bar.foreground
font.family: root.bar.fontFamily
font.pixelSize: Style.font.body
}
Item { width: parent.width - 2 * Style.space(64); height: 1 }
Text {
horizontalAlignment: Text.AlignRight
text: Model.fmtVolume(root.svc ? root.svc.volumeDb : 0)
color: Qt.darker(root.bar.foreground, 1.3)
font.family: root.bar.fontFamily
font.pixelSize: Style.font.caption
}
}
PanelSlider {
width: parent.width
bar: root.bar
minimum: -30
maximum: 6
step: 1
integer: true
value: root.svc ? root.svc.volumeDb : 0
onMoved: function (v) { if (root.svc) root.svc.setVolume(v) }
}
}
PanelSeparator { foreground: root.bar.foreground }
// ---- yt-radio ----
Column {
width: parent.width
spacing: Style.space(4)
Row {
width: parent.width
spacing: Style.space(10)
Text {
width: parent.width - ytSwitch.width - Style.space(10)
text: "Radio infinita (yt-radio)"
color: root.active ? root.bar.foreground : Qt.darker(root.bar.foreground, 1.8)
font.family: root.bar.fontFamily
font.pixelSize: Style.font.body
elide: Text.ElideRight
anchors.verticalCenter: parent.verticalCenter
}
ToggleSwitch {
id: ytSwitch
anchors.verticalCenter: parent.verticalCenter
enabled: root.active
checked: root.active && root.svc.ytRadioEnabled
foreground: root.bar.foreground
onToggled: if (root.svc) root.svc.toggleYtRadio()
}
}
Text {
width: parent.width
visible: !root.active
text: "Requiere la TUI de cliamp abierta (no funciona en --daemon)."
color: Qt.darker(root.bar.foreground, 1.6)
font.family: root.bar.fontFamily
font.pixelSize: Style.font.caption
wrapMode: Text.WordWrap
}
}
} // controls
}
}
}
}