blob: 865334444471efcbf011bec57be2d8a3e3da8495 (
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
import QtQuick
import Quickshell.Hyprland
import Quickshell.Io
import qs.Common
import qs.Modals.Common
import qs.Modules.Notifications.Center
import qs.Services
DankModal {
id: notificationModal
layerNamespace: "dms:notification-center-modal"
HyprlandFocusGrab {
windows: [notificationModal.contentWindow]
active: notificationModal.useHyprlandFocusGrab && notificationModal.shouldHaveFocus
}
property bool notificationModalOpen: false
property var notificationListRef: null
property var historyListRef: null
property int currentTab: 0
property var notificationHeaderRef: null
function show() {
notificationModalOpen = true;
currentTab = 0;
NotificationService.onOverlayOpen();
open();
modalKeyboardController.reset();
if (modalKeyboardController && notificationListRef) {
modalKeyboardController.listView = notificationListRef;
modalKeyboardController.rebuildFlatNavigation();
Qt.callLater(() => {
modalKeyboardController.keyboardNavigationActive = true;
modalKeyboardController.selectedFlatIndex = 0;
modalKeyboardController.updateSelectedIdFromIndex();
if (notificationListRef) {
notificationListRef.keyboardActive = true;
notificationListRef.currentIndex = 0;
}
modalKeyboardController.selectionVersion++;
modalKeyboardController.ensureVisible();
});
}
}
function hide() {
notificationModalOpen = false;
NotificationService.onOverlayClose();
close();
modalKeyboardController.reset();
}
function toggle() {
if (shouldBeVisible) {
hide();
} else {
show();
}
}
function clearAll() {
NotificationService.clearAllNotifications();
}
function dismissAllPopups() {
NotificationService.dismissAllPopups();
}
modalWidth: Math.min(500, screenWidth - 48)
modalHeight: Math.min(700, screenHeight * 0.85)
backgroundColor: Theme.withAlpha(Theme.surfaceContainer, Theme.popupTransparency)
visible: false
onBackgroundClicked: hide()
onOpened: () => {
Qt.callLater(() => modalFocusScope.forceActiveFocus());
}
onShouldBeVisibleChanged: shouldBeVisible => {
if (!shouldBeVisible) {
notificationModalOpen = false;
modalKeyboardController.reset();
NotificationService.onOverlayClose();
}
}
modalFocusScope.Keys.onPressed: event => {
if (event.key === Qt.Key_Escape) {
hide();
event.accepted = true;
return;
}
if (event.key === Qt.Key_Left) {
if (notificationHeaderRef && notificationHeaderRef.currentTab > 0) {
notificationHeaderRef.currentTab = 0;
event.accepted = true;
}
return;
}
if (event.key === Qt.Key_Right) {
if (notificationHeaderRef && notificationHeaderRef.currentTab === 0 && SettingsData.notificationHistoryEnabled) {
notificationHeaderRef.currentTab = 1;
event.accepted = true;
}
return;
}
if (currentTab === 1 && historyListRef) {
historyListRef.handleKey(event);
return;
}
modalKeyboardController.handleKey(event);
}
NotificationKeyboardController {
id: modalKeyboardController
listView: null
isOpen: notificationModal.notificationModalOpen
onClose: () => notificationModal.hide()
}
IpcHandler {
function open(): string {
notificationModal.show();
return "NOTIFICATION_MODAL_OPEN_SUCCESS";
}
function close(): string {
notificationModal.hide();
return "NOTIFICATION_MODAL_CLOSE_SUCCESS";
}
function toggle(): string {
notificationModal.toggle();
return "NOTIFICATION_MODAL_TOGGLE_SUCCESS";
}
function toggleDoNotDisturb(): string {
SessionData.setDoNotDisturb(!SessionData.doNotDisturb);
return "NOTIFICATION_MODAL_TOGGLE_DND_SUCCESS";
}
function getDoNotDisturb(): bool {
return SessionData.doNotDisturb;
}
function clearAll(): string {
notificationModal.clearAll();
return "NOTIFICATION_MODAL_CLEAR_ALL_SUCCESS";
}
function dismissAllPopups(): string {
notificationModal.dismissAllPopups();
return "NOTIFICATION_MODAL_DISMISS_ALL_POPUPS_SUCCESS";
}
target: "notifications"
}
content: Component {
Item {
id: notificationKeyHandler
LayoutMirroring.enabled: I18n.isRtl
LayoutMirroring.childrenInherit: true
anchors.fill: parent
Column {
anchors.fill: parent
anchors.margins: Theme.spacingL
spacing: Theme.spacingM
NotificationHeader {
id: notificationHeader
keyboardController: modalKeyboardController
onCurrentTabChanged: notificationModal.currentTab = currentTab
Component.onCompleted: notificationModal.notificationHeaderRef = notificationHeader
}
NotificationSettings {
id: notificationSettings
expanded: notificationHeader.showSettings
}
KeyboardNavigatedNotificationList {
id: notificationList
width: parent.width
height: parent.height - y
visible: notificationHeader.currentTab === 0
keyboardController: modalKeyboardController
Component.onCompleted: {
notificationModal.notificationListRef = notificationList;
if (modalKeyboardController) {
modalKeyboardController.listView = notificationList;
modalKeyboardController.rebuildFlatNavigation();
}
}
}
HistoryNotificationList {
id: historyList
width: parent.width
height: parent.height - y
visible: notificationHeader.currentTab === 1
Component.onCompleted: notificationModal.historyListRef = historyList
}
}
NotificationKeyboardHints {
id: keyboardHints
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: Theme.spacingL
showHints: notificationHeader.currentTab === 0 ? modalKeyboardController.showKeyboardHints : historyList.showKeyboardHints
}
}
}
}
|