2023-05-13 15:15:52 +00:00
|
|
|
// SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2022-02-12 05:19:44 +00:00
|
|
|
|
2023-05-13 15:15:52 +00:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Layouts
|
2022-02-12 05:19:44 +00:00
|
|
|
|
2023-11-02 11:08:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2023-07-25 18:34:35 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
2022-02-12 05:19:44 +00:00
|
|
|
|
2023-10-20 20:01:56 +00:00
|
|
|
import org.kde.notificationmanager as NotificationManager
|
2022-06-24 15:44:30 +00:00
|
|
|
|
2022-12-09 15:54:02 +00:00
|
|
|
Loader {
|
2022-05-21 03:41:11 +00:00
|
|
|
id: root
|
|
|
|
|
required property var lockScreenState
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2022-04-07 18:11:08 +00:00
|
|
|
property var notificationsModel: []
|
2022-06-24 15:44:30 +00:00
|
|
|
property var notificationSettings: NotificationManager.Settings {}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2022-02-12 05:19:44 +00:00
|
|
|
property real leftMargin: 0
|
|
|
|
|
property real rightMargin: 0
|
|
|
|
|
property real topMargin: 0
|
|
|
|
|
property real bottomMargin: 0
|
2025-03-20 02:06:33 +00:00
|
|
|
|
|
|
|
|
property real topPadding: 0
|
|
|
|
|
|
2022-12-09 15:54:02 +00:00
|
|
|
readonly property bool notificationsShown: item && item.notificationsList.hasNotifications
|
2025-03-20 02:06:33 +00:00
|
|
|
readonly property bool listOverflowing: item && item.notificationsList.listView.listOverflowing
|
|
|
|
|
|
|
|
|
|
property bool scrollLock: false
|
2022-12-09 15:54:02 +00:00
|
|
|
|
|
|
|
|
property var notificationsList: item ? item.notificationsList : null
|
|
|
|
|
|
|
|
|
|
signal passwordRequested()
|
|
|
|
|
|
|
|
|
|
// perform delayed loading of notifications
|
|
|
|
|
active: false
|
|
|
|
|
Timer {
|
|
|
|
|
interval: 500
|
|
|
|
|
running: true
|
|
|
|
|
onTriggered: root.active = true
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-21 03:41:11 +00:00
|
|
|
Connections {
|
|
|
|
|
target: lockScreenState
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2022-05-21 03:41:11 +00:00
|
|
|
function onUnlockSucceeded() {
|
|
|
|
|
// run pending action if successfully unlocked
|
|
|
|
|
if (notificationsList.requestNotificationAction) {
|
|
|
|
|
notificationsList.runPendingAction();
|
2022-02-17 05:52:34 +00:00
|
|
|
notificationsList.requestNotificationAction = false;
|
2022-02-12 05:19:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2022-05-21 03:41:11 +00:00
|
|
|
function onUnlockFailed() {
|
|
|
|
|
notificationsList.requestNotificationAction = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
|
|
|
|
sourceComponent: Item {
|
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
|
|
property alias notificationsList: notificationsList
|
|
|
|
|
|
2023-07-25 01:13:52 +00:00
|
|
|
Item {
|
2025-03-20 02:06:33 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
2022-12-09 15:54:02 +00:00
|
|
|
anchors.topMargin: root.topMargin
|
|
|
|
|
anchors.leftMargin: root.leftMargin
|
|
|
|
|
anchors.rightMargin: root.rightMargin
|
2023-07-25 18:34:35 +00:00
|
|
|
|
2023-07-25 01:13:52 +00:00
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.Window
|
|
|
|
|
Kirigami.Theme.inherit: false
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2025-03-20 02:06:33 +00:00
|
|
|
height: Math.min(parent.height - root.topMargin - root.bottomMargin, notificationsList.listView.listHeight + Kirigami.Units.gridUnit)
|
|
|
|
|
|
2022-12-09 15:54:02 +00:00
|
|
|
MobileShell.NotificationsWidget {
|
|
|
|
|
id: notificationsList
|
|
|
|
|
anchors.fill: parent
|
2025-03-20 02:06:33 +00:00
|
|
|
opacity: 0 // we display with the opacity gradient below
|
2022-12-09 15:54:02 +00:00
|
|
|
|
|
|
|
|
historyModelType: MobileShell.NotificationsModelType.WatchedNotificationsModel
|
|
|
|
|
actionsRequireUnlock: true
|
|
|
|
|
historyModel: root.notificationsModel
|
|
|
|
|
notificationSettings: root.notificationSettings
|
2024-08-01 01:18:33 +00:00
|
|
|
inLockscreen: true
|
2025-03-20 02:06:33 +00:00
|
|
|
topPadding: root.topPadding // Kirigami.Units.gridUnit
|
|
|
|
|
bottomPadding: Kirigami.Units.gridUnit
|
|
|
|
|
listView.interactive: !root.scrollLock && listView.listOverflowing
|
2022-12-09 15:54:02 +00:00
|
|
|
|
|
|
|
|
property bool requestNotificationAction: false
|
|
|
|
|
|
|
|
|
|
onUnlockRequested: {
|
|
|
|
|
requestNotificationAction = true;
|
|
|
|
|
root.passwordRequested();
|
|
|
|
|
}
|
2022-02-12 05:19:44 +00:00
|
|
|
}
|
2025-03-20 02:06:33 +00:00
|
|
|
|
|
|
|
|
// opacity gradient at flickable edges
|
|
|
|
|
MobileShell.FlickableOpacityGradient {
|
|
|
|
|
anchors {
|
|
|
|
|
top: notificationsList.top
|
|
|
|
|
left: notificationsList.left
|
|
|
|
|
right: notificationsList.right
|
|
|
|
|
}
|
|
|
|
|
height: notificationsList.listView.height
|
|
|
|
|
flickable: notificationsList.listView
|
|
|
|
|
}
|
2022-02-12 05:19:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|