Warning, /plasma/kscreenlocker/greeter/fallbacktheme/Greeter.qml is written in an unsupported language. File is not indexed.

0001 /*
0002 SPDX-FileCopyrightText: 2011 Martin Gräßlin <mgraesslin@kde.org>
0003 SPDX-FileCopyrightText: 2023 Nate Graham <nate@kde.org>
0004 
0005 SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 import QtQuick 2.15
0009 import QtQuick.Layouts 1.15
0010 
0011 import org.kde.kirigami 2.20 as Kirigami
0012 import org.kde.plasma.extras 2.0 as PlasmaExtras
0013 import org.kde.plasma.components 3.0 as PlasmaComponents3
0014 import org.kde.kscreenlocker 1.0 as ScreenLocker
0015 
0016 Item {
0017     id: root
0018 
0019     signal switchUserClicked()
0020     signal canceled()
0021 
0022     property alias notification: message.text
0023     property bool switchUserEnabled
0024     property bool capsLockOn
0025 
0026     function resetFocus() {
0027         password.forceActiveFocus();
0028     }
0029 
0030     implicitWidth: layoutItem.width + Kirigami.Units.largeSpacing * 2
0031     implicitHeight: layoutItem.height + Kirigami.Units.largeSpacing * 2
0032 
0033     ColumnLayout {
0034         id: layoutItem
0035         anchors.centerIn: parent
0036         spacing: Kirigami.Units.largeSpacing
0037 
0038         PlasmaComponents3.Label {
0039             id: message
0040             Layout.fillWidth: true
0041             horizontalAlignment: Text.AlignHCenter
0042             elide: Text.ElideRight
0043             text: ""
0044             font.bold: true
0045 
0046             visible: opacity > 0
0047             opacity: text == "" ? 0 : 1
0048             Behavior on opacity {
0049                 NumberAnimation {
0050                     duration: Kirigami.Units.longDuration
0051                 }
0052             }
0053         }
0054 
0055         PlasmaComponents3.Label {
0056             Layout.fillWidth: true
0057             horizontalAlignment: Text.AlignHCenter
0058             elide: Text.ElideRight
0059             text: i18n("Warning: Caps Lock on")
0060             font.bold: true
0061 
0062             visible: opacity > 0
0063             opacity: root.capsLockOn ? 1 : 0
0064             Behavior on opacity {
0065                 NumberAnimation {
0066                     duration: Kirigami.Units.longDuration
0067                 }
0068             }
0069         }
0070 
0071         PlasmaComponents3.Label {
0072             Layout.fillWidth: true
0073             horizontalAlignment: Text.AlignHCenter
0074             elide: Text.ElideRight
0075             text: kscreenlocker_userName.length == 0 ? i18nd("kscreenlocker_greet", "The session is locked") :
0076                                                        i18nd("kscreenlocker_greet", "The session has been locked by %1", kscreenlocker_userName)
0077         }
0078         PlasmaExtras.PasswordField {
0079             id: password
0080             Layout.alignment: Qt.AlignHCenter
0081             implicitWidth: Kirigami.Units.gridUnit * 15
0082             enabled: !authenticator.busy
0083             Keys.onEnterPressed: authenticator.startAuthenticating()
0084             Keys.onReturnPressed: authenticator.startAuthenticating()
0085             Keys.onEscapePressed: password.text = ""
0086         }
0087 
0088         PlasmaComponents3.Label {
0089             visible: authenticator.authenticatorTypes & ScreenLocker.Authenticator.Fingerprint
0090             text: i18nd("kscreenlocker_greet", "(or place your fingerprint on the reader)")
0091             Layout.fillWidth: true
0092         }
0093 
0094         PlasmaComponents3.Label {
0095             visible: authenticator.authenticatorTypes & ScreenLocker.Authenticator.Smartcard
0096             text: i18nd("kscreenlocker_greet", "(or use your smartcard)")
0097             Layout.fillWidth: true
0098         }
0099 
0100         RowLayout {
0101             Layout.alignment: Qt.AlignHCenter
0102             spacing: Kirigami.Units.largeSpacing
0103 
0104             PlasmaComponents3.Button {
0105                 text: i18nd("kscreenlocker_greet", "&Switch Users")
0106                 icon.name: "system-switch-user"
0107                 visible: root.switchUserEnabled
0108                 onClicked: switchUserClicked()
0109             }
0110 
0111             PlasmaComponents3.Button {
0112                 text: i18nd("kscreenlocker_greet", "Un&lock")
0113                 icon.name: "unlock"
0114                 enabled: !authenticator.graceLocked
0115                 onClicked: authenticator.startAuthenticating()
0116             }
0117         }
0118     }
0119 
0120     Connections {
0121         target: authenticator
0122 
0123         function onFailed() {
0124             root.notification = i18nd("kscreenlocker_greet", "Unlocking failed");
0125         }
0126         function onBusyChanged() {
0127             if (!authenticator.busy) {
0128                 root.notification = "";
0129                 password.selectAll();
0130                 root.resetFocus();
0131             }
0132         }
0133         function onInfoMessageChanged() {
0134             root.notification = Qt.binding(() => authenticator.infoMessage);
0135         }
0136         function onErrorMessageChanged() {
0137             root.notification = Qt.binding(() => authenticator.errorMessage);
0138         }
0139         function onPromptForSecretChanged() {
0140             authenticator.respond(password.text);
0141         }
0142         function onSucceeded() {
0143             Qt.quit()
0144         }
0145     }
0146 
0147     Component.onCompleted: {
0148         root.resetFocus();
0149     }
0150 }