2022-02-12 05:19:44 +00:00
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com>
|
2022-12-09 15:54:02 +00:00
|
|
|
*
|
2022-02-12 05:19:44 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
|
import QtQuick.Layouts 1.1
|
2023-03-03 05:48:24 +00:00
|
|
|
import Qt5Compat.GraphicalEffects
|
2022-02-12 05:19:44 +00:00
|
|
|
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
|
|
|
import org.kde.notificationmanager 1.1 as Notifications
|
|
|
|
|
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
|
|
|
|
|
2022-06-24 15:44:30 +00:00
|
|
|
import org.kde.notificationmanager 1.0 as NotificationManager
|
|
|
|
|
|
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
|
2022-12-09 15:54:02 +00:00
|
|
|
readonly property bool notificationsShown: item && item.notificationsList.hasNotifications
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
PlasmaCore.ColorScope {
|
2022-02-12 05:19:44 +00:00
|
|
|
anchors.fill: parent
|
2022-12-09 15:54:02 +00:00
|
|
|
anchors.topMargin: root.topMargin
|
|
|
|
|
anchors.bottomMargin: root.bottomMargin
|
|
|
|
|
anchors.leftMargin: root.leftMargin
|
|
|
|
|
anchors.rightMargin: root.rightMargin
|
|
|
|
|
colorGroup: PlasmaCore.Theme.NormalColorGroup
|
|
|
|
|
|
|
|
|
|
MobileShell.NotificationsWidget {
|
|
|
|
|
id: notificationsList
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
historyModelType: MobileShell.NotificationsModelType.WatchedNotificationsModel
|
|
|
|
|
actionsRequireUnlock: true
|
|
|
|
|
historyModel: root.notificationsModel
|
|
|
|
|
notificationSettings: root.notificationSettings
|
|
|
|
|
|
|
|
|
|
property bool requestNotificationAction: false
|
|
|
|
|
|
|
|
|
|
onUnlockRequested: {
|
|
|
|
|
requestNotificationAction = true;
|
|
|
|
|
root.passwordRequested();
|
|
|
|
|
}
|
2022-02-12 05:19:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|