mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-07-26 14:24:45 +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-2022 Devin Lin <devin@kde.org>
|
||||||
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
|
|
@ -16,6 +13,8 @@ Flickable {
|
||||||
|
|
||||||
required property real keypadHeight
|
required property real keypadHeight
|
||||||
|
|
||||||
|
signal opened()
|
||||||
|
|
||||||
function cancelAnimations() {
|
function cancelAnimations() {
|
||||||
positionAnim.stop();
|
positionAnim.stop();
|
||||||
}
|
}
|
||||||
|
|
@ -45,6 +44,12 @@ Flickable {
|
||||||
id: positionAnim
|
id: positionAnim
|
||||||
duration: PlasmaCore.Units.longDuration * 2
|
duration: PlasmaCore.Units.longDuration * 2
|
||||||
easing.type: Easing.OutCubic
|
easing.type: Easing.OutCubic
|
||||||
|
|
||||||
|
onFinished: {
|
||||||
|
if (root.position === keypadHeight) {
|
||||||
|
root.opened();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we use flickable solely for capturing flicks, not positioning elements
|
// we use flickable solely for capturing flicks, not positioning elements
|
||||||
|
|
@ -55,7 +60,6 @@ Flickable {
|
||||||
|
|
||||||
readonly property real startContentY: contentHeight / 2
|
readonly property real startContentY: contentHeight / 2
|
||||||
|
|
||||||
|
|
||||||
property int oldPosition: position
|
property int oldPosition: position
|
||||||
property bool movingUp: false
|
property bool movingUp: false
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,13 @@ PlasmaCore.ColorScope {
|
||||||
|
|
||||||
property real openFactor: position / keypadHeight
|
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
|
keypadHeight: PlasmaCore.Units.gridUnit * 20
|
||||||
|
|
||||||
// go to closed position when loaded
|
// go to closed position when loaded
|
||||||
|
|
@ -162,6 +169,7 @@ PlasmaCore.ColorScope {
|
||||||
Loader {
|
Loader {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
|
active: !root.lockScreenState.passwordless // only load keypad if not passwordless
|
||||||
|
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
/*
|
// SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com>
|
||||||
* SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com>
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQml 2.15
|
import QtQml 2.15
|
||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
|
|
@ -16,8 +13,12 @@ QtObject {
|
||||||
// whether waiting for authentication after trying password
|
// whether waiting for authentication after trying password
|
||||||
property bool waitingForAuth: false
|
property bool waitingForAuth: false
|
||||||
|
|
||||||
|
// the info message given
|
||||||
property string info: ""
|
property string info: ""
|
||||||
|
|
||||||
|
// whether the lockscreen was passwordless
|
||||||
|
property bool passwordless: true
|
||||||
|
|
||||||
signal reset()
|
signal reset()
|
||||||
signal unlockSucceeded()
|
signal unlockSucceeded()
|
||||||
signal unlockFailed()
|
signal unlockFailed()
|
||||||
|
|
@ -26,6 +27,7 @@ QtObject {
|
||||||
if (root.password !== '') { // prevent typing lock when password is empty
|
if (root.password !== '') { // prevent typing lock when password is empty
|
||||||
waitingForAuth = true;
|
waitingForAuth = true;
|
||||||
}
|
}
|
||||||
|
connections.hasPrompt = true;
|
||||||
authenticator.tryUnlock();
|
authenticator.tryUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,21 +36,35 @@ QtObject {
|
||||||
root.reset();
|
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 {
|
property var connections: Connections {
|
||||||
target: authenticator
|
target: authenticator
|
||||||
|
|
||||||
|
// false for our test of whether we have passwordless login, otherwise it's true
|
||||||
|
property bool hasPrompt: false
|
||||||
|
|
||||||
function onSucceeded() {
|
function onSucceeded() {
|
||||||
console.log('login succeeded');
|
if (hasPrompt) {
|
||||||
root.waitingForAuth = false;
|
console.log('login succeeded');
|
||||||
root.unlockSucceeded();
|
root.waitingForAuth = false;
|
||||||
Qt.quit();
|
root.unlockSucceeded();
|
||||||
|
Qt.quit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFailed() {
|
function onFailed() {
|
||||||
console.log('login failed');
|
root.passwordless = false;
|
||||||
root.waitingForAuth = false;
|
if (hasPrompt) {
|
||||||
root.password = "";
|
console.log('login failed');
|
||||||
root.unlockFailed();
|
root.waitingForAuth = false;
|
||||||
|
root.password = "";
|
||||||
|
root.unlockFailed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInfoMessage(msg) {
|
function onInfoMessage(msg) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue