From 7b25e6f3a79d9729c3851dbaf0540710126a5f81 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Tue, 15 Jul 2025 15:28:18 +0800 Subject: mpris: trackart mpris: animation --- bar/Mpris.qml | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/bar/Mpris.qml b/bar/Mpris.qml index 1f94e88..eca0091 100644 --- a/bar/Mpris.qml +++ b/bar/Mpris.qml @@ -1,6 +1,7 @@ -import QtQuick 2.15 -import QtQuick.Layouts 1.15 +import QtQuick +import QtQuick.Layouts import Quickshell +import Quickshell.Widgets import Quickshell.Services.Mpris import qs.services as Services import qs.config @@ -26,9 +27,12 @@ Item { return title.trim(); } - implicitWidth: rect.width - General.rectMargin / 1.25 + implicitWidth: activePlayer ? rect.width - General.rectMargin / 1.25 : 0 height: Bar.height + General.rectMargin / 1.5 + // TODO: after support for multiple players is added, this should be changed to if none exist/is active + opacity: activePlayer ? 1 : 0 + Rectangle { id: rect anchors.verticalCenter: parent.verticalCenter @@ -41,8 +45,14 @@ Item { id: layout anchors.centerIn: parent spacing: Bar.resourceIconTextSpacing / 1.5 - Icon { - text: root.state + // Icon { + // text: root.state + // } + Image { + source: activePlayer.trackArtUrl + fillMode: Image.PreserveAspectFit + Layout.preferredWidth: Bar.appIconSize + cache: true } IText { animate: true @@ -171,4 +181,17 @@ Item { } } } + + Behavior on opacity { + NumberAnimation { + duration: General.animateDuration / 4 + } + } + + Behavior on implicitWidth { + ISpringAnimation { + spring: General.springAnimationSpring * 2 + damping: General.springAnimationDamping * 1.3 + } + } } -- cgit v1.2.3