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 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQuick.Layouts 1.15 0009 0010 import org.kde.plasma.core 2.0 as PlasmaCore 0011 import org.kde.plasma.components 2.0 as PlasmaComponents 0012 0013 Item { 0014 id: root 0015 0016 signal switchUserClicked() 0017 signal canceled() 0018 0019 property alias notification: message.text 0020 property bool switchUserEnabled 0021 property bool capsLockOn 0022 0023 implicitWidth: layoutItem.width + theme.mSize(theme.defaultFont).width * 4 + 12 0024 implicitHeight: layoutItem.height + 12 0025 0026 anchors { 0027 fill: parent 0028 margins: 6 0029 } 0030 0031 Column { 0032 id: layoutItem 0033 anchors.centerIn: parent 0034 spacing: theme.mSize(theme.defaultFont).height / 2 0035 0036 PlasmaComponents.Label { 0037 id: message 0038 text: "" 0039 anchors.horizontalCenter: parent.horizontalCenter 0040 font.bold: true 0041 Behavior on opacity { 0042 NumberAnimation { 0043 duration: 250 0044 } 0045 } 0046 opacity: text == "" ? 0 : 1 0047 } 0048 0049 PlasmaComponents.Label { 0050 id: capsLockMessage 0051 text: i18n("Warning: Caps Lock on") 0052 anchors.horizontalCenter: parent.horizontalCenter 0053 opacity: capsLockOn ? 1 : 0 0054 height: capsLockOn ? paintedHeight : 0 0055 font.bold: true 0056 Behavior on opacity { 0057 NumberAnimation { 0058 duration: 250 0059 } 0060 } 0061 } 0062 0063 PlasmaComponents.Label { 0064 id: lockMessage 0065 text: kscreenlocker_userName.length == 0 ? i18nd("kscreenlocker_greet", "The session is locked") : 0066 i18nd("kscreenlocker_greet", "The session has been locked by %1", kscreenlocker_userName) 0067 anchors.horizontalCenter: parent.horizontalCenter 0068 } 0069 0070 RowLayout { 0071 anchors.horizontalCenter: parent.horizontalCenter 0072 PlasmaComponents.Label { 0073 text: i18nd("kscreenlocker_greet", "Password:") 0074 } 0075 PlasmaComponents.TextField { 0076 id: password 0077 enabled: !authenticator.busy 0078 echoMode: TextInput.Password 0079 focus: true 0080 Keys.onEnterPressed: authenticator.tryUnlock() 0081 Keys.onReturnPressed: authenticator.tryUnlock() 0082 Keys.onEscapePressed: password.text = "" 0083 } 0084 } 0085 0086 PlasmaComponents.ButtonRow { 0087 id: buttonRow 0088 property bool showAccel: false 0089 exclusive: false 0090 spacing: theme.mSize(theme.defaultFont).width / 2 0091 anchors.horizontalCenter: parent.horizontalCenter 0092 0093 AccelButton { 0094 id: switchUser 0095 label: i18nd("kscreenlocker_greet", "&Switch Users") 0096 iconSource: "fork" 0097 visible: switchUserEnabled 0098 onClicked: switchUserClicked() 0099 } 0100 0101 AccelButton { 0102 id: unlock 0103 label: i18nd("kscreenlocker_greet", "Un&lock") 0104 iconSource: "object-unlocked" 0105 enabled: !authenticator.graceLocked 0106 onClicked: authenticator.tryUnlock() 0107 } 0108 } 0109 } 0110 0111 Keys.onPressed: { 0112 const alt = event.modifiers & Qt.AltModifier; 0113 buttonRow.showAccel = alt; 0114 0115 if (alt) { 0116 // focus munging is needed otherwise the greet (QWidget) 0117 // eats all the key events, even if root is added to forwardTo 0118 // qml property of greeter 0119 // greeter.focus = false; 0120 root.forceActiveFocus(); 0121 0122 for (const button of [switchUser, unlock]) { 0123 if (event.key == button.accelKey) { 0124 buttonRow.showAccel = false; 0125 button.clicked(); 0126 break; 0127 } 0128 } 0129 } 0130 } 0131 0132 Keys.onReleased: { 0133 buttonRow.showAccel = event.modifiers & Qt.AltModifier; 0134 } 0135 0136 Connections { 0137 target: authenticator 0138 0139 function onFailed() { 0140 root.notification = i18nd("kscreenlocker_greet", "Unlocking failed"); 0141 } 0142 function onBusyChanged() { 0143 if (!authenticator.busy) { 0144 root.notification = ""; 0145 password.selectAll(); 0146 password.focus = true; 0147 } 0148 } 0149 function onInfoMessage(text) { 0150 root.notification = text; 0151 } 0152 function onErrorMessage(text) { 0153 root.notification = text; 0154 } 0155 function onPromptForSecret() { 0156 authenticator.respond(password.text); 0157 } 0158 function onSucceeded() { 0159 Qt.quit() 0160 } 0161 } 0162 }