Notification: adjust animation on action invoke

This commit is contained in:
Lysec
2026-02-10 16:54:42 +01:00
parent 2989f85d3b
commit 330df2b6e4
+31 -9
View File
@@ -145,9 +145,12 @@ Variants {
}
}
if (delegate?.animateOut) {
delegate.animateOut();
} else {
try {
if (delegate && typeof delegate.animateOut === "function" && !delegate.isRemoving) {
delegate.animateOut();
}
} catch (e) {
// Service fallback if delegate is already invalid
NotificationService.dismissActiveNotification(notificationId);
}
};
@@ -305,15 +308,16 @@ Variants {
onExited: card.hoverCount--
onClicked: mouse => {
if (mouse.button === Qt.RightButton) {
animateOut();
card.animateOut();
} else if (mouse.button === Qt.LeftButton) {
var actions = model.actionsJson ? JSON.parse(model.actionsJson) : [];
var hasDefault = actions.some(function (a) {
return a.identifier === "default";
});
if (hasDefault) {
animateOut();
NotificationService.invokeAction(notificationId, "default");
card.animateOut();
deferredActionTimer.actionId = "default";
deferredActionTimer.start();
}
}
}
@@ -378,6 +382,20 @@ Variants {
}
}
Timer {
id: deferredActionTimer
interval: 50
property string actionId: ""
property bool isHistoryRemoval: false
onTriggered: {
if (isHistoryRemoval) {
NotificationService.removeFromHistory(notificationId);
} else {
NotificationService.invokeAction(notificationId, actionId);
}
}
}
onIsRemovingChanged: {
if (isRemoving) {
removalTimer.start();
@@ -544,7 +562,10 @@ Variants {
outlined: false
implicitHeight: 24
onClicked: {
NotificationService.invokeAction(parent.parentNotificationId, actionData.identifier);
card.animateOut();
deferredActionTimer.actionId = actionData.identifier;
deferredActionTimer.isHistoryRemoval = false;
deferredActionTimer.start();
}
}
}
@@ -564,8 +585,9 @@ Variants {
anchors.rightMargin: Style.marginM
onClicked: {
animateOut();
NotificationService.removeFromHistory(model.id);
card.animateOut();
deferredActionTimer.isHistoryRemoval = true;
deferredActionTimer.start();
}
}
}