Changeset View
Changeset View
Standalone View
Standalone View
applets/taskmanager/package/contents/ui/ToolTipInstance.qml
Show All 37 Lines | 35 | Column { | |||
---|---|---|---|---|---|
38 | 38 | | |||
39 | spacing: units.smallSpacing | 39 | spacing: units.smallSpacing | ||
40 | 40 | | |||
41 | property string mprisSourceName: mpris2Source.sourceNameForLauncherUrl(toolTipDelegate.launcherUrl, isGroup ? AppPid : pidParent) | 41 | property string mprisSourceName: mpris2Source.sourceNameForLauncherUrl(toolTipDelegate.launcherUrl, isGroup ? AppPid : pidParent) | ||
42 | property var playerData: mprisSourceName != "" ? mpris2Source.data[mprisSourceName] : 0 | 42 | property var playerData: mprisSourceName != "" ? mpris2Source.data[mprisSourceName] : 0 | ||
43 | property bool hasPlayer: !!mprisSourceName && !!playerData | 43 | property bool hasPlayer: !!mprisSourceName && !!playerData | ||
44 | property bool playing: hasPlayer && playerData.PlaybackStatus === "Playing" | 44 | property bool playing: hasPlayer && playerData.PlaybackStatus === "Playing" | ||
45 | property bool canControl: hasPlayer && playerData.CanControl | 45 | property bool canControl: hasPlayer && playerData.CanControl | ||
46 | property bool canPlay: hasPlayer && playerData.CanPlay | ||||
47 | property bool canPause: hasPlayer && playerData.CanPause | ||||
46 | property bool canGoBack: hasPlayer && playerData.CanGoPrevious | 48 | property bool canGoBack: hasPlayer && playerData.CanGoPrevious | ||
47 | property bool canGoNext: hasPlayer && playerData.CanGoNext | 49 | property bool canGoNext: hasPlayer && playerData.CanGoNext | ||
48 | property bool canRaise: hasPlayer && playerData.CanRaise | 50 | property bool canRaise: hasPlayer && playerData.CanRaise | ||
49 | property var currentMetadata: hasPlayer ? playerData.Metadata : ({}) | 51 | property var currentMetadata: hasPlayer ? playerData.Metadata : ({}) | ||
50 | 52 | | |||
51 | readonly property string track: { | 53 | readonly property string track: { | ||
52 | var xesamTitle = currentMetadata["xesam:title"] | 54 | var xesamTitle = currentMetadata["xesam:title"] | ||
53 | if (xesamTitle) { | 55 | if (xesamTitle) { | ||
▲ Show 20 Lines • Show All 279 Lines • ▼ Show 20 Line(s) | 330 | PlasmaCore.IconItem { | |||
333 | source: LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward" | 335 | source: LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward" | ||
334 | animated: false | 336 | animated: false | ||
335 | } | 337 | } | ||
336 | } | 338 | } | ||
337 | 339 | | |||
338 | MouseArea { | 340 | MouseArea { | ||
339 | height: units.iconSizes.medium | 341 | height: units.iconSizes.medium | ||
340 | width: height | 342 | width: height | ||
343 | enabled: playing ? canPause : canPlay | ||||
341 | 344 | | |||
342 | acceptedButtons: Qt.LeftButton | 345 | acceptedButtons: Qt.LeftButton | ||
343 | hoverEnabled: true | 346 | hoverEnabled: true | ||
344 | onClicked: mpris2Source.playPause(mprisSourceName) | 347 | onClicked: { | ||
348 | if (!playing) { | ||||
349 | mpris2Source.play(mprisSourceName); | ||||
broulik: Same as with media controller, please do not mix playPause with manual play+pause, it makes the… | |||||
350 | } else { | ||||
351 | mpris2Source.pause(mprisSourceName); | ||||
352 | } | ||||
353 | } | ||||
345 | 354 | | |||
346 | PlasmaCore.IconItem { | 355 | PlasmaCore.IconItem { | ||
347 | anchors.fill: parent | 356 | anchors.fill: parent | ||
357 | enabled: playing ? canPause : canPlay | ||||
348 | active: parent.containsMouse | 358 | active: parent.containsMouse | ||
349 | 359 | | |||
350 | source: playing ? "media-playback-pause" : "media-playback-start" | 360 | source: playing ? "media-playback-pause" : "media-playback-start" | ||
351 | animated: false | 361 | animated: false | ||
352 | } | 362 | } | ||
353 | } | 363 | } | ||
354 | 364 | | |||
355 | MouseArea { | 365 | MouseArea { | ||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |
Same as with media controller, please do not mix playPause with manual play+pause, it makes the code convoluted and hard to follow, just manually do it then.