2026-01-19 16:56:11 +01:00
|
|
|
import QtQuick
|
|
|
|
|
import Quickshell.Services.Mpris
|
|
|
|
|
import qs
|
|
|
|
|
import qs.settings
|
|
|
|
|
import qs.reusables
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: container
|
2026-01-19 17:04:51 +01:00
|
|
|
visible: root.spotify != null
|
2026-01-19 16:56:11 +01:00
|
|
|
radius: implicitHeight / 2
|
2026-01-20 12:46:38 +01:00
|
|
|
color: Colors.color8
|
2026-01-19 16:56:11 +01:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
implicitWidth: root.implicitWidth + 20
|
|
|
|
|
implicitHeight: Settings.config.barHeight - 10
|
|
|
|
|
Item {
|
|
|
|
|
id: root
|
|
|
|
|
property var spotify: root.getSpotify()
|
|
|
|
|
function getSpotify() {
|
|
|
|
|
for (let i = 0; i < Mpris.players.values.length; i++) {
|
2026-01-19 17:04:51 +01:00
|
|
|
if (Mpris.players.values[i].identity.toLowerCase() === "spotify") {
|
2026-01-19 16:56:11 +01:00
|
|
|
return Mpris.players.values[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
implicitWidth: mprisText.implicitWidth
|
|
|
|
|
CustomText {
|
|
|
|
|
id: mprisText
|
|
|
|
|
text: root.spotify != null ? root.spotify.trackArtist + " - " + root.spotify.trackTitle : ""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
id: clickHandler
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
hoverEnabled: true
|
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
onDoubleClicked: mouse => {
|
|
|
|
|
if (mouse.button == Qt.LeftButton) {
|
|
|
|
|
root.spotify.next();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onClicked: mouse => {
|
|
|
|
|
if (mouse.button == Qt.RightButton) {
|
|
|
|
|
root.spotify.togglePlaying();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|