From e01096691fde987bac3bd316fe4036022ea65278 Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Wed, 27 Aug 2025 12:00:20 -0400 Subject: [PATCH] update mpris with slider --- modules/bar/components/Mpris.qml | 65 +++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/modules/bar/components/Mpris.qml b/modules/bar/components/Mpris.qml index 675a1b9..6ab1275 100644 --- a/modules/bar/components/Mpris.qml +++ b/modules/bar/components/Mpris.qml @@ -1,13 +1,17 @@ pragma ComponentBehavior: Bound +import qs.components import qs.config import qs.services import qs.widgets import QtQuick +import QtQuick.Layouts StyledButton { id: root + padding: 6 + onClicked: { if (!Mpris.active.canTogglePlaying) { return; @@ -19,29 +23,54 @@ StyledButton { } } - content: StyledText { - id: text - text: `${Mpris.active?.isPlaying ? "" : ""} ${Mpris.active?.trackTitle} - ${Mpris.active?.trackArtist}` + content: ColumnLayout { + id: content - font.pixelSize: Dimensions.mpris.fontSize + spacing: 0 - states: State { - name: "hovered" - when: root.containsMouse - PropertyChanges { - text { - color: Theme.palette.base300 + implicitWidth: text.width + implicitHeight: text.height + StyledText { + id: text + text: `${Mpris.active?.isPlaying ? "" : ""} ${Mpris.active?.trackTitle} - ${Mpris.active?.trackArtist}` + + font.pixelSize: Dimensions.mpris.fontSize + + states: State { + name: "hovered" + when: root.containsMouse + PropertyChanges { + text { + color: Theme.palette.primarycontent + } + } + } + transitions: Transition { + from: "" + to: "hovered" + reversible: true + ColorAnimation { + properties: "color" + duration: 100 + easing.type: Easing.InOutCubic } } } - transitions: Transition { - from: "" - to: "hovered" - reversible: true - ColorAnimation { - properties: "color" - duration: 200 - easing.type: Easing.InOutCubic + StyledSlider { + from: 0 + to: Mpris.active?.length ?? 0 + value: Mpris.active?.position + implicitHeight: 6 + Layout.fillWidth: true + onMoved: { + Mpris.active.position = value; + } + + Timer { + running: Mpris.active?.isPlaying + interval: 1000 + repeat: true + onTriggered: Mpris.active?.positionChanged() } } }