aboutsummaryrefslogtreecommitdiff
path: root/modules/system/quickshell/Clock.qml
blob: 0ec3933475deb86263603e82f82c4b43408c55f0 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import QtQuick
import QtQuick.Layouts
import Quickshell

Item {
    id: root
    width: clock.implicitWidth
    height: parent.height

    Text {
        id: clock
        anchors.verticalCenter: parent.verticalCenter
        color: Theme.text
        text: Qt.formatDateTime(new Date(), "ddd d MMM  HH:mm:ss")
        font {
            family: Theme.mainFont
            pixelSize: 13
            weight: Font.Medium
        }

        Timer {
            interval: 1000
            running: true
            repeat: true
            onTriggered: clock.text = Qt.formatDateTime(new Date(), "ddd d MMM  HH:mm:ss")
        }
    }

    MouseArea {
        anchors.fill: parent
        cursorShape: Qt.PointingHandCursor
        onClicked: GlobalState.toggle("NotificationHistory")
    }

    AnchoredPopup {
        popupName: "NotificationHistory"
        anchorWindow: barWindow
        anchorItem: root

        PopupCard {
            width: 360
            maxHeight: 520
            margins: 14

            RowLayout {
                Layout.fillWidth: true
                Layout.leftMargin: 4
                Layout.rightMargin: 4
                spacing: 8

                Text {
                    text: "Notifications"
                    color: Theme.text
                    font {
                        family: Theme.mainFont
                        pixelSize: 14
                        weight: Font.DemiBold
                    }
                }

                Item {
                    Layout.fillWidth: true
                }

                Text {
                    visible: GlobalState.notificationHistory.length > 0
                    text: "Clear"
                    color: clearArea.containsMouse ? Theme.text : Theme.textMuted
                    font {
                        family: Theme.mainFont
                        pixelSize: 12
                        weight: Font.Medium
                    }

                    MouseArea {
                        id: clearArea
                        anchors.fill: parent
                        hoverEnabled: true
                        cursorShape: Qt.PointingHandCursor
                        onClicked: GlobalState.clearNotificationHistory()
                    }
                }
            }

            Rectangle {
                Layout.fillWidth: true
                Layout.preferredHeight: 1
                color: Theme.border
            }

            Text {
                visible: GlobalState.notificationHistory.length === 0
                Layout.fillWidth: true
                Layout.topMargin: 20
                Layout.bottomMargin: 20
                horizontalAlignment: Text.AlignHCenter
                text: "No notifications"
                color: Theme.textMuted
                font {
                    family: Theme.mainFont
                    pixelSize: 13
                    weight: Font.Medium
                }
            }

            Repeater {
                model: GlobalState.notificationHistory

                delegate: Squircle {
                    id: historyItem
                    required property var modelData

                    Layout.fillWidth: true
                    Layout.preferredHeight: Math.max(64, historyLayout.implicitHeight + 20)
                    cornerRadius: 12
                    fillColor: historyHover.containsMouse ? Theme.surfaceHover : Theme.surface
                    strokeColor: Theme.border
                    strokeWidth: 1

                    MouseArea {
                        id: historyHover
                        anchors.fill: parent
                        hoverEnabled: true
                        acceptedButtons: Qt.NoButton
                    }

                    RowLayout {
                        id: historyLayout
                        anchors {
                            fill: parent
                            margins: 10
                        }
                        spacing: 10

                        IconCircle {
                            size: 32
                            source: "notifications"
                            active: false
                            Layout.alignment: Qt.AlignTop
                        }

                        ColumnLayout {
                            Layout.fillWidth: true
                            spacing: 2

                            RowLayout {
                                Layout.fillWidth: true

                                Text {
                                    Layout.fillWidth: true
                                    text: historyItem.modelData.nAppName || "Notification"
                                    color: Theme.textMuted
                                    elide: Text.ElideRight
                                    font {
                                        family: Theme.mainFont
                                        pixelSize: 11
                                        weight: Font.Medium
                                    }
                                }

                                Text {
                                    text: Qt.formatTime(historyItem.modelData.nTimestamp, "HH:mm")
                                    color: Theme.textPlaceholder
                                    font {
                                        family: Theme.mainFont
                                        pixelSize: 10
                                    }
                                }
                            }

                            Text {
                                visible: text !== ""
                                Layout.fillWidth: true
                                text: historyItem.modelData.nSummary || ""
                                color: Theme.text
                                elide: Text.ElideRight
                                maximumLineCount: 1
                                font {
                                    family: Theme.mainFont
                                    pixelSize: 13
                                    weight: Font.DemiBold
                                }
                            }

                            Text {
                                visible: text !== ""
                                Layout.fillWidth: true
                                text: historyItem.modelData.nBody || ""
                                color: Theme.textMuted
                                wrapMode: Text.WordWrap
                                maximumLineCount: 2
                                elide: Text.ElideRight
                                textFormat: Text.StyledText
                                font {
                                    family: Theme.mainFont
                                    pixelSize: 12
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}