2022-04-07 18:11:08 +00:00
|
|
|
/*
|
2024-07-07 18:24:48 +00:00
|
|
|
* SPDX-FileCopyrightText: 2021-2024 Devin Lin <espidev@gmail.com>
|
2022-04-07 18:11:08 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
|
2023-07-25 18:34:35 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
2023-11-02 11:08:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2024-07-07 18:24:48 +00:00
|
|
|
import org.kde.plasma.components 3.0 as PC3
|
2022-04-07 18:11:08 +00:00
|
|
|
|
2023-10-20 20:01:56 +00:00
|
|
|
import org.kde.notificationmanager as NotificationManager
|
2022-04-07 18:11:08 +00:00
|
|
|
|
2022-12-09 15:54:02 +00:00
|
|
|
Item {
|
2022-04-07 18:11:08 +00:00
|
|
|
id: root
|
|
|
|
|
required property real openFactor
|
2022-12-09 15:54:02 +00:00
|
|
|
required property real statusBarHeight
|
|
|
|
|
|
2022-04-07 18:11:08 +00:00
|
|
|
property var notificationsModel: []
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2025-03-20 02:06:33 +00:00
|
|
|
readonly property bool actionDrawerVisible: swipeArea.actionDrawer.intendedToBeVisible
|
|
|
|
|
|
2022-04-07 18:11:08 +00:00
|
|
|
signal passwordRequested()
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2024-06-28 15:04:32 +00:00
|
|
|
// The status bar and quicksettings take a while to load, don't pause initial lockscreen loading for it
|
|
|
|
|
Timer {
|
|
|
|
|
id: loadTimer
|
|
|
|
|
running: true
|
|
|
|
|
repeat: false
|
|
|
|
|
onTriggered: {
|
|
|
|
|
statusBarLoader.active = true
|
|
|
|
|
actionDrawerLoader.active = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-07 18:24:48 +00:00
|
|
|
// Add loading indicator when status bar has not loaded yet
|
|
|
|
|
PC3.BusyIndicator {
|
|
|
|
|
id: statusBarLoadingIndication
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.topMargin: Kirigami.Units.smallSpacing
|
|
|
|
|
anchors.rightMargin: Kirigami.Units.smallSpacing
|
|
|
|
|
visible: statusBarLoader.status != Loader.Ready
|
|
|
|
|
|
|
|
|
|
implicitHeight: root.statusBarHeight
|
|
|
|
|
implicitWidth: root.statusBarHeight
|
|
|
|
|
|
|
|
|
|
Kirigami.Theme.inherit: false
|
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-28 15:04:32 +00:00
|
|
|
// Status bar
|
|
|
|
|
Loader {
|
|
|
|
|
id: statusBarLoader
|
|
|
|
|
active: false
|
|
|
|
|
asynchronous: true
|
|
|
|
|
visible: status == Loader.Ready
|
2022-12-09 15:54:02 +00:00
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
|
|
height: root.statusBarHeight
|
|
|
|
|
|
2024-06-28 15:04:32 +00:00
|
|
|
sourceComponent: MobileShell.StatusBar {
|
|
|
|
|
id: statusBar
|
|
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
height: root.statusBarHeight
|
2023-07-25 18:34:35 +00:00
|
|
|
|
2024-06-28 15:04:32 +00:00
|
|
|
Kirigami.Theme.inherit: false
|
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2024-06-28 15:04:32 +00:00
|
|
|
backgroundColor: "transparent"
|
|
|
|
|
|
|
|
|
|
showSecondRow: false
|
|
|
|
|
showDropShadow: true
|
|
|
|
|
showTime: false
|
|
|
|
|
disableSystemTray: true // prevent SIGABRT, since loading the system tray on the lockscreen leads to bad... things
|
|
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-28 15:04:32 +00:00
|
|
|
// Drag down gesture to open action drawer
|
2022-12-09 15:54:02 +00:00
|
|
|
MobileShell.ActionDrawerOpenSurface {
|
|
|
|
|
id: swipeArea
|
2024-06-28 15:04:32 +00:00
|
|
|
actionDrawer: actionDrawerLoader.item ? actionDrawerLoader.item.actionDrawer : null
|
|
|
|
|
|
|
|
|
|
anchors.fill: statusBarLoader
|
2022-12-09 15:54:02 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-28 15:04:32 +00:00
|
|
|
// Dynamically load on swipe-down to avoid having to load at start
|
|
|
|
|
Loader {
|
|
|
|
|
id: actionDrawerLoader
|
|
|
|
|
active: false
|
|
|
|
|
asynchronous: true
|
|
|
|
|
visible: status == Loader.Ready
|
|
|
|
|
|
2022-12-09 15:54:02 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
|
2024-06-28 15:04:32 +00:00
|
|
|
sourceComponent: Item {
|
|
|
|
|
property var actionDrawer: drawer
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2024-06-28 15:04:32 +00:00
|
|
|
// Action drawer component
|
|
|
|
|
MobileShell.ActionDrawer {
|
|
|
|
|
id: drawer
|
|
|
|
|
anchors.fill: parent
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2024-06-28 15:04:32 +00:00
|
|
|
visible: offset !== 0
|
|
|
|
|
restrictedPermissions: true
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2024-06-28 15:04:32 +00:00
|
|
|
notificationSettings: NotificationManager.Settings {}
|
|
|
|
|
notificationModel: root.notificationsModel
|
|
|
|
|
notificationModelType: MobileShell.NotificationsModelType.WatchedNotificationsModel
|
|
|
|
|
|
|
|
|
|
property bool requestNotificationAction: false
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2024-06-28 15:04:32 +00:00
|
|
|
// notification button clicked, requesting auth
|
|
|
|
|
onPermissionsRequested: {
|
|
|
|
|
requestNotificationAction = true;
|
|
|
|
|
drawer.close();
|
|
|
|
|
root.passwordRequested();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// listen to authentication events
|
|
|
|
|
Connections {
|
|
|
|
|
target: authenticator
|
|
|
|
|
function onSucceeded() {
|
|
|
|
|
// run pending action if successfully unlocked
|
|
|
|
|
if (drawer.requestNotificationAction) {
|
|
|
|
|
drawer.runPendingAction();
|
|
|
|
|
drawer.requestNotificationAction = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function onFailed() {
|
|
|
|
|
drawer.requestNotificationAction = false;
|
|
|
|
|
}
|
2022-04-07 18:11:08 +00:00
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
}
|
2022-04-07 18:11:08 +00:00
|
|
|
}
|
|
|
|
|
}
|