From 5e0318651bbab26ba9811fd8c183096d78151489 Mon Sep 17 00:00:00 2001 From: Mengci Cai Date: Tue, 10 Mar 2026 09:59:04 +0800 Subject: [PATCH] fix: improve notification bubble panel hide animation Changed the bubble panel visibility logic to include a 400ms delay before hiding when there are no notifications. This prevents the panel from disappearing abruptly when the last bubble is removed. The QML ListView now includes a remove transition with smooth exit animation for bubbles. Added QTimer include for delayed hide functionality. Modified the ListView height calculation to use maximum of contentHeight and childrenRect.height to ensure proper layout during animations. Implemented a sequential animation for bubble removal with x-axis slide- out effect. Log: Improved notification bubble animations with smoother hide effects Influence: 1. Test notification bubble appearance and disappearance 2. Verify panel remains visible during bubble removal animations 3. Check that multiple bubbles animate correctly 4. Test edge cases with rapid notification additions/removals 5. Verify panel properly hides after all bubbles are removed 6. Test animation timing and smoothness PMS: BUG-284659 --- panels/notification/bubble/bubblepanel.cpp | 10 +++++++- panels/notification/bubble/package/main.qml | 26 ++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/panels/notification/bubble/bubblepanel.cpp b/panels/notification/bubble/bubblepanel.cpp index f9ecc9439..4a100d0d9 100644 --- a/panels/notification/bubble/bubblepanel.cpp +++ b/panels/notification/bubble/bubblepanel.cpp @@ -12,6 +12,7 @@ #include #include +#include namespace notification { Q_DECLARE_LOGGING_CATEGORY(notifyLog) @@ -110,7 +111,14 @@ void BubblePanel::onNotificationStateChanged(qint64 id, int processedType) void BubblePanel::onBubbleCountChanged() { bool isEmpty = m_bubbles->items().isEmpty(); - setVisible(!isEmpty && enabled()); + const bool visible = !isEmpty && enabled(); + if (!visible) { + QTimer::singleShot(400, this, [this]() { + setVisible(false); + }); + } else { + setVisible(visible); + } } void BubblePanel::addBubble(qint64 id) diff --git a/panels/notification/bubble/package/main.qml b/panels/notification/bubble/package/main.qml index 80ccac395..c948038b2 100644 --- a/panels/notification/bubble/package/main.qml +++ b/panels/notification/bubble/package/main.qml @@ -92,7 +92,7 @@ Window { ListView { id: bubbleView width: 360 - height: contentHeight + height: Math.max(contentHeight, childrenRect.height) anchors { right: parent.right bottom: parent.bottom @@ -128,6 +128,30 @@ Window { easing.type: Easing.OutExpo } } + + remove: Transition { + SequentialAnimation { + PropertyAction { + property: "ListView.delayRemove" + value: true + } + + ParallelAnimation { + NumberAnimation { + property: "x" + to: 360 + duration: 400 + easing.type: Easing.InExpo + } + } + + PropertyAction { + property: "ListView.delayRemove" + value: false + } + } + } + delegate: Bubble { width: 360 bubble: model