Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/package/contents/ui/previews/ToolTipInstance.qml
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 39 | Column { | |||
---|---|---|---|---|---|
46 | 46 | | |||
47 | property int appPid: (typeof model !== 'undefined') && (typeof model.AppPid !== 'undefined') ? AppPid : -1 | 47 | property int appPid: (typeof model !== 'undefined') && (typeof model.AppPid !== 'undefined') ? AppPid : -1 | ||
48 | property int itemIndex: (typeof model !== 'undefined') && (typeof model.index !== 'undefined') ? index : 0 | 48 | property int itemIndex: (typeof model !== 'undefined') && (typeof model.index !== 'undefined') ? index : 0 | ||
49 | property int virtualDesktop: (typeof model !== 'undefined') && (typeof model.VirtualDesktop !== 'undefined') ? VirtualDesktop : 0 | 49 | property int virtualDesktop: (typeof model !== 'undefined') && (typeof model.VirtualDesktop !== 'undefined') ? VirtualDesktop : 0 | ||
50 | property var activities : (typeof model !== 'undefined') && (typeof model.Activities !== 'undefined') ? Activities : [] | 50 | property var activities : (typeof model !== 'undefined') && (typeof model.Activities !== 'undefined') ? Activities : [] | ||
51 | 51 | | |||
52 | spacing: units.smallSpacing | 52 | spacing: units.smallSpacing | ||
53 | 53 | | |||
54 | property string mprisSourceName: mpris2Source.sourceNameForLauncherUrl(toolTipDelegate.launcherUrl, isGroup ? appPid : pidParent) | 54 | readonly property string mprisSourceName: mpris2Source.sourceNameForLauncherUrl(toolTipDelegate.launcherUrl, isGroup ? appPid : pidParent) | ||
55 | property var playerData: mprisSourceName != "" ? mpris2Source.data[mprisSourceName] : 0 | 55 | readonly property var playerData: mprisSourceName != "" ? mpris2Source.data[mprisSourceName] : 0 | ||
56 | property bool hasPlayer: !!mprisSourceName && !!playerData | 56 | readonly property bool hasPlayer: !!mprisSourceName && !!playerData | ||
57 | property bool playing: hasPlayer && playerData.PlaybackStatus === "Playing" | 57 | readonly property bool playing: hasPlayer && playerData.PlaybackStatus === "Playing" | ||
58 | property bool canControl: hasPlayer && playerData.CanControl | 58 | readonly property bool canControl: hasPlayer && playerData.CanControl | ||
59 | property bool canGoBack: hasPlayer && playerData.CanGoPrevious | 59 | readonly property bool canPlay: hasPlayer && playerData.CanPlay | ||
60 | property bool canGoNext: hasPlayer && playerData.CanGoNext | 60 | readonly property bool canPause: hasPlayer && playerData.CanPause | ||
61 | property bool canRaise: hasPlayer && playerData.CanRaise | 61 | readonly property bool canGoBack: hasPlayer && playerData.CanGoPrevious | ||
62 | property var currentMetadata: hasPlayer ? playerData.Metadata : ({}) | 62 | readonly property bool canGoNext: hasPlayer && playerData.CanGoNext | ||
63 | readonly property bool canRaise: hasPlayer && playerData.CanRaise | ||||
64 | readonly property var currentMetadata: hasPlayer ? playerData.Metadata : ({}) | ||||
63 | 65 | | |||
64 | readonly property string track: { | 66 | readonly property string track: { | ||
65 | var xesamTitle = currentMetadata["xesam:title"] | 67 | var xesamTitle = currentMetadata["xesam:title"] | ||
66 | if (xesamTitle) { | 68 | if (xesamTitle) { | ||
67 | return xesamTitle; | 69 | return xesamTitle; | ||
68 | } | 70 | } | ||
69 | // if no track title is given, print out the file name | 71 | // if no track title is given, print out the file name | ||
70 | var xesamUrl = currentMetadata["xesam:url"] ? currentMetadata["xesam:url"].toString() : "" | 72 | var xesamUrl = currentMetadata["xesam:url"] ? currentMetadata["xesam:url"].toString() : "" | ||
71 | if (!xesamUrl) { | 73 | if (!xesamUrl) { | ||
72 | return ""; | 74 | return ""; | ||
73 | } | 75 | } | ||
74 | var lastSlashPos = xesamUrl.lastIndexOf('/') | 76 | var lastSlashPos = xesamUrl.lastIndexOf('/') | ||
75 | if (lastSlashPos < 0) { | 77 | if (lastSlashPos < 0) { | ||
76 | return ""; | 78 | return ""; | ||
77 | } | 79 | } | ||
78 | var lastUrlPart = xesamUrl.substring(lastSlashPos + 1) | 80 | var lastUrlPart = xesamUrl.substring(lastSlashPos + 1) | ||
79 | return decodeURIComponent(lastUrlPart); | 81 | return decodeURIComponent(lastUrlPart); | ||
80 | } | 82 | } | ||
81 | readonly property string artist: currentMetadata["xesam:artist"] || "" | 83 | readonly property string artist: currentMetadata["xesam:artist"] || "" | ||
82 | readonly property string albumArt: currentMetadata["mpris:artUrl"] || "" | 84 | readonly property string albumArt: currentMetadata["mpris:artUrl"] || "" | ||
83 | 85 | | |||
84 | // | 86 | // | ||
85 | function containsMouse() { | 87 | function containsMouse() { | ||
86 | return area1.containsMouse || area2.containsMouse | 88 | return closeButton.hovered || area2.containsMouse | ||
87 | || (playbackLoader.active && playbackLoader.item.containsMouse()); | 89 | || (playbackLoader.active && playbackLoader.item.containsMouse()); | ||
88 | } | 90 | } | ||
89 | 91 | | |||
90 | function isTaskActive() { | 92 | function isTaskActive() { | ||
91 | return (isGroup ? isActive : (parentTask ? parentTask.isActive : false)); | 93 | return (isGroup ? isActive : (parentTask ? parentTask.isActive : false)); | ||
92 | } | 94 | } | ||
93 | 95 | | |||
94 | // launcher icon + text labels + close button | 96 | // launcher icon + text labels + close button | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 143 | PlasmaExtras.Heading { | |||
146 | elide: Text.ElideRight | 148 | elide: Text.ElideRight | ||
147 | text: isWin ? generateSubText() : "" | 149 | text: isWin ? generateSubText() : "" | ||
148 | textFormat: Text.PlainText | 150 | textFormat: Text.PlainText | ||
149 | opacity: 0.6 | 151 | opacity: 0.6 | ||
150 | visible: text !== "" | 152 | visible: text !== "" | ||
151 | } | 153 | } | ||
152 | } | 154 | } | ||
153 | // close button | 155 | // close button | ||
154 | MouseArea { | 156 | PlasmaComponents.ToolButton { | ||
155 | id: area1 | 157 | id: closeButton | ||
156 | Layout.alignment: Qt.AlignRight | Qt.AlignTop | 158 | Layout.alignment: Qt.AlignRight | Qt.AlignTop | ||
157 | | ||||
158 | height: units.iconSizes.smallMedium | | |||
159 | width: height | | |||
160 | | ||||
161 | visible: isWin && !hideCloseButtons | 159 | visible: isWin && !hideCloseButtons | ||
162 | 160 | iconSource: "window-close" | |||
mvourlakos: This needs also the !hideCloseButtons | |||||
163 | acceptedButtons: Qt.LeftButton | | |||
164 | hoverEnabled: true | | |||
165 | onClicked: { | 161 | onClicked: { | ||
166 | //NOTE: compatibility with plasma 5.8 | 162 | backend.cancelHighlightWindows(); | ||
167 | if (backend.cancelHighlightWindows) | 163 | tasksModel.requestClose(submodelIndex); | ||
168 | backend.cancelHighlightWindows() | | |||
169 | | ||||
170 | tasksModel.requestClose(submodelIndex) | | |||
171 | } | | |||
172 | onContainsMouseChanged: mainToolTip.mouseIsInside(); | | |||
173 | | ||||
174 | PlasmaCore.IconItem { | | |||
175 | anchors.fill: parent | | |||
176 | active: parent.containsMouse | | |||
177 | | ||||
178 | source: "window-close" | | |||
179 | animated: false | | |||
180 | } | 164 | } | ||
165 | onHoveredChanged: mainToolTip.mouseIsInside() | ||||
181 | } | 166 | } | ||
182 | } | 167 | } | ||
183 | 168 | | |||
184 | // thumbnail container | 169 | // thumbnail container | ||
185 | Item { | 170 | Item { | ||
186 | id: thumbnail | 171 | id: thumbnail | ||
187 | width: header.width | 172 | width: header.width | ||
188 | // similar to 0.5625 = 1 / (16:9) as most screens are | 173 | // similar to 0.5625 = 1 / (16:9) as most screens are | ||
189 | // round necessary, otherwise shadow mask for players has gap! | 174 | // round necessary, otherwise shadow mask for players has gap! | ||
190 | height: Math.round(0.5 * width) + (!winTitle.visible? winTitle.height : 0) | 175 | height: Math.round(0.5 * width) + (!winTitle.visible? Math.round(winTitle.height) : 0) | ||
I still don't know why Plasma ToolTip doesn't need this. But it is needed here. trmdi: I still don't know why Plasma ToolTip doesn't need this. But it is needed here. | |||||
191 | anchors.horizontalCenter: parent.horizontalCenter | 176 | anchors.horizontalCenter: parent.horizontalCenter | ||
192 | 177 | | |||
193 | visible: isWin | 178 | visible: isWin | ||
194 | 179 | | |||
195 | Item { | 180 | Item { | ||
196 | id: thumbnailSourceItem | 181 | id: thumbnailSourceItem | ||
197 | anchors.fill: parent | 182 | anchors.fill: parent | ||
198 | anchors.bottomMargin: 2 | 183 | anchors.bottomMargin: 2 | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 266 | Item { | |||
289 | // id: raisePlayerArea | 274 | // id: raisePlayerArea | ||
290 | // anchors.fill: parent | 275 | // anchors.fill: parent | ||
291 | 276 | | |||
292 | // visible: !isWin || !windows[0] && canRaise | 277 | // visible: !isWin || !windows[0] && canRaise | ||
293 | // onClicked: mpris2Source.raise(mprisSourceName) | 278 | // onClicked: mpris2Source.raise(mprisSourceName) | ||
294 | // } | 279 | // } | ||
295 | 280 | | |||
296 | function containsMouse() { | 281 | function containsMouse() { | ||
297 | return area3.containsMouse || area4.containsMouse || area5.containsMouse || area6.containsMouse; | 282 | return area3.containsMouse || canGoBackButton.hovered || playingButton.hovered || canGoNextButton.hovered; | ||
298 | } | 283 | } | ||
299 | 284 | | |||
300 | Item { | 285 | Item { | ||
301 | id: playerControlsFrostedGlass | 286 | id: playerControlsFrostedGlass | ||
302 | anchors.fill: parent | 287 | anchors.fill: parent | ||
303 | visible: false // OpacityMask would render it | 288 | visible: false // OpacityMask would render it | ||
304 | 289 | | |||
305 | Rectangle { | 290 | Rectangle { | ||
Show All 37 Lines | 321 | RowLayout { | |||
343 | spacing: 0 | 328 | spacing: 0 | ||
344 | enabled: canControl | 329 | enabled: canControl | ||
345 | 330 | | |||
346 | ColumnLayout { | 331 | ColumnLayout { | ||
347 | Layout.margins: 2 | 332 | Layout.margins: 2 | ||
348 | Layout.fillWidth: true | 333 | Layout.fillWidth: true | ||
349 | spacing: 0 | 334 | spacing: 0 | ||
350 | 335 | | |||
351 | PlasmaExtras.Heading { | 336 | PlasmaComponents.Label { | ||
352 | Layout.fillWidth: true | 337 | Layout.fillWidth: true | ||
353 | level: 5 | | |||
354 | lineHeight: 1 | 338 | lineHeight: 1 | ||
355 | maximumLineCount: artistText.visible? 1 : 2 | 339 | maximumLineCount: artistText.visible? 1 : 2 | ||
356 | wrapMode: artistText.visible? Text.NoWrap : Text.Wrap | 340 | wrapMode: artistText.visible? Text.NoWrap : Text.Wrap | ||
357 | elide: Text.ElideRight | 341 | elide: Text.ElideRight | ||
358 | text: track || "" | 342 | text: track || "" | ||
359 | font.weight: Font.Bold | | |||
360 | } | 343 | } | ||
361 | 344 | | |||
362 | PlasmaExtras.Heading { | 345 | PlasmaExtras.DescriptiveLabel { | ||
363 | id: artistText | 346 | id: artistText | ||
364 | Layout.fillWidth: true | 347 | Layout.fillWidth: true | ||
365 | level: 5 | | |||
366 | wrapMode: Text.NoWrap | 348 | wrapMode: Text.NoWrap | ||
367 | lineHeight: 1 | 349 | lineHeight: 1 | ||
368 | elide: Text.ElideRight | 350 | elide: Text.ElideRight | ||
369 | text: artist || "" | 351 | text: artist || "" | ||
370 | visible: text != "" | 352 | visible: text != "" | ||
371 | opacity: 0.75 | 353 | font.pointSize: theme.smallestFont.pointSize | ||
372 | } | 354 | } | ||
373 | } | 355 | } | ||
374 | 356 | | |||
375 | MouseArea { | 357 | PlasmaComponents.ToolButton { | ||
376 | id: area4 | 358 | id: canGoBackButton | ||
377 | | ||||
378 | height: units.iconSizes.smallMedium | | |||
379 | width: height | | |||
380 | | ||||
381 | acceptedButtons: Qt.LeftButton | | |||
382 | hoverEnabled: true | | |||
383 | onClicked: mpris2Source.goPrevious(mprisSourceName) | | |||
384 | onContainsMouseChanged: mainToolTip.mouseIsInside(); | | |||
385 | | ||||
386 | PlasmaCore.IconItem { | | |||
387 | anchors.fill: parent | | |||
388 | enabled: canGoBack | 359 | enabled: canGoBack | ||
389 | active: parent.containsMouse | 360 | iconSource: LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward" | ||
390 | 361 | onClicked: mpris2Source.goPrevious(mprisSourceName) | |||
391 | source: LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward" | 362 | onHoveredChanged: mainToolTip.mouseIsInside() | ||
392 | animated: false | | |||
393 | } | | |||
394 | } | 363 | } | ||
395 | 364 | | |||
396 | MouseArea { | 365 | PlasmaComponents.ToolButton { | ||
397 | id: area5 | 366 | id: playingButton | ||
398 | 367 | enabled: playing ? canPause : canPlay | |||
399 | height: units.iconSizes.medium | 368 | iconSource: playing ? "media-playback-pause" : "media-playback-start" | ||
400 | width: height | 369 | onClicked: { | ||
401 | 370 | if (!playing) { | |||
402 | acceptedButtons: Qt.LeftButton | 371 | mpris2Source.play(mprisSourceName); | ||
403 | hoverEnabled: true | 372 | } else { | ||
404 | onClicked: mpris2Source.playPause(mprisSourceName) | 373 | mpris2Source.pause(mprisSourceName); | ||
405 | onContainsMouseChanged: mainToolTip.mouseIsInside(); | | |||
406 | | ||||
407 | PlasmaCore.IconItem { | | |||
408 | anchors.fill: parent | | |||
409 | active: parent.containsMouse | | |||
410 | | ||||
411 | source: playing ? "media-playback-pause" : "media-playback-start" | | |||
412 | animated: false | | |||
413 | } | 374 | } | ||
414 | } | 375 | } | ||
376 | onHoveredChanged: mainToolTip.mouseIsInside() | ||||
377 | } | ||||
415 | 378 | | |||
416 | MouseArea { | 379 | PlasmaComponents.ToolButton { | ||
417 | id: area6 | 380 | id: canGoNextButton | ||
418 | | ||||
419 | height: units.iconSizes.smallMedium | | |||
420 | width: height | | |||
421 | | ||||
422 | acceptedButtons: Qt.LeftButton | | |||
423 | hoverEnabled: true | | |||
424 | onClicked: mpris2Source.goNext(mprisSourceName) | | |||
425 | onContainsMouseChanged: mainToolTip.mouseIsInside(); | | |||
426 | | ||||
427 | PlasmaCore.IconItem { | | |||
428 | anchors.fill: parent | | |||
429 | enabled: canGoNext | 381 | enabled: canGoNext | ||
430 | active: parent.containsMouse | 382 | iconSource: LayoutMirroring.enabled ? "media-skip-backward" : "media-skip-forward" | ||
431 | 383 | onClicked: mpris2Source.goNext(mprisSourceName) | |||
432 | source: LayoutMirroring.enabled ? "media-skip-backward" : "media-skip-forward" | 384 | onHoveredChanged: mainToolTip.mouseIsInside() | ||
433 | animated: false | | |||
434 | } | | |||
435 | } | 385 | } | ||
386 | | ||||
436 | } | 387 | } | ||
437 | } | 388 | } | ||
438 | } | 389 | } | ||
439 | 390 | | |||
440 | //active window line | 391 | //active window line | ||
441 | Rectangle{ | 392 | Rectangle{ | ||
442 | width: parent.width | 393 | width: parent.width | ||
443 | height: 2 | 394 | height: 2 | ||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |
This needs also the !hideCloseButtons