mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-09 07:12:07 -04:00
osd: reverse media playback icons and handle screen changes
This commit is contained in:
@@ -16,18 +16,28 @@ DankOSD {
|
||||
autoHideInterval: 3000
|
||||
enableMouseInteraction: true
|
||||
|
||||
function getPlaybackIcon() {
|
||||
if (!player)
|
||||
return "music_note";
|
||||
property string _displayIcon: "music_note"
|
||||
|
||||
function updatePlaybackIcon() {
|
||||
if (!player) {
|
||||
_displayIcon = "music_note";
|
||||
iconDebounce.stop();
|
||||
return;
|
||||
}
|
||||
let icon = "music_note";
|
||||
switch (player.playbackState) {
|
||||
case MprisPlaybackState.Playing:
|
||||
return "play_arrow";
|
||||
icon = "pause";
|
||||
break;
|
||||
case MprisPlaybackState.Paused:
|
||||
case MprisPlaybackState.Stopped:
|
||||
return "pause";
|
||||
default:
|
||||
return "music_note";
|
||||
icon = "play_arrow";
|
||||
break;
|
||||
}
|
||||
if (icon === _displayIcon)
|
||||
return;
|
||||
iconDebounce.pendingIcon = icon;
|
||||
iconDebounce.restart();
|
||||
}
|
||||
|
||||
function togglePlaying() {
|
||||
@@ -38,6 +48,13 @@ DankOSD {
|
||||
|
||||
property bool _pendingShow: false
|
||||
|
||||
Timer {
|
||||
id: iconDebounce
|
||||
interval: 150
|
||||
property string pendingIcon: "music_note"
|
||||
onTriggered: root._displayIcon = pendingIcon
|
||||
}
|
||||
|
||||
Image {
|
||||
id: artPreloader
|
||||
source: TrackArtService._bgArtSource
|
||||
@@ -86,6 +103,7 @@ DankOSD {
|
||||
if (!SettingsData.osdMediaPlaybackEnabled)
|
||||
return;
|
||||
|
||||
root.updatePlaybackIcon();
|
||||
TrackArtService.loadArtwork(player.trackArtUrl);
|
||||
|
||||
if (!player.trackArtUrl || player.trackArtUrl === "") {
|
||||
@@ -202,7 +220,7 @@ DankOSD {
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: getPlaybackIcon()
|
||||
name: root._displayIcon
|
||||
size: Theme.iconSize
|
||||
color: playPauseButton.containsMouse ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
@@ -272,7 +290,7 @@ DankOSD {
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: getPlaybackIcon()
|
||||
name: root._displayIcon
|
||||
size: Theme.iconSize
|
||||
color: playPauseButtonVert.containsMouse ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user