aboutsummaryrefslogtreecommitdiff
path: root/modules/system/quickshell/NotificationPopupList.qml
blob: 6b9280bd712517d72974143688c21d4b532944d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import QtQuick
import Quickshell
import Quickshell.Wayland

PanelWindow {
    id: root
    property var popupModel

    signal actionInvoked(int id, string identifier)
    signal replySent(int id, string text)
    signal dismissed(int id)
    signal activated(int id)
    signal hideRequested(int id)

    visible: popupList.count > 0

    anchors { top: true; right: true }
    WlrLayershell.margins.top: Theme.barHeight
    exclusionMode: ExclusionMode.Ignore
    color: "transparent"
    
    readonly property int edgeMargin: 12
    readonly property int animationSafeMargin: 80
    readonly property int popupWidth: 400

    implicitWidth: popupWidth + edgeMargin * 2 + animationSafeMargin
    implicitHeight: popupList.contentHeight + edgeMargin * 2

    WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand

    ListView {
        id: popupList
        anchors {
            top: parent.top
            right: parent.right
            topMargin: edgeMargin
            rightMargin: edgeMargin
        }

        width: popupWidth
        height: contentHeight
        spacing: 8
        model: root.popupModel
        interactive: false
        clip: false
        
        delegate: NotificationCard {
            onActionInvoked: (id, identifier) => root.actionInvoked(id, identifier)
            onReplySent: (id, text) => root.replySent(id, text)
            onDismissed: id => root.dismissed(id)
            onActivated: id => root.activated(id)
            onHideRequested: id => root.hideRequested(id)
        }

        add: Transition {
            ParallelAnimation {
                NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 250; easing.type: Easing.OutSine }
                NumberAnimation { property: "x"; from: popupWidth + edgeMargin; duration: 350; easing.type: Easing.OutBack }
            }
        }

        remove: Transition {
            ParallelAnimation {
                NumberAnimation { property: "opacity"; from: 1; to: 0; duration: 200; easing.type: Easing.InSine }
                NumberAnimation { property: "x"; to: popupWidth + edgeMargin; duration: 200; easing.type: Easing.InSine }
            }
        }

        displaced: Transition {
            NumberAnimation { properties: "x,y"; duration: 250; easing.type: Easing.OutSine }
        }
    }
}