1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
/*
SPDX-FileCopyrightText: 2011 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2023 Nate Graham <nate@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.15
import QtQuick.Layouts 1.15
import org.kde.kirigami 2.20 as Kirigami
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.kscreenlocker 1.0 as ScreenLocker
Item {
id: root
signal switchUserClicked()
signal canceled()
property alias notification: message.text
property bool switchUserEnabled
property bool capsLockOn
function resetFocus() {
password.forceActiveFocus();
}
implicitWidth: layoutItem.width + Kirigami.Units.largeSpacing * 2
implicitHeight: layoutItem.height + Kirigami.Units.largeSpacing * 2
ColumnLayout {
id: layoutItem
anchors.centerIn: parent
spacing: Kirigami.Units.largeSpacing
PlasmaComponents3.Label {
id: message
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
text: ""
font.bold: true
visible: opacity > 0
opacity: text == "" ? 0 : 1
Behavior on opacity {
NumberAnimation {
duration: Kirigami.Units.longDuration
}
}
}
PlasmaComponents3.Label {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
text: i18n("Warning: Caps Lock on")
font.bold: true
visible: opacity > 0
opacity: root.capsLockOn ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: Kirigami.Units.longDuration
}
}
}
PlasmaComponents3.Label {
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
text: kscreenlocker_userName.length == 0 ? i18nd("kscreenlocker_greet", "The session is locked") :
i18nd("kscreenlocker_greet", "The session has been locked by %1", kscreenlocker_userName)
}
PlasmaExtras.PasswordField {
id: password
Layout.alignment: Qt.AlignHCenter
implicitWidth: Kirigami.Units.gridUnit * 15
enabled: !authenticator.busy
text: PasswordSync.password
Keys.onEnterPressed: authenticator.startAuthenticating()
Keys.onReturnPressed: authenticator.startAuthenticating()
Keys.onEscapePressed: {
password.text = ""
password.text = Qt.binding(() => PasswordSync.password)
}
}
Binding {
target: PasswordSync
property: "password"
value: password.text
}
PlasmaComponents3.Label {
visible: authenticator.authenticatorTypes & ScreenLocker.Authenticator.Fingerprint
text: i18nd("kscreenlocker_greet", "(or place your fingerprint on the reader)")
Layout.fillWidth: true
}
PlasmaComponents3.Label {
visible: authenticator.authenticatorTypes & ScreenLocker.Authenticator.Smartcard
text: i18nd("kscreenlocker_greet", "(or use your smartcard)")
Layout.fillWidth: true
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
spacing: Kirigami.Units.largeSpacing
PlasmaComponents3.Button {
text: i18nd("kscreenlocker_greet", "&Switch Users")
icon.name: "system-switch-user"
visible: root.switchUserEnabled
onClicked: switchUserClicked()
}
PlasmaComponents3.Button {
text: i18nd("kscreenlocker_greet", "Un&lock")
icon.name: "unlock"
enabled: !authenticator.graceLocked
onClicked: authenticator.startAuthenticating()
}
}
}
Connections {
target: authenticator
function onFailed() {
root.notification = i18nd("kscreenlocker_greet", "Unlocking failed");
}
function onBusyChanged() {
if (!authenticator.busy) {
root.notification = "";
password.selectAll();
root.resetFocus();
}
}
function onInfoMessageChanged() {
root.notification = Qt.binding(() => authenticator.infoMessage);
}
function onErrorMessageChanged() {
root.notification = Qt.binding(() => authenticator.errorMessage);
}
function onPromptForSecretChanged() {
authenticator.respond(password.text);
}
function onSucceeded() {
Qt.quit()
}
}
Component.onCompleted: {
root.resetFocus();
}
}
|