mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
lockscreen: Add support for passwordless logins
This commit is contained in:
parent
8438027d8b
commit
0787904ed5
3 changed files with 47 additions and 19 deletions
|
|
@ -1,8 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2021-2022 Devin Lin <devin@kde.org>
|
||||
// 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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
// SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com>
|
||||
// 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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue