mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
lockscreen: Port to new API
This commit is contained in:
parent
12bd56f30b
commit
93395acd02
4 changed files with 122 additions and 59 deletions
84
lookandfeel/contents/lockscreen/BottomIconIndicator.qml
Normal file
84
lookandfeel/contents/lockscreen/BottomIconIndicator.qml
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
// SPDX-FileCopyrightText: 2023 Devin Lin <espidev@gmail.com>
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
import org.kde.kirigami 2.20 as Kirigami
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: root
|
||||||
|
asynchronous: true
|
||||||
|
|
||||||
|
property var lockScreenState
|
||||||
|
|
||||||
|
property real animationY: 0
|
||||||
|
readonly property real fullYOffset: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
|
// animate it going up and down
|
||||||
|
NumberAnimation on animationY {
|
||||||
|
id: animateUpAndDown
|
||||||
|
duration: 800
|
||||||
|
easing.type: Easing.InCubic
|
||||||
|
to: root.fullYOffset
|
||||||
|
|
||||||
|
// only bounce icon if we are showing the scroll up icon
|
||||||
|
running: !lockScreenState.isFingerprintSupported
|
||||||
|
|
||||||
|
onFinished: {
|
||||||
|
if (root.animationY === root.fullYOffset) {
|
||||||
|
to = 0;
|
||||||
|
easing.type = Easing.OutCubic;
|
||||||
|
} else {
|
||||||
|
to = root.fullYOffset;
|
||||||
|
easing.type = Easing.InCubic;
|
||||||
|
}
|
||||||
|
restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
onStopped: {
|
||||||
|
if (lockScreenState.isFingerprintSupported) {
|
||||||
|
root.animationY = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceComponent: {
|
||||||
|
if (lockScreenState.isFingerprintSupported) {
|
||||||
|
return fingerprintIcon;
|
||||||
|
} else {
|
||||||
|
return scrollUpIcon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: scrollUpIcon
|
||||||
|
|
||||||
|
Kirigami.Icon {
|
||||||
|
implicitWidth: Kirigami.Units.iconSizes.small
|
||||||
|
implicitHeight: Kirigami.Units.iconSizes.small
|
||||||
|
opacity: 1 - flickable.openFactor
|
||||||
|
|
||||||
|
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
|
||||||
|
source: "arrow-up"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: fingerprintIcon
|
||||||
|
|
||||||
|
Kirigami.Icon {
|
||||||
|
source: 'fingerprint-symbolic'
|
||||||
|
opacity: 1 - flickable.openFactor
|
||||||
|
implicitWidth: Kirigami.Units.iconSizes.medium
|
||||||
|
implicitHeight: Kirigami.Units.iconSizes.medium
|
||||||
|
|
||||||
|
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
|
||||||
|
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.bottomMargin: Kirigami.Units.gridUnit * 2 + flickable.position * 0.5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -154,46 +154,13 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
// scroll up icon
|
// scroll up icon
|
||||||
Loader {
|
BottomIconIndicator {
|
||||||
id: scrollUpIconLoader
|
id: scrollUpIconLoader
|
||||||
asynchronous: true
|
lockScreenState: root.lockScreenState
|
||||||
|
|
||||||
property real animationY: 0
|
|
||||||
readonly property real fullYOffset: Kirigami.Units.largeSpacing
|
|
||||||
|
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.bottomMargin: Kirigami.Units.gridUnit + flickable.position * 0.5 + scrollUpIconLoader.animationY
|
anchors.bottomMargin: Kirigami.Units.gridUnit + flickable.position * 0.5 + scrollUpIconLoader.animationY
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
// animate it going up and down
|
|
||||||
NumberAnimation on animationY {
|
|
||||||
id: animateUpAndDown
|
|
||||||
running: true
|
|
||||||
duration: 800
|
|
||||||
easing.type: Easing.InCubic
|
|
||||||
to: scrollUpIconLoader.fullYOffset
|
|
||||||
|
|
||||||
onFinished: {
|
|
||||||
if (scrollUpIconLoader.animationY === scrollUpIconLoader.fullYOffset) {
|
|
||||||
to = 0;
|
|
||||||
easing.type = Easing.OutCubic;
|
|
||||||
} else {
|
|
||||||
to = scrollUpIconLoader.fullYOffset;
|
|
||||||
easing.type = Easing.InCubic;
|
|
||||||
}
|
|
||||||
restart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceComponent: Kirigami.Icon {
|
|
||||||
id: scrollUpIcon
|
|
||||||
implicitWidth: Kirigami.Units.iconSizes.small
|
|
||||||
implicitHeight: Kirigami.Units.iconSizes.small
|
|
||||||
opacity: 1 - flickable.openFactor
|
|
||||||
|
|
||||||
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
|
|
||||||
source: "arrow-up"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// password keypad
|
// password keypad
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
import QtQml
|
import QtQml
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
|
import org.kde.kscreenlocker 1.0 as ScreenLocker
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
|
@ -19,6 +21,9 @@ QtObject {
|
||||||
// whether the lockscreen was passwordless
|
// whether the lockscreen was passwordless
|
||||||
property bool passwordless: false // TODO true
|
property bool passwordless: false // TODO true
|
||||||
|
|
||||||
|
// whether the device can login with fingerprint
|
||||||
|
readonly property bool isFingerprintSupported: authenticator.authenticatorTypes & ScreenLocker.Authenticator.Fingerprint
|
||||||
|
|
||||||
signal reset()
|
signal reset()
|
||||||
signal unlockSucceeded()
|
signal unlockSucceeded()
|
||||||
signal unlockFailed()
|
signal unlockFailed()
|
||||||
|
|
@ -28,7 +33,7 @@ QtObject {
|
||||||
waitingForAuth = true;
|
waitingForAuth = true;
|
||||||
}
|
}
|
||||||
connections.hasPrompt = true;
|
connections.hasPrompt = true;
|
||||||
authenticator.tryUnlock();
|
authenticator.startAuthenticating();
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetPassword() {
|
function resetPassword() {
|
||||||
|
|
@ -41,7 +46,7 @@ QtObject {
|
||||||
// if we do, authenticator will emit a success signal, otherwise it will emit failure
|
// if we do, authenticator will emit a success signal, otherwise it will emit failure
|
||||||
|
|
||||||
// TODO: Disabled for the time being, since it seems to cause an infinite loop
|
// TODO: Disabled for the time being, since it seems to cause an infinite loop
|
||||||
// authenticator.tryUnlock();
|
// authenticator.startAuthenticating();
|
||||||
}
|
}
|
||||||
|
|
||||||
property var connections: Connections {
|
property var connections: Connections {
|
||||||
|
|
@ -59,8 +64,13 @@ QtObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFailed() {
|
function onFailed(kind) {
|
||||||
|
if (kind != 0) { // if this is coming from the noninteractive authenticators
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// root.passwordless = false;
|
// root.passwordless = false;
|
||||||
|
|
||||||
if (hasPrompt) {
|
if (hasPrompt) {
|
||||||
console.log('login failed');
|
console.log('login failed');
|
||||||
root.waitingForAuth = false;
|
root.waitingForAuth = false;
|
||||||
|
|
@ -69,26 +79,26 @@ QtObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInfoMessage(msg) {
|
function onInfoMessageChanged() {
|
||||||
console.log('info: ' + msg);
|
console.log('info: ' + authenticator.infoMessage);
|
||||||
root.info += msg + " ";
|
root.info += authenticator.infoMessage + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
function onErrorMessage(msg) {
|
function onErrorMessageChanged() {
|
||||||
console.log('error: ' + msg);
|
console.log('error: ' + authenticator.errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
function onPrompt(msg) {
|
function onPromptChanged() {
|
||||||
console.log('prompt: ' + msg);
|
console.log('prompt: ' + authenticator.prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPromptForSecret(msg) {
|
function onPromptForSecretChanged() {
|
||||||
console.log('prompt secret: ' + msg);
|
console.log('prompt secret: ' + authenticator.promptForSecret);
|
||||||
if (root.password !== "") {
|
if (root.password !== "") {
|
||||||
authenticator.respond(root.password);
|
authenticator.respond(root.password);
|
||||||
authenticator.tryUnlock();
|
authenticator.startAuthenticating();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,26 +30,28 @@ ApplicationWindow {
|
||||||
QtObject {
|
QtObject {
|
||||||
id: authenticator // id passed in by kscreenlocker
|
id: authenticator // id passed in by kscreenlocker
|
||||||
|
|
||||||
|
property string infoMessage: ""
|
||||||
|
property string errorMessage: ""
|
||||||
|
property string prompt: ""
|
||||||
|
property string promptForSecret: ""
|
||||||
|
|
||||||
signal succeeded()
|
signal succeeded()
|
||||||
signal failed()
|
signal failed()
|
||||||
signal infoMessage(string msg)
|
|
||||||
signal errorMessage(string msg)
|
|
||||||
signal prompt(string msg)
|
|
||||||
signal promptForSecret(string msg)
|
|
||||||
|
|
||||||
// these are not kscreenlocker properties, for test purposes only
|
// these are not kscreenlocker properties, for test purposes only
|
||||||
property string password: ""
|
property string password: ""
|
||||||
property bool prompt: true
|
property bool shouldPrompt: true
|
||||||
|
|
||||||
function tryUnlock() {
|
function startAuthenticating() {
|
||||||
if (prompt) {
|
if (shouldPrompt) {
|
||||||
prompt = false;
|
shouldPrompt = false;
|
||||||
promptForSecret("Password:");
|
promptForSecret = "Password:";
|
||||||
|
promptForSecretChanged();
|
||||||
} else if (password === "123456") {
|
} else if (password === "123456") {
|
||||||
prompt = true;
|
shouldPrompt = true;
|
||||||
succeeded();
|
succeeded();
|
||||||
} else {
|
} else {
|
||||||
prompt = true;
|
shouldPrompt = true;
|
||||||
failed();
|
failed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue