lockscreen: Improve physical keyboard input

This commit is contained in:
Devin Lin 2022-06-23 23:35:54 -04:00
parent 74285d9261
commit 9f1b76c4cf
3 changed files with 16 additions and 20 deletions

View file

@ -21,6 +21,8 @@ Rectangle {
required property var lockScreenState
property alias passwordBar: passwordBar
// 0 - keypad is not shown, 1 - keypad is shown
property double swipeProgress
@ -50,25 +52,6 @@ Rectangle {
easing.type: Easing.InOutQuad
}
}
// listen for keyboard events
Keys.onPressed: {
if (event.modifiers === Qt.NoModifier) {
if (event.key === Qt.Key_Backspace) {
passwordBar.backspace();
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
passwordBar.enter();
} else if (event.text != "") {
passwordBar.keyPress(event.text);
}
}
if (event.modifiers & Qt.ControlModifier) {
if (event.key === Qt.Key_Backspace) {
passwordBar.clear();
}
}
}
RectangularGlow {
anchors.topMargin: 1

View file

@ -29,10 +29,19 @@ PlasmaCore.ColorScope {
property bool notificationsShown: false
readonly property bool drawerOpen: flickable.openFactor >= 1
property var passwordBar: keypadLoader.item.passwordBar
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
anchors.fill: parent
// listen for keyboard events, and focus on input area
Component.onCompleted: forceActiveFocus();
Keys.onPressed: {
passwordBar.isPinMode = false;
flickable.goToOpenPosition();
passwordBar.textField.forceActiveFocus();
}
// wallpaper blur
Loader {
anchors.fill: parent
@ -167,6 +176,7 @@ PlasmaCore.ColorScope {
// password keypad
Loader {
id: keypadLoader
width: parent.width
asynchronous: true
active: !root.lockScreenState.passwordless // only load keypad if not passwordless
@ -174,8 +184,9 @@ PlasmaCore.ColorScope {
anchors.bottom: parent.bottom
sourceComponent: ColumnLayout {
transform: Translate { y: flickable.keypadHeight - flickable.position }
property alias passwordBar: keypad.passwordBar
transform: Translate { y: flickable.keypadHeight - flickable.position }
spacing: 0
// info notification text

View file

@ -20,6 +20,8 @@ Rectangle {
required property var lockScreenState
property alias textField: textField
// toggle between pin and password mode
property bool isPinMode: true