aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/NotificationList.qml
blob: 9fe4328c9ba9f906fb7e5588f2212a3964528d82 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

import QtQuick

// The drawer's reserved notification space: a header with a History button,
// then the live queue, scrollable because the queue can hold 20 and the grid
// below is fixed. The grid owns its own position, so this space only fills
// what the grid leaves.
Item {
    id: list

    signal history

    Column {
        anchors.fill: parent
        spacing: 6

        Item {
            width: parent.width
            height: 28

            Text {
                anchors { left: parent.left; verticalCenter: parent.verticalCenter }
                text: "Notifications"
                font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4; bold: true }
                color: Theme.subtext
            }

            Text {
                id: historyBtn
                anchors { right: parent.right; verticalCenter: parent.verticalCenter }
                text: "History"
                font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
                color: historyArea.containsMouse ? Theme.accent : Theme.subtext

                MouseArea {
                    id: historyArea
                    anchors.fill: parent
                    anchors.margins: -6
                    hoverEnabled: true
                    cursorShape: Qt.PointingHandCursor
                    onClicked: list.history()
                }
            }
        }

        Flickable {
            id: flick
            width: parent.width
            height: parent.height - 34
            clip: true
            contentWidth: width
            contentHeight: col.implicitHeight
            boundsBehavior: Flickable.StopAtBounds

            Column {
                id: col
                width: flick.width
                spacing: 8

                Repeater {
                    model: Notify.queue
                    NotificationRow {
                        required property var modelData
                        width: col.width
                        notification: modelData
                        live: true
                    }
                }

                Text {
                    width: col.width
                    visible: Notify.queue.length === 0
                    text: "No notifications"
                    font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
                    color: Theme.overlay
                }
            }
        }
    }
}