notif animations

This commit is contained in:
end-4
2025-04-20 00:48:43 +02:00
parent 905d26570f
commit 3096107d6b
6 changed files with 144 additions and 18 deletions
@@ -24,7 +24,7 @@ Item {
Behavior on implicitHeight {
enabled: enableAnimation
NumberAnimation {
duration: Appearance.animation.elementDecel.duration
duration: Appearance.animation.elementDecelFast.duration
easing.type: Appearance.animation.elementDecel.type
}
}
@@ -33,21 +33,31 @@ Item {
root.ready = true
}
function destroyWithAnimation() {
notificationRowWrapper.anchors.left = undefined
notificationRowWrapper.anchors.right = undefined
notificationRowWrapper.anchors.fill = undefined
notificationBackground.anchors.left = undefined
notificationBackground.anchors.right = undefined
notificationBackground.anchors.fill = undefined
notificationRowWrapper.x = width
notificationBackground.x = width
destroyTimer1.start()
function destroyWithAnimation(delay = 0) {
destroyTimer0.interval = delay
destroyTimer0.start()
}
Timer {
id: destroyTimer0
interval: 0
repeat: false
onTriggered: {
notificationRowWrapper.anchors.left = undefined
notificationRowWrapper.anchors.right = undefined
notificationRowWrapper.anchors.fill = undefined
notificationBackground.anchors.left = undefined
notificationBackground.anchors.right = undefined
notificationBackground.anchors.fill = undefined
notificationRowWrapper.x = width
notificationBackground.x = width
destroyTimer1.start()
}
}
Timer {
id: destroyTimer1
interval: Appearance.animation.elementDecel.duration / 2
interval: Appearance.animation.elementDecelFast.duration
repeat: false
onTriggered: {
notificationRowWrapper.anchors.top = undefined
@@ -59,7 +69,7 @@ Item {
Timer {
id: destroyTimer2
interval: Appearance.animation.elementDecel.duration
interval: Appearance.animation.elementDecelFast.duration
repeat: false
onTriggered: {
root.destroy()
@@ -102,7 +112,7 @@ Item {
Behavior on x {
enabled: enableAnimation
NumberAnimation {
duration: Appearance.animation.elementDecel.duration
duration: Appearance.animation.elementDecelFast.duration
easing.type: Appearance.animation.elementDecel.type
}
}
@@ -120,7 +130,7 @@ Item {
Behavior on x {
enabled: enableAnimation
NumberAnimation {
duration: Appearance.animation.elementDecel.duration
duration: Appearance.animation.elementDecelFast.duration
easing.type: Appearance.animation.elementDecel.type
}
}
@@ -70,6 +70,40 @@ Item {
}
}
// Placeholder when list is empty
Item {
anchors.fill: flickable
visible: opacity > 0
opacity: (root.notificationWidgetList.length === 0) ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
}
}
ColumnLayout {
anchors.centerIn: parent
spacing: 5
MaterialSymbol {
Layout.alignment: Qt.AlignHCenter
font.pixelSize: 55
color: Appearance.m3colors.m3outline
text: "notifications_active"
}
StyledText {
Layout.alignment: Qt.AlignHCenter
font.pixelSize: Appearance.font.pixelSize.normal
color: Appearance.m3colors.m3outline
horizontalAlignment: Text.AlignHCenter
text: "No notifications"
}
}
}
RowLayout {
id: statusRow
anchors.left: parent.left
@@ -92,5 +126,23 @@ Item {
}
}
}
Item { Layout.fillWidth: true }
NotificationStatusButton {
buttonIcon: "clear_all"
buttonText: "Clear"
onClicked: () => {
for (let i = notificationWidgetList.length - 1; i >= 0; i--) {
// for (let i = 0; i < notificationWidgetList.length; i++) {
const widget = notificationWidgetList[i];
if (widget && widget.notificationObject) {
widget.destroyWithAnimation();
}
}
notificationWidgetList = [];
Notifications.discardAll()
}
}
}
}
@@ -0,0 +1,55 @@
import "root:/modules/common"
import "root:/modules/common/widgets"
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Button {
id: button
property string buttonText: ""
property string buttonIcon: ""
implicitHeight: 30
implicitWidth: contentRowLayout.implicitWidth + 10 * 2
Behavior on implicitWidth {
SmoothedAnimation {
velocity: Appearance.animation.elementDecel.velocity
}
}
PointingHandInteraction {}
background: Rectangle {
anchors.fill: parent
radius: Appearance.rounding.full
color: (button.down) ? Appearance.colors.colLayer2Active : (button.hovered ? Appearance.colors.colLayer2Hover : Appearance.colors.colLayer2)
Behavior on color {
ColorAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
}
}
}
contentItem: RowLayout {
id: contentRowLayout
// anchors.centerIn: parent
anchors.right: parent.right
spacing: 0
MaterialSymbol {
text: buttonIcon
Layout.fillWidth: false
font.pixelSize: Appearance.font.pixelSize.larger
color: Appearance.colors.colOnLayer1
}
StyledText {
text: buttonText
Layout.fillWidth: false
font.pixelSize: Appearance.font.pixelSize.small
color: Appearance.colors.colOnLayer1
}
}
}
@@ -145,16 +145,16 @@ Item {
MaterialSymbol {
Layout.alignment: Qt.AlignHCenter
text: emptyPlaceholderIcon
font.pixelSize: 55
color: Appearance.m3colors.m3outline
text: emptyPlaceholderIcon
}
StyledText {
Layout.alignment: Qt.AlignHCenter
text: emptyPlaceholderText
font.pixelSize: Appearance.font.pixelSize.normal
color: Appearance.m3colors.m3outline
horizontalAlignment: Text.AlignHCenter
text: emptyPlaceholderText
}
}
}
@@ -130,7 +130,7 @@ Singleton {
function setActivePlayer(player: MprisPlayer) {
const targetPlayer = player ?? Mpris.players[0];
console.log(`setactive: ${targetPlayer} from ${activePlayer}`)
console.log(`[Mpris] Active player ${targetPlayer} << ${activePlayer}`)
if (targetPlayer && this.activePlayer) {
this.__reverse = Mpris.players.indexOf(targetPlayer) < Mpris.players.indexOf(this.activePlayer);
@@ -66,6 +66,15 @@ Singleton {
root.discard(id);
}
function discardAll() {
root.list = []
triggerListChange()
notifFileView.setText(JSON.stringify(root.list, null, 2))
notifServer.trackedNotifications.values.forEach((notif) => {
notif.dismiss()
})
}
function attemptInvokeAction(id, notifIdentifier) {
const notifServerIndex = notifServer.trackedNotifications.values.findIndex((notif) => notif.id === id);
if (notifServerIndex !== -1) {