From 9d88d62201494e1beca7cf5ceb94d6788b2d3919 Mon Sep 17 00:00:00 2001 From: Damocles Date: Sun, 12 Apr 2026 17:48:59 +0200 Subject: [PATCH] bar icons: crossfade animation on icon change --- modules/BarIcon.qml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/BarIcon.qml b/modules/BarIcon.qml index 1a07d09..a9d0e89 100644 --- a/modules/BarIcon.qml +++ b/modules/BarIcon.qml @@ -8,8 +8,26 @@ Text { property string icon: "" property string tooltip: "" property bool _hovered: false + property string _displayIcon: icon + property string _pendingIcon: "" - text: icon + text: _displayIcon + + onIconChanged: { + if (_crossfade.running) { + _pendingIcon = icon; + } else { + _pendingIcon = icon; + _crossfade.start(); + } + } + + SequentialAnimation { + id: _crossfade + NumberAnimation { target: root; property: "opacity"; to: 0; duration: 60; easing.type: Easing.InQuad } + ScriptAction { script: root._displayIcon = root._pendingIcon } + NumberAnimation { target: root; property: "opacity"; to: 1; duration: 100; easing.type: Easing.OutQuad } + } color: M.Theme.base05 font.pixelSize: M.Theme.fontSize + 1 font.family: M.Theme.iconFontFamily