34 lines
1 KiB
QML
34 lines
1 KiB
QML
import QtQuick
|
|
import Quickshell.Services.Mpris
|
|
import "." as M
|
|
|
|
M.BarSection {
|
|
id: root
|
|
spacing: 4
|
|
visible: player !== null
|
|
tooltip: {
|
|
const p = root.player;
|
|
if (!p) return "";
|
|
const parts = [];
|
|
if (p.trackTitle) parts.push(p.trackTitle);
|
|
if (p.trackArtists?.length) parts.push(p.trackArtists.join(", "));
|
|
if (p.trackAlbum) parts.push(p.trackAlbum);
|
|
return parts.join("\n") || p.identity;
|
|
}
|
|
|
|
readonly property MprisPlayer player: Mpris.players.values[0] ?? null
|
|
readonly property bool playing: player?.playbackState === MprisPlaybackState.Playing
|
|
|
|
M.BarIcon {
|
|
icon: root.playing ? "\uF04B" : (root.player?.playbackState === MprisPlaybackState.Paused ? "\uDB80\uDFE4" : "\uDB81\uDCDB")
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
M.BarLabel {
|
|
label: root.player?.identity ?? ""
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
|
|
TapHandler {
|
|
onTapped: root.player?.togglePlaying()
|
|
}
|
|
}
|