From c95abd061904ea7300a6d6b5a72a80efe2d57b86 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 16 Jul 2025 15:10:08 +0800 Subject: mpris: directly use position / length instead of calculating a progress --- bar/Mpris.qml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'bar') diff --git a/bar/Mpris.qml b/bar/Mpris.qml index 31c984c..b213721 100644 --- a/bar/Mpris.qml +++ b/bar/Mpris.qml @@ -12,7 +12,6 @@ import qs.components Item { id: root readonly property MprisPlayer activePlayer: Services.Mpris.activePlayer - readonly property real progress: (activePlayer?.positionSupported && activePlayer?.lengthSupported && activePlayer.length > 0) ? activePlayer.position / activePlayer.length : 0 readonly property string cleanedTitle: cleanMusicTitle(activePlayer?.trackTitle) function cleanMusicTitle(title) { @@ -46,8 +45,8 @@ Item { handle: Item from: 0 - to: 1 - value: root.progress + to: activePlayer?.length || 0 + value: activePlayer?.position || 0 background: Rectangle { anchors.fill: parent color: WallustColors.color4 @@ -69,8 +68,8 @@ Item { } onMoved: { - if (Math.round(root.activePlayer.position) !== Math.round(value * root.activePlayer.length)) { - root.activePlayer.position = value * root.activePlayer.length; + if (Math.round(root.activePlayer.position) !== Math.round(value)) { + root.activePlayer.position = value; } } -- cgit v1.2.3