Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/package/contents/ui/ToolTipInstance.qml
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 64 | readonly property string track: { | |||
---|---|---|---|---|---|
78 | var lastUrlPart = xesamUrl.substring(lastSlashPos + 1) | 78 | var lastUrlPart = xesamUrl.substring(lastSlashPos + 1) | ||
79 | return decodeURIComponent(lastUrlPart); | 79 | return decodeURIComponent(lastUrlPart); | ||
80 | } | 80 | } | ||
81 | readonly property string artist: currentMetadata["xesam:artist"] || "" | 81 | readonly property string artist: currentMetadata["xesam:artist"] || "" | ||
82 | readonly property string albumArt: currentMetadata["mpris:artUrl"] || "" | 82 | readonly property string albumArt: currentMetadata["mpris:artUrl"] || "" | ||
83 | 83 | | |||
84 | // | 84 | // | ||
85 | function containsMouse() { | 85 | function containsMouse() { | ||
86 | return area1.containsMouse || area2.containsMouse || area3.containsMouse || area4.containsMouse | 86 | return area1.containsMouse || area2.containsMouse | ||
87 | || (playbackLoader.active && playbackLoader.item.containsMouse()); | 87 | || (playbackLoader.active && playbackLoader.item.containsMouse()); | ||
88 | } | 88 | } | ||
89 | 89 | | |||
90 | // launcher icon + text labels + close button | 90 | // launcher icon + text labels + close button | ||
91 | RowLayout { | 91 | RowLayout { | ||
92 | id: header | 92 | id: header | ||
93 | Layout.minimumWidth: childrenRect.width | 93 | Layout.minimumWidth: childrenRect.width | ||
94 | Layout.maximumWidth: Layout.minimumWidth | 94 | Layout.maximumWidth: Layout.minimumWidth | ||
Show All 9 Lines | 102 | PlasmaCore.IconItem { | |||
104 | Layout.preferredHeight: units.iconSizes.medium | 104 | Layout.preferredHeight: units.iconSizes.medium | ||
105 | source: icon | 105 | source: icon | ||
106 | animated: false | 106 | animated: false | ||
107 | usesPlasmaTheme: false | 107 | usesPlasmaTheme: false | ||
108 | visible: !isWin | 108 | visible: !isWin | ||
109 | } | 109 | } | ||
110 | // all textlabels | 110 | // all textlabels | ||
111 | Column { | 111 | Column { | ||
112 | spacing: 0.75 * units.smallSpacing | 112 | PlasmaExtras.Heading { | ||
113 | Layout.margins: units.smallSpacing * 0.4 | 113 | level: 3 | ||
114 | | ||||
115 | PlasmaComponents.Label { | | |||
116 | width: isWin ? textWidth : undefined | 114 | width: isWin ? textWidth : undefined | ||
117 | height: 1.25 * theme.mSize(theme.defaultFont).height | 115 | height: undefined | ||
118 | font.pointSize: -1 | 116 | maximumLineCount: 1 | ||
119 | font.pixelSize: height | | |||
120 | elide: Text.ElideRight | 117 | elide: Text.ElideRight | ||
121 | text: appName | 118 | text: appName | ||
122 | opacity: flatIndex == 0 | 119 | opacity: flatIndex == 0 | ||
123 | textFormat: Text.PlainText | 120 | textFormat: Text.PlainText | ||
124 | horizontalAlignment: Text.AlignLeft | 121 | visible: text !== "" | ||
125 | } | 122 | } | ||
126 | // window title | 123 | // window title | ||
127 | PlasmaComponents.Label { | 124 | PlasmaExtras.Heading { | ||
125 | id: winTitle | ||||
126 | level: 5 | ||||
128 | width: isWin ? textWidth : undefined | 127 | width: isWin ? textWidth : undefined | ||
129 | height: theme.mSize(theme.defaultFont).height | 128 | height: undefined | ||
130 | font.pointSize: -1 | 129 | maximumLineCount: 1 | ||
131 | font.pixelSize: height | | |||
132 | elide: Text.ElideRight | 130 | elide: Text.ElideRight | ||
133 | text: generateTitle() | 131 | text: generateTitle() | ||
134 | textFormat: Text.PlainText | 132 | textFormat: Text.PlainText | ||
135 | horizontalAlignment: Text.AlignLeft | | |||
136 | opacity: 0.75 | 133 | opacity: 0.75 | ||
134 | visible: !hasPlayer | ||||
137 | } | 135 | } | ||
138 | // subtext | 136 | // subtext | ||
139 | PlasmaComponents.Label { | 137 | PlasmaExtras.Heading { | ||
138 | level: 6 | ||||
140 | width: isWin ? textWidth : undefined | 139 | width: isWin ? textWidth : undefined | ||
141 | height: 0.75 * theme.mSize(theme.defaultFont).height | 140 | height: undefined | ||
142 | font.pointSize: -1 | 141 | maximumLineCount: 1 | ||
143 | font.pixelSize: height | | |||
144 | elide: Text.ElideRight | 142 | elide: Text.ElideRight | ||
145 | text: isWin ? generateSubText() : "" | 143 | text: isWin ? generateSubText() : "" | ||
146 | textFormat: Text.PlainText | 144 | textFormat: Text.PlainText | ||
147 | horizontalAlignment: Text.AlignLeft | | |||
148 | opacity: 0.6 | 145 | opacity: 0.6 | ||
149 | visible: text !== "" | 146 | visible: text !== "" | ||
150 | } | 147 | } | ||
151 | } | 148 | } | ||
152 | // close button | 149 | // close button | ||
153 | MouseArea { | 150 | MouseArea { | ||
154 | id: area1 | 151 | id: area1 | ||
155 | Layout.alignment: Qt.AlignRight | Qt.AlignTop | 152 | Layout.alignment: Qt.AlignRight | Qt.AlignTop | ||
Show All 25 Lines | |||||
181 | } | 178 | } | ||
182 | 179 | | |||
183 | // thumbnail container | 180 | // thumbnail container | ||
184 | Item { | 181 | Item { | ||
185 | id: thumbnail | 182 | id: thumbnail | ||
186 | width: header.width | 183 | width: header.width | ||
187 | // similar to 0.5625 = 1 / (16:9) as most screens are | 184 | // similar to 0.5625 = 1 / (16:9) as most screens are | ||
188 | // round necessary, otherwise shadow mask for players has gap! | 185 | // round necessary, otherwise shadow mask for players has gap! | ||
189 | height: Math.round(0.5 * width) | 186 | height: Math.round(0.5 * width) + (!winTitle.visible? winTitle.height : 0) | ||
190 | anchors.horizontalCenter: parent.horizontalCenter | 187 | anchors.horizontalCenter: parent.horizontalCenter | ||
191 | 188 | | |||
192 | visible: isWin | 189 | visible: isWin | ||
193 | 190 | | |||
194 | Item { | 191 | Item { | ||
195 | id: thumbnailSourceItem | 192 | id: thumbnailSourceItem | ||
196 | anchors.fill: parent | 193 | anchors.fill: parent | ||
197 | anchors.bottomMargin: 2 | 194 | anchors.bottomMargin: 2 | ||
Show All 19 Lines | 212 | ToolTipWindowMouseArea { | |||
217 | 214 | | |||
218 | anchors.fill: Latte.WindowSystem.isPlatformWayland ? parent : previewThumbX11Loader | 215 | anchors.fill: Latte.WindowSystem.isPlatformWayland ? parent : previewThumbX11Loader | ||
219 | rootTask: parentTask | 216 | rootTask: parentTask | ||
220 | modelIndex: submodelIndex | 217 | modelIndex: submodelIndex | ||
221 | winId: thumbnailSourceItem.winId | 218 | winId: thumbnailSourceItem.winId | ||
222 | } | 219 | } | ||
223 | 220 | | |||
224 | Image { | 221 | Image { | ||
222 | id: albumArtBackground | ||||
223 | source: albumArt | ||||
224 | anchors.fill: parent | ||||
225 | fillMode: Image.PreserveAspectCrop | ||||
226 | visible: albumArtImage.available | ||||
227 | layer.enabled: true | ||||
228 | opacity: 0.25 | ||||
229 | layer.effect: FastBlur { | ||||
230 | source: albumArtBackground | ||||
231 | anchors.fill: parent | ||||
232 | radius: 30 | ||||
233 | } | ||||
234 | } | ||||
235 | | ||||
236 | Image { | ||||
225 | id: albumArtImage | 237 | id: albumArtImage | ||
226 | // also Image.Loading to prevent loading thumbnails just because the album art takes a split second to load | 238 | // also Image.Loading to prevent loading thumbnails just because the album art takes a split second to load | ||
227 | readonly property bool available: status === Image.Ready || status === Image.Loading | 239 | readonly property bool available: status === Image.Ready || status === Image.Loading | ||
228 | 240 | | |||
229 | anchors.fill: parent | 241 | height: thumbnail.height - playbackLoader.realHeight | ||
242 | anchors.horizontalCenter: parent.horizontalCenter | ||||
230 | sourceSize: Qt.size(parent.width, parent.height) | 243 | sourceSize: Qt.size(parent.width, parent.height) | ||
231 | asynchronous: true | 244 | asynchronous: true | ||
232 | source: albumArt | 245 | source: albumArt | ||
233 | fillMode: Image.PreserveAspectCrop | 246 | fillMode: Image.PreserveAspectFit | ||
234 | visible: available | 247 | visible: available | ||
235 | | ||||
236 | ToolTipWindowMouseArea { | | |||
237 | id: area3 | | |||
238 | | ||||
239 | anchors.fill: parent | | |||
240 | rootTask: parentTask | | |||
241 | modelIndex: instance.submodelIndex | | |||
242 | winId: thumbnailSourceItem.winId | | |||
243 | } | | |||
244 | } | 248 | } | ||
245 | 249 | | |||
246 | // when minimized, we don't have a preview, so show the icon | 250 | // when minimized, we don't have a preview, so show the icon | ||
247 | PlasmaCore.IconItem { | 251 | PlasmaCore.IconItem { | ||
248 | anchors.fill: parent | 252 | width: parent.width | ||
253 | height: thumbnail.height - playbackLoader.realHeight | ||||
254 | anchors.horizontalCenter: parent.horizontalCenter | ||||
249 | source: icon | 255 | source: icon | ||
250 | animated: false | 256 | animated: false | ||
251 | usesPlasmaTheme: false | 257 | usesPlasmaTheme: false | ||
252 | visible: (thumbnailSourceItem.isMinimized && !albumArtImage.visible) //X11 case | 258 | visible: (thumbnailSourceItem.isMinimized && !albumArtImage.visible) //X11 case | ||
253 | || (!previewThumbX11Loader.active && !albumArtImage.visible) //Wayland case | 259 | || (!previewThumbX11Loader.active && !albumArtImage.visible) //Wayland case | ||
254 | | ||||
255 | ToolTipWindowMouseArea { | | |||
256 | id: area4 | | |||
257 | | ||||
258 | anchors.fill: parent | | |||
259 | rootTask: parentTask | | |||
260 | modelIndex: submodelIndex | | |||
261 | winId: thumbnailSourceItem.winId | | |||
262 | } | | |||
263 | } | 260 | } | ||
264 | } | 261 | } | ||
265 | 262 | | |||
266 | 263 | | |||
267 | Loader { | 264 | Loader { | ||
268 | id: playbackLoader | 265 | id: playbackLoader | ||
266 | | ||||
267 | property real realHeight: item? item.realHeight : 0 | ||||
268 | | ||||
269 | anchors.fill: thumbnail | 269 | anchors.fill: thumbnail | ||
270 | active: hasPlayer | 270 | active: hasPlayer | ||
271 | sourceComponent: playerControlsComp | 271 | sourceComponent: playerControlsComp | ||
272 | } | 272 | } | ||
273 | 273 | | |||
274 | Component { | 274 | Component { | ||
275 | id: playerControlsComp | 275 | id: playerControlsComp | ||
276 | 276 | | |||
277 | Item { | 277 | Item { | ||
278 | property real realHeight: playerControlsRow.height | ||||
279 | | ||||
278 | anchors.fill: parent | 280 | anchors.fill: parent | ||
279 | 281 | | |||
280 | // TODO: When could this really be the case? A not-launcher-task always has a window!? | 282 | // TODO: When could this really be the case? A not-launcher-task always has a window!? | ||
281 | // if there's no window associated with this task, we might still be able to raise the player | 283 | // if there's no window associated with this task, we might still be able to raise the player | ||
282 | // MouseArea { | 284 | // MouseArea { | ||
283 | // id: raisePlayerArea | 285 | // id: raisePlayerArea | ||
284 | // anchors.fill: parent | 286 | // anchors.fill: parent | ||
285 | 287 | | |||
286 | // visible: !isWin || !windows[0] && canRaise | 288 | // visible: !isWin || !windows[0] && canRaise | ||
287 | // onClicked: mpris2Source.raise(mprisSourceName) | 289 | // onClicked: mpris2Source.raise(mprisSourceName) | ||
288 | // } | 290 | // } | ||
289 | 291 | | |||
290 | function containsMouse() { | 292 | function containsMouse() { | ||
291 | return area5.containsMouse || area6.containsMouse || area7.containsMouse || area8.containsMouse; | 293 | return area3.containsMouse || area4.containsMouse || area5.containsMouse || area6.containsMouse; | ||
292 | } | 294 | } | ||
293 | 295 | | |||
294 | Item { | 296 | Item { | ||
295 | id: playerControlsFrostedGlass | 297 | id: playerControlsFrostedGlass | ||
296 | anchors.fill: parent | 298 | anchors.fill: parent | ||
297 | visible: false // OpacityMask would render it | 299 | visible: false // OpacityMask would render it | ||
298 | 300 | | |||
299 | Rectangle { | 301 | Rectangle { | ||
Show All 15 Lines | 316 | OpacityMask { | |||
315 | id: playerControlsOpacityMask | 317 | id: playerControlsOpacityMask | ||
316 | anchors.fill: parent | 318 | anchors.fill: parent | ||
317 | source: playerControlsFrostedGlass | 319 | source: playerControlsFrostedGlass | ||
318 | maskSource: thumbnailSourceItem | 320 | maskSource: thumbnailSourceItem | ||
319 | } | 321 | } | ||
320 | 322 | | |||
321 | // prevent accidental click-through when a control is disabled | 323 | // prevent accidental click-through when a control is disabled | ||
322 | MouseArea { | 324 | MouseArea { | ||
323 | id: area5 | 325 | id: area3 | ||
324 | anchors.fill: playerControlsRow | 326 | anchors.fill: playerControlsRow | ||
325 | 327 | | |||
326 | hoverEnabled: true | 328 | hoverEnabled: true | ||
327 | onContainsMouseChanged: mainToolTip.mouseIsInside(); | 329 | onContainsMouseChanged: mainToolTip.mouseIsInside(); | ||
328 | } | 330 | } | ||
329 | 331 | | |||
330 | RowLayout { | 332 | RowLayout { | ||
331 | id: playerControlsRow | 333 | id: playerControlsRow | ||
332 | anchors { | 334 | anchors { | ||
333 | horizontalCenter: parent.horizontalCenter | 335 | horizontalCenter: parent.horizontalCenter | ||
334 | bottom: parent.bottom | 336 | bottom: parent.bottom | ||
335 | } | 337 | } | ||
336 | width: parent.width | 338 | width: parent.width | ||
337 | spacing: 0 | 339 | spacing: 0 | ||
338 | enabled: canControl | 340 | enabled: canControl | ||
339 | 341 | | |||
340 | ColumnLayout { | 342 | ColumnLayout { | ||
343 | Layout.leftMargin: 2 | ||||
341 | Layout.fillWidth: true | 344 | Layout.fillWidth: true | ||
342 | spacing: 0 | 345 | spacing: 0 | ||
343 | 346 | | |||
344 | PlasmaExtras.Heading { | 347 | PlasmaExtras.Heading { | ||
345 | Layout.fillWidth: true | 348 | Layout.fillWidth: true | ||
346 | level: 4 | 349 | level: 5 | ||
347 | wrapMode: Text.NoWrap | 350 | lineHeight: 1 | ||
351 | maximumLineCount: artistText.visible? 1 : 2 | ||||
352 | wrapMode: artistText.visible? Text.NoWrap : Text.Wrap | ||||
348 | elide: Text.ElideRight | 353 | elide: Text.ElideRight | ||
349 | text: track || "" | 354 | text: track || "" | ||
355 | font.weight: Font.Bold | ||||
350 | } | 356 | } | ||
351 | 357 | | |||
352 | PlasmaExtras.Heading { | 358 | PlasmaExtras.Heading { | ||
359 | id: artistText | ||||
353 | Layout.fillWidth: true | 360 | Layout.fillWidth: true | ||
354 | level: 5 | 361 | level: 5 | ||
355 | wrapMode: Text.NoWrap | 362 | wrapMode: Text.NoWrap | ||
363 | lineHeight: 1 | ||||
356 | elide: Text.ElideRight | 364 | elide: Text.ElideRight | ||
357 | text: artist || "" | 365 | text: artist || "" | ||
366 | visible: text != "" | ||||
367 | opacity: 0.75 | ||||
358 | } | 368 | } | ||
359 | } | 369 | } | ||
360 | 370 | | |||
361 | MouseArea { | 371 | MouseArea { | ||
362 | id: area6 | 372 | id: area4 | ||
363 | 373 | | |||
364 | height: units.iconSizes.smallMedium | 374 | height: units.iconSizes.smallMedium | ||
365 | width: height | 375 | width: height | ||
366 | 376 | | |||
367 | acceptedButtons: Qt.LeftButton | 377 | acceptedButtons: Qt.LeftButton | ||
368 | hoverEnabled: true | 378 | hoverEnabled: true | ||
369 | onClicked: mpris2Source.goPrevious(mprisSourceName) | 379 | onClicked: mpris2Source.goPrevious(mprisSourceName) | ||
370 | onContainsMouseChanged: mainToolTip.mouseIsInside(); | 380 | onContainsMouseChanged: mainToolTip.mouseIsInside(); | ||
371 | 381 | | |||
372 | PlasmaCore.IconItem { | 382 | PlasmaCore.IconItem { | ||
373 | anchors.fill: parent | 383 | anchors.fill: parent | ||
374 | enabled: canGoBack | 384 | enabled: canGoBack | ||
375 | active: parent.containsMouse | 385 | active: parent.containsMouse | ||
376 | 386 | | |||
377 | source: LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward" | 387 | source: LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward" | ||
378 | animated: false | 388 | animated: false | ||
379 | } | 389 | } | ||
380 | } | 390 | } | ||
381 | 391 | | |||
382 | MouseArea { | 392 | MouseArea { | ||
383 | id: area7 | 393 | id: area5 | ||
384 | 394 | | |||
385 | height: units.iconSizes.medium | 395 | height: units.iconSizes.medium | ||
386 | width: height | 396 | width: height | ||
387 | 397 | | |||
388 | acceptedButtons: Qt.LeftButton | 398 | acceptedButtons: Qt.LeftButton | ||
389 | hoverEnabled: true | 399 | hoverEnabled: true | ||
390 | onClicked: mpris2Source.playPause(mprisSourceName) | 400 | onClicked: mpris2Source.playPause(mprisSourceName) | ||
391 | onContainsMouseChanged: mainToolTip.mouseIsInside(); | 401 | onContainsMouseChanged: mainToolTip.mouseIsInside(); | ||
392 | 402 | | |||
393 | PlasmaCore.IconItem { | 403 | PlasmaCore.IconItem { | ||
394 | anchors.fill: parent | 404 | anchors.fill: parent | ||
395 | active: parent.containsMouse | 405 | active: parent.containsMouse | ||
396 | 406 | | |||
397 | source: playing ? "media-playback-pause" : "media-playback-start" | 407 | source: playing ? "media-playback-pause" : "media-playback-start" | ||
398 | animated: false | 408 | animated: false | ||
399 | } | 409 | } | ||
400 | } | 410 | } | ||
401 | 411 | | |||
402 | MouseArea { | 412 | MouseArea { | ||
403 | id: area8 | 413 | id: area6 | ||
404 | 414 | | |||
405 | height: units.iconSizes.smallMedium | 415 | height: units.iconSizes.smallMedium | ||
406 | width: height | 416 | width: height | ||
407 | 417 | | |||
408 | acceptedButtons: Qt.LeftButton | 418 | acceptedButtons: Qt.LeftButton | ||
409 | hoverEnabled: true | 419 | hoverEnabled: true | ||
410 | onClicked: mpris2Source.goNext(mprisSourceName) | 420 | onClicked: mpris2Source.goNext(mprisSourceName) | ||
411 | onContainsMouseChanged: mainToolTip.mouseIsInside(); | 421 | onContainsMouseChanged: mainToolTip.mouseIsInside(); | ||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |