Compare commits

...

2 Commits

Author SHA1 Message Date
e74c3ce04b fix mpris text 2026-02-12 19:21:28 +01:00
fcaf744efc fix mpris to fixed width 2026-02-12 19:00:34 +01:00

View File

@ -6,15 +6,13 @@ import qs.settings
import qs.reusables import qs.reusables
Rectangle { Rectangle {
id: container id: root
visible: root.spotify != null visible: root.spotify != null
radius: implicitHeight / 2 radius: implicitHeight / 2
color: clickHandler.containsMouse ? Colors.primaryContainer : Colors.surfaceContainer
implicitWidth: root.implicitWidth + 20
implicitHeight: Settings.config.barHeight - 10 implicitHeight: Settings.config.barHeight - 10
Item { color: clickHandler.containsMouse ? Colors.primary : Colors.surfaceContainer
id: root implicitWidth: statusRow.width + 20
anchors.centerIn: parent
property var spotify: root.getSpotify() property var spotify: root.getSpotify()
function getSpotify() { function getSpotify() {
for (let i = 0; i < Mpris.players.values.length; i++) { for (let i = 0; i < Mpris.players.values.length; i++) {
@ -24,27 +22,28 @@ Rectangle {
} }
return null; return null;
} }
implicitWidth: statusRow.implicitWidth
implicitHeight: statusRow.implicitHeight
RowLayout { RowLayout {
id: statusRow id: statusRow
spacing: 5 spacing: 5
anchors.verticalCenter: parent.verticalCenter anchors.centerIn: parent
property var combinedText: root.spotify != null ? root.spotify.trackArtist + " - " + root.spotify.trackTitle : "" property var combinedText: root.spotify != null ? root.spotify.trackArtist + " - " + root.spotify.trackTitle : ""
property var status: root.spotify != null ? !root.spotify.isPlaying ? "play_arrow" : "pause" : "" property var status: root.spotify != null ? !root.spotify.isPlaying ? "play_arrow" : "pause" : ""
CustomText { CustomText {
id: mprisText id: mprisText
Layout.maximumWidth: 300
Layout.topMargin: 2 Layout.topMargin: 2
text: root.spotify != null ? parent.combinedText : "" text: root.spotify != null ? parent.combinedText : ""
elide: Text.ElideRight
color: clickHandler.containsMouse ? Colors.onPrimaryColor : Colors.onSurfaceColor
} }
CustomIcon { CustomIcon {
id: mprisStatus id: mprisStatus
color: clickHandler.containsMouse ? Colors.onPrimaryColor : Colors.onSurfaceColor
Layout.topMargin: 2 Layout.topMargin: 2
text: root.spotify != null ? parent.status : "" text: root.spotify != null ? parent.status : ""
} }
} }
}
MouseArea { MouseArea {
id: clickHandler id: clickHandler
anchors.fill: parent anchors.fill: parent