49 lines
1.2 KiB
QML
49 lines
1.2 KiB
QML
import QtQuick // for Text
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import Quickshell.Services.Mpris
|
|
import Quickshell.Widgets
|
|
|
|
Item {
|
|
id: media
|
|
height: 30
|
|
|
|
readonly property real textWidth: info.contentWidth + 10
|
|
|
|
ClippingWrapperRectangle {
|
|
radius: 5
|
|
anchors.fill: parent
|
|
Text {
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
id: info
|
|
|
|
text: {
|
|
let s = ''
|
|
let players = []
|
|
|
|
Mpris.players.values.forEach((p) => {
|
|
if(p.isPlaying) players.push(p)
|
|
})
|
|
|
|
if(players[0]?.trackTitle) {
|
|
s += players[0].trackTitle
|
|
}
|
|
if(players[0]?.trackAlbum) {
|
|
s += ' - ' + players[0].trackAlbum
|
|
}
|
|
if(players[0]?.trackArtist) {
|
|
s += ' - ' + players[0].trackArtist
|
|
}
|
|
|
|
media.visible = players.length > 0
|
|
|
|
return s
|
|
}
|
|
font.pointSize: 11
|
|
}
|
|
}
|
|
}
|