diff --git a/look-and-feel/contents/lockscreen/FlickContainer.qml b/look-and-feel/contents/lockscreen/FlickContainer.qml index 762cc3a4..9737b28e 100644 --- a/look-and-feel/contents/lockscreen/FlickContainer.qml +++ b/look-and-feel/contents/lockscreen/FlickContainer.qml @@ -1,8 +1,5 @@ -/* - * SPDX-FileCopyrightText: 2021 Devin Lin - * - * SPDX-License-Identifier: LGPL-2.0-or-later - */ +// SPDX-FileCopyrightText: 2021-2022 Devin Lin +// SPDX-License-Identifier: LGPL-2.0-or-later import QtQuick 2.15 import QtQuick.Layouts 1.15 @@ -16,6 +13,8 @@ Flickable { required property real keypadHeight + signal opened() + function cancelAnimations() { positionAnim.stop(); } @@ -45,6 +44,12 @@ Flickable { id: positionAnim duration: PlasmaCore.Units.longDuration * 2 easing.type: Easing.OutCubic + + onFinished: { + if (root.position === keypadHeight) { + root.opened(); + } + } } // we use flickable solely for capturing flicks, not positioning elements @@ -55,7 +60,6 @@ Flickable { readonly property real startContentY: contentHeight / 2 - property int oldPosition: position property bool movingUp: false diff --git a/look-and-feel/contents/lockscreen/LockScreen.qml b/look-and-feel/contents/lockscreen/LockScreen.qml index 798a477c..20c6bbdc 100644 --- a/look-and-feel/contents/lockscreen/LockScreen.qml +++ b/look-and-feel/contents/lockscreen/LockScreen.qml @@ -69,6 +69,13 @@ PlasmaCore.ColorScope { 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(); + } + } + keypadHeight: PlasmaCore.Units.gridUnit * 20 // go to closed position when loaded @@ -162,6 +169,7 @@ PlasmaCore.ColorScope { Loader { width: parent.width asynchronous: true + active: !root.lockScreenState.passwordless // only load keypad if not passwordless anchors.bottom: parent.bottom diff --git a/look-and-feel/contents/lockscreen/LockScreenState.qml b/look-and-feel/contents/lockscreen/LockScreenState.qml index 0edc9047..e4eec873 100644 --- a/look-and-feel/contents/lockscreen/LockScreenState.qml +++ b/look-and-feel/contents/lockscreen/LockScreenState.qml @@ -1,8 +1,5 @@ -/* - * SPDX-FileCopyrightText: 2022 Devin Lin - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ +// SPDX-FileCopyrightText: 2022 Devin Lin +// SPDX-License-Identifier: GPL-2.0-or-later import QtQml 2.15 import QtQuick 2.15 @@ -16,8 +13,12 @@ QtObject { // whether waiting for authentication after trying password property bool waitingForAuth: false + // the info message given property string info: "" + // whether the lockscreen was passwordless + property bool passwordless: true + signal reset() signal unlockSucceeded() signal unlockFailed() @@ -26,6 +27,7 @@ QtObject { if (root.password !== '') { // prevent typing lock when password is empty waitingForAuth = true; } + connections.hasPrompt = true; authenticator.tryUnlock(); } @@ -34,21 +36,35 @@ QtObject { root.reset(); } + Component.onCompleted: { + // determine whether we have passwordless login + // if we do, authenticator will emit a success signal, otherwise it will emit failure + authenticator.tryUnlock(); + } + property var connections: Connections { target: authenticator + // false for our test of whether we have passwordless login, otherwise it's true + property bool hasPrompt: false + function onSucceeded() { - console.log('login succeeded'); - root.waitingForAuth = false; - root.unlockSucceeded(); - Qt.quit(); + if (hasPrompt) { + console.log('login succeeded'); + root.waitingForAuth = false; + root.unlockSucceeded(); + Qt.quit(); + } } function onFailed() { - console.log('login failed'); - root.waitingForAuth = false; - root.password = ""; - root.unlockFailed(); + root.passwordless = false; + if (hasPrompt) { + console.log('login failed'); + root.waitingForAuth = false; + root.password = ""; + root.unlockFailed(); + } } function onInfoMessage(msg) {