shift-shell/shell/contents/lockscreen/LockScreenState.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

85 lines
2.3 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com>
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQml
import QtQuick
2024-02-11 23:03:17 +00:00
import org.kde.kscreenlocker 1.0 as ScreenLocker
2023-10-28 18:44:06 +00:00
QtObject {
id: root
// current password being typed
property string password: ""
// 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: false // TODO true
2024-06-16 20:50:06 +00:00
// whether the device can log in with fingerprint
2024-02-11 23:03:17 +00:00
readonly property bool isFingerprintSupported: authenticator.authenticatorTypes & ScreenLocker.Authenticator.Fingerprint
2023-10-28 18:44:06 +00:00
signal reset()
signal unlockSucceeded()
signal unlockFailed()
function tryPassword() {
if (root.password !== '') { // prevent typing lock when password is empty
waitingForAuth = true;
}
2023-10-28 18:44:06 +00:00
authenticator.startAuthenticating();
}
function resetPassword() {
password = "";
root.reset();
}
property var connections: Connections {
target: authenticator
function onSucceeded() {
console.log('login succeeded');
root.waitingForAuth = false;
root.unlockSucceeded();
Qt.quit();
}
function onFailed() {
console.log('login failed');
root.waitingForAuth = false;
root.password = "";
root.unlockFailed();
}
2023-10-28 18:44:06 +00:00
function onInfoMessageChanged() {
console.log('info: ' + authenticator.infoMessage);
root.info += authenticator.infoMessage + " ";
}
// TODO
2023-10-28 18:44:06 +00:00
function onErrorMessageChanged() {
console.log('error: ' + authenticator.errorMessage);
}
// TODO
2023-10-28 18:44:06 +00:00
function onPromptChanged() {
console.log('prompt: ' + authenticator.prompt);
}
2023-10-28 18:44:06 +00:00
function onPromptForSecretChanged() {
console.log('prompt secret: ' + authenticator.promptForSecret);
if (root.password !== "") {
authenticator.respond(root.password);
2023-10-28 18:44:06 +00:00
authenticator.startAuthenticating();
}
}
}
}