2026-01-19 16:56:11 +01:00
|
|
|
import QtQuick
|
2026-02-01 23:59:09 +01:00
|
|
|
import QtQuick.Layouts
|
2026-01-19 16:56:11 +01:00
|
|
|
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-26 18:20:36 +01:00
|
|
|
color: clickHandler.containsMouse ? Colors.primaryContainer : Colors.surfaceContainer
|
2026-01-19 16:56:11 +01:00
|
|
|
implicitWidth: root.implicitWidth + 20
|
|
|
|
|
implicitHeight: Settings.config.barHeight - 10
|
|
|
|
|
Item {
|
|
|
|
|
id: root
|
2026-01-21 18:11:12 +01:00
|
|
|
anchors.centerIn: parent
|
2026-01-19 16:56:11 +01:00
|
|
|
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;
|
|
|
|
|
}
|
2026-01-20 13:00:53 +01:00
|
|
|
implicitWidth: statusRow.implicitWidth
|
2026-01-21 18:11:12 +01:00
|
|
|
implicitHeight: statusRow.implicitHeight
|
2026-01-20 13:00:53 +01:00
|
|
|
|
2026-02-01 23:59:09 +01:00
|
|
|
RowLayout {
|
2026-01-21 15:38:17 +01:00
|
|
|
id: statusRow
|
2026-01-21 23:37:56 +01:00
|
|
|
spacing: 5
|
2026-01-21 18:11:12 +01:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2026-01-21 23:37:56 +01:00
|
|
|
property var combinedText: root.spotify != null ? root.spotify.trackArtist + " - " + root.spotify.trackTitle : ""
|
2026-01-21 15:38:17 +01:00
|
|
|
property var status: root.spotify != null ? !root.spotify.isPlaying ? "play_arrow" : "pause" : ""
|
|
|
|
|
CustomText {
|
|
|
|
|
id: mprisText
|
2026-02-01 23:59:09 +01:00
|
|
|
Layout.topMargin: 2
|
2026-01-21 15:38:17 +01:00
|
|
|
text: root.spotify != null ? parent.combinedText : ""
|
|
|
|
|
}
|
|
|
|
|
CustomIcon {
|
|
|
|
|
id: mprisStatus
|
2026-02-01 23:59:09 +01:00
|
|
|
Layout.topMargin: 2
|
2026-01-21 15:38:17 +01:00
|
|
|
text: root.spotify != null ? parent.status : ""
|
|
|
|
|
}
|
2026-01-19 16:56:11 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|