summaryrefslogtreecommitdiff
path: root/raveos-hyprland-theme/theme-data/dms/Modules/Notifications/Center/NotificationSettings.qml
blob: 97364c7c1ecbdb4844840249ced4599a33d401d3 (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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
import QtQuick
import qs.Common
import qs.Widgets

Rectangle {
    id: root

    property bool expanded: false
    property real maxAllowedHeight: 0
    readonly property real naturalContentHeight: contentColumn.height + Theme.spacingL * 2

    width: parent.width
    height: expanded ? (maxAllowedHeight > 0 ? Math.min(naturalContentHeight, maxAllowedHeight) : naturalContentHeight) : 0
    visible: expanded
    clip: true
    radius: Theme.cornerRadius
    color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.3)
    border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.1)
    border.width: 1

    Behavior on height {
        NumberAnimation {
            duration: Theme.shortDuration
            easing.type: Theme.emphasizedEasing
        }
    }

    opacity: expanded ? 1 : 0
    Behavior on opacity {
        NumberAnimation {
            duration: Theme.shortDuration
            easing.type: Theme.emphasizedEasing
        }
    }

    readonly property var timeoutOptions: [
        {
            "text": I18n.tr("Never"),
            "value": 0
        },
        {
            "text": I18n.tr("1 second"),
            "value": 1000
        },
        {
            "text": I18n.tr("3 seconds"),
            "value": 3000
        },
        {
            "text": I18n.tr("5 seconds"),
            "value": 5000
        },
        {
            "text": I18n.tr("8 seconds"),
            "value": 8000
        },
        {
            "text": I18n.tr("10 seconds"),
            "value": 10000
        },
        {
            "text": I18n.tr("15 seconds"),
            "value": 15000
        },
        {
            "text": I18n.tr("30 seconds"),
            "value": 30000
        },
        {
            "text": I18n.tr("1 minute"),
            "value": 60000
        },
        {
            "text": I18n.tr("2 minutes"),
            "value": 120000
        },
        {
            "text": I18n.tr("5 minutes"),
            "value": 300000
        },
        {
            "text": I18n.tr("10 minutes"),
            "value": 600000
        }
    ]

    function getTimeoutText(value) {
        if (value === undefined || value === null || isNaN(value)) {
            return I18n.tr("5 seconds");
        }

        for (let i = 0; i < timeoutOptions.length; i++) {
            if (timeoutOptions[i].value === value) {
                return timeoutOptions[i].text;
            }
        }
        if (value === 0) {
            return I18n.tr("Never");
        }
        if (value < 1000) {
            return value + "ms";
        }
        if (value < 60000) {
            return Math.round(value / 1000) + " " + I18n.tr("seconds");
        }
        return Math.round(value / 60000) + " " + I18n.tr("minutes");
    }

    Flickable {
        id: settingsFlickable
        anchors.fill: parent
        contentHeight: contentColumn.height + Theme.spacingL * 2
        clip: true
        flickableDirection: Flickable.VerticalFlick
        boundsBehavior: Flickable.DragAndOvershootBounds
        interactive: root.naturalContentHeight > root.height

        Column {
            id: contentColumn
            anchors.top: parent.top
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.margins: Theme.spacingL
            spacing: Theme.spacingM

        StyledText {
            text: I18n.tr("Notification Settings")
            font.pixelSize: Theme.fontSizeMedium
            font.weight: Font.Bold
            color: Theme.surfaceText
        }

        Item {
            width: parent.width
            height: Math.max(dndRow.implicitHeight, dndToggle.implicitHeight) + Theme.spacingS

            Row {
                id: dndRow
                anchors.left: parent.left
                anchors.verticalCenter: parent.verticalCenter
                spacing: Theme.spacingM

                DankIcon {
                    name: SessionData.doNotDisturb ? "notifications_off" : "notifications"
                    size: Theme.iconSizeSmall
                    color: SessionData.doNotDisturb ? Theme.error : Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }

                StyledText {
                    text: I18n.tr("Do Not Disturb")
                    font.pixelSize: Theme.fontSizeSmall
                    color: Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }
            }

            DankToggle {
                id: dndToggle
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                checked: SessionData.doNotDisturb
                onToggled: SessionData.setDoNotDisturb(!SessionData.doNotDisturb)
            }
        }

        Rectangle {
            width: parent.width
            height: 1
            color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.1)
        }

        StyledText {
            text: I18n.tr("Notification Timeouts")
            font.pixelSize: Theme.fontSizeSmall
            font.weight: Font.Medium
            color: Theme.surfaceVariantText
        }

        DankDropdown {
            text: I18n.tr("Low Priority")
            description: I18n.tr("Timeout for low priority notifications")
            currentValue: getTimeoutText(SettingsData.notificationTimeoutLow)
            options: timeoutOptions.map(opt => opt.text)
            onValueChanged: value => {
                for (let i = 0; i < timeoutOptions.length; i++) {
                    if (timeoutOptions[i].text === value) {
                        SettingsData.set("notificationTimeoutLow", timeoutOptions[i].value);
                        break;
                    }
                }
            }
        }

        DankDropdown {
            text: I18n.tr("Normal Priority")
            description: I18n.tr("Timeout for normal priority notifications")
            currentValue: getTimeoutText(SettingsData.notificationTimeoutNormal)
            options: timeoutOptions.map(opt => opt.text)
            onValueChanged: value => {
                for (let i = 0; i < timeoutOptions.length; i++) {
                    if (timeoutOptions[i].text === value) {
                        SettingsData.set("notificationTimeoutNormal", timeoutOptions[i].value);
                        break;
                    }
                }
            }
        }

        DankDropdown {
            text: I18n.tr("Critical Priority")
            description: I18n.tr("Timeout for critical priority notifications")
            currentValue: getTimeoutText(SettingsData.notificationTimeoutCritical)
            options: timeoutOptions.map(opt => opt.text)
            onValueChanged: value => {
                for (let i = 0; i < timeoutOptions.length; i++) {
                    if (timeoutOptions[i].text === value) {
                        SettingsData.set("notificationTimeoutCritical", timeoutOptions[i].value);
                        break;
                    }
                }
            }
        }

        Rectangle {
            width: parent.width
            height: 1
            color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.1)
        }

        Item {
            width: parent.width
            height: Math.max(overlayRow.implicitHeight, overlayToggle.implicitHeight) + Theme.spacingS

            Row {
                id: overlayRow
                anchors.left: parent.left
                anchors.right: overlayToggle.left
                anchors.rightMargin: Theme.spacingM
                anchors.verticalCenter: parent.verticalCenter
                spacing: Theme.spacingM

                DankIcon {
                    name: "notifications_active"
                    size: Theme.iconSizeSmall
                    color: SettingsData.notificationOverlayEnabled ? Theme.primary : Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }

                Column {
                    spacing: 2
                    anchors.verticalCenter: parent.verticalCenter
                    width: overlayRow.width - Theme.iconSizeSmall - Theme.spacingM

                    StyledText {
                        width: parent.width
                        text: I18n.tr("Notification Overlay")
                        font.pixelSize: Theme.fontSizeSmall
                        color: Theme.surfaceText
                        wrapMode: Text.Wrap
                    }

                    StyledText {
                        width: parent.width
                        text: I18n.tr("Display all priorities over fullscreen apps")
                        font.pixelSize: Theme.fontSizeSmall - 1
                        color: Theme.surfaceVariantText
                        wrapMode: Text.Wrap
                    }
                }
            }

            DankToggle {
                id: overlayToggle
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                checked: SettingsData.notificationOverlayEnabled
                onToggled: toggled => SettingsData.set("notificationOverlayEnabled", toggled)
            }
        }

        Item {
            width: parent.width
            height: Math.max(privacyRow.implicitHeight, privacyToggle.implicitHeight) + Theme.spacingS

            Row {
                id: privacyRow
                anchors.left: parent.left
                anchors.right: privacyToggle.left
                anchors.rightMargin: Theme.spacingM
                anchors.verticalCenter: parent.verticalCenter
                spacing: Theme.spacingM

                DankIcon {
                    name: "privacy_tip"
                    size: Theme.iconSizeSmall
                    color: SettingsData.notificationPopupPrivacyMode ? Theme.primary : Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }

                Column {
                    spacing: 2
                    anchors.verticalCenter: parent.verticalCenter
                    width: privacyRow.width - Theme.iconSizeSmall - Theme.spacingM

                    StyledText {
                        width: parent.width
                        text: I18n.tr("Privacy Mode")
                        font.pixelSize: Theme.fontSizeSmall
                        color: Theme.surfaceText
                        wrapMode: Text.Wrap
                    }

                    StyledText {
                        width: parent.width
                        text: I18n.tr("Hide notification content until expanded")
                        font.pixelSize: Theme.fontSizeSmall - 1
                        color: Theme.surfaceVariantText
                        wrapMode: Text.Wrap
                    }
                }
            }

            DankToggle {
                id: privacyToggle
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                checked: SettingsData.notificationPopupPrivacyMode
                onToggled: toggled => SettingsData.set("notificationPopupPrivacyMode", toggled)
            }
        }

        Rectangle {
            width: parent.width
            height: 1
            color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.1)
        }

        StyledText {
            text: I18n.tr("History Settings")
            font.pixelSize: Theme.fontSizeSmall
            font.weight: Font.Medium
            color: Theme.surfaceVariantText
        }

        Item {
            width: parent.width
            height: Math.max(lowRow.implicitHeight, lowToggle.implicitHeight) + Theme.spacingS

            Row {
                id: lowRow
                anchors.left: parent.left
                anchors.verticalCenter: parent.verticalCenter
                spacing: Theme.spacingM

                DankIcon {
                    name: "low_priority"
                    size: Theme.iconSizeSmall
                    color: SettingsData.notificationHistorySaveLow ? Theme.primary : Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }

                StyledText {
                    text: I18n.tr("Low Priority")
                    font.pixelSize: Theme.fontSizeSmall
                    color: Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }
            }

            DankToggle {
                id: lowToggle
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                checked: SettingsData.notificationHistorySaveLow
                onToggled: toggled => SettingsData.set("notificationHistorySaveLow", toggled)
            }
        }

        Item {
            width: parent.width
            height: Math.max(normalRow.implicitHeight, normalToggle.implicitHeight) + Theme.spacingS

            Row {
                id: normalRow
                anchors.left: parent.left
                anchors.verticalCenter: parent.verticalCenter
                spacing: Theme.spacingM

                DankIcon {
                    name: "notifications"
                    size: Theme.iconSizeSmall
                    color: SettingsData.notificationHistorySaveNormal ? Theme.primary : Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }

                StyledText {
                    text: I18n.tr("Normal Priority")
                    font.pixelSize: Theme.fontSizeSmall
                    color: Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }
            }

            DankToggle {
                id: normalToggle
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                checked: SettingsData.notificationHistorySaveNormal
                onToggled: toggled => SettingsData.set("notificationHistorySaveNormal", toggled)
            }
        }

        Item {
            width: parent.width
            height: Math.max(criticalRow.implicitHeight, criticalToggle.implicitHeight) + Theme.spacingS

            Row {
                id: criticalRow
                anchors.left: parent.left
                anchors.verticalCenter: parent.verticalCenter
                spacing: Theme.spacingM

                DankIcon {
                    name: "priority_high"
                    size: Theme.iconSizeSmall
                    color: SettingsData.notificationHistorySaveCritical ? Theme.primary : Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }

                StyledText {
                    text: I18n.tr("Critical Priority")
                    font.pixelSize: Theme.fontSizeSmall
                    color: Theme.surfaceText
                    anchors.verticalCenter: parent.verticalCenter
                }
            }

            DankToggle {
                id: criticalToggle
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                checked: SettingsData.notificationHistorySaveCritical
                onToggled: toggled => SettingsData.set("notificationHistorySaveCritical", toggled)
            }
        }
    }
    }
}