2023-05-13 15:15:52 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
|
|
|
|
|
// SPDX-FileCopyrightText: 2021-2022 Devin Lin <espidev@gmail.com>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-08-20 10:10:58 +00:00
|
|
|
|
2023-05-13 15:15:52 +00:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Layouts
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2023-09-05 15:34:49 +00:00
|
|
|
import org.kde.plasma.core as PlasmaCore
|
2023-10-20 20:01:56 +00:00
|
|
|
import org.kde.notificationmanager as Notifications
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2022-05-21 03:41:11 +00:00
|
|
|
import org.kde.kirigami 2.12 as Kirigami
|
|
|
|
|
|
2022-04-10 17:44:37 +00:00
|
|
|
/**
|
|
|
|
|
* Lockscreen component that is loaded after the device is locked.
|
2022-12-09 15:54:02 +00:00
|
|
|
*
|
2022-04-10 17:44:37 +00:00
|
|
|
* Special attention must be paid to ensuring the GUI loads as fast as possible.
|
|
|
|
|
*/
|
2022-12-09 15:54:02 +00:00
|
|
|
Item {
|
2020-02-01 14:21:24 +00:00
|
|
|
id: root
|
|
|
|
|
|
2022-05-21 03:41:11 +00:00
|
|
|
property var lockScreenState: LockScreenState {}
|
|
|
|
|
property var notifModel: Notifications.WatchedNotificationsModel {}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2022-07-12 02:11:33 +00:00
|
|
|
// only show widescreen mode for short height devices (ex. phone landscape)
|
|
|
|
|
property bool isWidescreen: root.height < 720 && (root.height < root.width * 0.75)
|
2021-05-05 19:48:06 +00:00
|
|
|
property bool notificationsShown: false
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2022-02-17 05:52:34 +00:00
|
|
|
readonly property bool drawerOpen: flickable.openFactor >= 1
|
2022-06-24 03:35:54 +00:00
|
|
|
property var passwordBar: keypadLoader.item.passwordBar
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2022-06-24 03:35:54 +00:00
|
|
|
// listen for keyboard events, and focus on input area
|
|
|
|
|
Component.onCompleted: forceActiveFocus();
|
|
|
|
|
Keys.onPressed: {
|
|
|
|
|
passwordBar.isPinMode = false;
|
|
|
|
|
flickable.goToOpenPosition();
|
|
|
|
|
passwordBar.textField.forceActiveFocus();
|
|
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
|
|
|
|
// wallpaper blur
|
2022-02-17 05:52:34 +00:00
|
|
|
Loader {
|
2020-02-01 14:21:24 +00:00
|
|
|
anchors.fill: parent
|
2022-02-17 05:52:34 +00:00
|
|
|
asynchronous: true
|
|
|
|
|
sourceComponent: WallpaperBlur {
|
|
|
|
|
source: wallpaper
|
2023-05-13 15:15:52 +00:00
|
|
|
shouldBlur: root.notificationsShown || root.drawerOpen // only blur once animation finished for performance
|
2020-08-31 01:38:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2022-05-21 03:41:11 +00:00
|
|
|
Connections {
|
|
|
|
|
target: root.lockScreenState
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2022-05-21 03:41:11 +00:00
|
|
|
// ensure keypad is opened when password is updated (ex. keyboard)
|
|
|
|
|
function onPasswordChanged() {
|
|
|
|
|
flickable.goToOpenPosition()
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-05 19:48:06 +00:00
|
|
|
|
2023-07-25 01:13:52 +00:00
|
|
|
Item {
|
2022-02-12 05:19:44 +00:00
|
|
|
anchors.fill: parent
|
2022-12-09 15:54:02 +00:00
|
|
|
|
|
|
|
|
// header bar and action drawer
|
|
|
|
|
Loader {
|
|
|
|
|
id: headerBarLoader
|
|
|
|
|
z: 1 // on top of flick area
|
2023-07-25 01:13:52 +00:00
|
|
|
readonly property real statusBarHeight: Kirigami.Units.gridUnit * 1.25
|
2022-12-09 15:54:02 +00:00
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
asynchronous: true
|
|
|
|
|
|
|
|
|
|
sourceComponent: HeaderComponent {
|
|
|
|
|
statusBarHeight: headerBarLoader.statusBarHeight
|
|
|
|
|
openFactor: flickable.openFactor
|
|
|
|
|
notificationsModel: root.notifModel
|
|
|
|
|
onPasswordRequested: root.askPassword()
|
2022-06-18 20:47:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
|
|
|
|
FlickContainer {
|
|
|
|
|
id: flickable
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
property real openFactor: position / keypadHeight
|
|
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
|
if (root.lockScreenState.passwordless) {
|
|
|
|
|
// try unlocking if flicked to the top, and we have passwordless login
|
|
|
|
|
root.lockScreenState.tryPassword();
|
|
|
|
|
}
|
2020-08-31 01:38:46 +00:00
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-07-25 01:13:52 +00:00
|
|
|
keypadHeight: Kirigami.Units.gridUnit * 20
|
2022-12-09 15:54:02 +00:00
|
|
|
|
|
|
|
|
// go to closed position when loaded
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
flickable.position = 0;
|
|
|
|
|
flickable.goToClosePosition();
|
2021-05-05 19:48:06 +00:00
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
|
|
|
|
// update position, and cap it at the keypad height
|
|
|
|
|
onPositionChanged: {
|
|
|
|
|
if (position > keypadHeight) {
|
|
|
|
|
position = keypadHeight;
|
|
|
|
|
} else if (position < 0) {
|
|
|
|
|
position = 0;
|
|
|
|
|
}
|
2020-07-12 03:33:54 +00:00
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
LockScreenNarrowContent {
|
|
|
|
|
id: phoneComponent
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
visible: !isWidescreen
|
|
|
|
|
active: visible
|
|
|
|
|
opacity: 1 - flickable.openFactor
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
fullHeight: root.height
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
lockScreenState: root.lockScreenState
|
|
|
|
|
notificationsModel: root.notifModel
|
|
|
|
|
onNotificationsShownChanged: root.notificationsShown = notificationsShown
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
onPasswordRequested: flickable.goToOpenPosition()
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
anchors.top: parent.top
|
2023-10-23 06:42:38 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2023-09-30 05:57:58 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
// move while swiping up
|
|
|
|
|
transform: Translate { y: Math.round((1 - phoneComponent.opacity) * (-root.height / 6)) }
|
|
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
LockScreenWideScreenContent {
|
|
|
|
|
id: tabletComponent
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
visible: isWidescreen
|
|
|
|
|
active: visible
|
|
|
|
|
opacity: 1 - flickable.openFactor
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
lockScreenState: root.lockScreenState
|
|
|
|
|
notificationsModel: root.notifModel
|
|
|
|
|
onNotificationsShownChanged: root.notificationsShown = notificationsShown
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
onPasswordRequested: flickable.goToOpenPosition()
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
anchors.topMargin: headerBarLoader.statusBarHeight
|
|
|
|
|
anchors.top: parent.top
|
2023-10-23 06:42:38 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2023-09-30 05:57:58 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
// move while swiping up
|
|
|
|
|
transform: Translate { y: Math.round((1 - phoneComponent.opacity) * (-root.height / 6)) }
|
|
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
// scroll up icon
|
2023-10-28 18:44:06 +00:00
|
|
|
BottomIconIndicator {
|
2023-09-30 05:57:58 +00:00
|
|
|
id: scrollUpIconLoader
|
2023-10-28 18:44:06 +00:00
|
|
|
lockScreenState: root.lockScreenState
|
2023-10-23 06:42:38 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2024-02-11 22:59:36 +00:00
|
|
|
anchors.bottomMargin: Kirigami.Units.gridUnit + flickable.position * 0.5
|
2023-09-30 05:57:58 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
// password keypad
|
|
|
|
|
Loader {
|
|
|
|
|
id: keypadLoader
|
|
|
|
|
width: parent.width
|
|
|
|
|
asynchronous: true
|
|
|
|
|
active: !root.lockScreenState.passwordless // only load keypad if not passwordless
|
|
|
|
|
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
|
|
|
|
|
sourceComponent: ColumnLayout {
|
|
|
|
|
property alias passwordBar: keypad.passwordBar
|
|
|
|
|
|
|
|
|
|
transform: Translate { y: flickable.keypadHeight - flickable.position }
|
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
|
|
// info notification text
|
|
|
|
|
Label {
|
|
|
|
|
Layout.fillWidth: true
|
2023-11-08 17:57:27 +00:00
|
|
|
Layout.rightMargin: Kirigami.Units.largeSpacing
|
|
|
|
|
Layout.leftMargin: Kirigami.Units.largeSpacing
|
2023-09-30 05:57:58 +00:00
|
|
|
Layout.bottomMargin: Kirigami.Units.smallSpacing * 2
|
|
|
|
|
font.pointSize: 9
|
|
|
|
|
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
text: root.lockScreenState.info
|
|
|
|
|
opacity: (root.lockScreenState.info.length === 0 || flickable.openFactor < 1) ? 0 : 1
|
|
|
|
|
color: 'white'
|
|
|
|
|
|
|
|
|
|
Behavior on opacity {
|
|
|
|
|
NumberAnimation { duration: 200 }
|
2022-12-09 15:54:02 +00:00
|
|
|
}
|
2023-09-30 05:57:58 +00:00
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
// scroll down icon
|
|
|
|
|
Kirigami.Icon {
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
Layout.bottomMargin: Kirigami.Units.gridUnit
|
2023-10-23 06:42:38 +00:00
|
|
|
implicitWidth: Kirigami.Units.iconSizes.small
|
|
|
|
|
implicitHeight: Kirigami.Units.iconSizes.small
|
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
|
2023-09-30 05:57:58 +00:00
|
|
|
source: "arrow-down"
|
|
|
|
|
opacity: Math.sin((Math.PI / 2) * flickable.openFactor + 1.5 * Math.PI) + 1
|
|
|
|
|
}
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
Keypad {
|
|
|
|
|
id: keypad
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
focus: true
|
2022-12-09 15:54:02 +00:00
|
|
|
|
2023-09-30 05:57:58 +00:00
|
|
|
lockScreenState: root.lockScreenState
|
|
|
|
|
swipeProgress: flickable.openFactor
|
2022-04-10 17:44:37 +00:00
|
|
|
}
|
2021-10-16 15:31:42 +00:00
|
|
|
}
|
2019-10-31 06:20:36 +00:00
|
|
|
}
|
2014-08-28 13:21:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|