Adjust keypad height for vkbd and ensure vkbd is always showing

This commit is contained in:
Devin Lin 2021-05-06 12:20:21 -04:00
parent 38f9e4871d
commit 19fe5a1afe
3 changed files with 119 additions and 88 deletions

View file

@ -32,7 +32,13 @@ Rectangle {
opacity: Math.sin((Math.PI / 2) * swipeProgress + 1.5 * Math.PI) + 1 opacity: Math.sin((Math.PI / 2) * swipeProgress + 1.5 * Math.PI) + 1
implicitHeight: passwordBar.isPinMode ? PlasmaCore.Units.gridUnit * 17 : passwordBar.implicitHeight implicitHeight: {
if (passwordBar.isPinMode && !Qt.inputMethod.visible) {
return PlasmaCore.Units.gridUnit * 17;
} else {
return PlasmaCore.Units.smallSpacing * 2 + Qt.inputMethod.keyboardRectangle.height + passwordBar.implicitHeight;
}
}
Behavior on implicitHeight { Behavior on implicitHeight {
NumberAnimation { NumberAnimation {
duration: Kirigami.Units.longDuration duration: Kirigami.Units.longDuration

View file

@ -1,5 +1,6 @@
/* /*
SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de> SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later SPDX-License-Identifier: GPL-2.0-or-later
*/ */

View file

@ -12,6 +12,7 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.workspace.keyboardlayout 1.0 import org.kde.plasma.workspace.keyboardlayout 1.0
import org.kde.kirigami 2.12 as Kirigami import org.kde.kirigami 2.12 as Kirigami
import org.kde.plasma.workspace.keyboardlayout 1.0 as Keyboards
Rectangle { Rectangle {
id: root id: root
@ -69,6 +70,10 @@ Rectangle {
if (!authenticator.graceLocked) { if (!authenticator.graceLocked) {
authenticator.tryUnlock(root.password); authenticator.tryUnlock(root.password);
} }
if (keypadOpen && !isPinMode) {
// make sure keyboard doesn't close
openKeyboardTimer.restart();
}
} }
function keyPress(data) { function keyPress(data) {
@ -85,6 +90,15 @@ Rectangle {
} }
} }
// HACK: we have to open the virtual keyboard after a certain amount of time or else it will close anyway
Timer {
id: openKeyboardTimer
interval: 10
running: false
repeat: false
onTriggered: Keyboards.KWinVirtualKeyboard.active = true
}
// trigger turning letter into dot after 500 milliseconds // trigger turning letter into dot after 500 milliseconds
Timer { Timer {
id: letterTimer id: letterTimer
@ -148,6 +162,15 @@ Rectangle {
} }
} }
MouseArea {
anchors.fill: parent
onClicked: {
// clicking on rectangle opens keyboard if not already open
if (!isPinMode) {
Keyboards.KWinVirtualKeyboard.active = true;
}
}
// toggle between showing keypad and not // toggle between showing keypad and not
ToolButton { ToolButton {
anchors.right: parent.right anchors.right: parent.right
@ -250,3 +273,4 @@ Rectangle {
} }
} }
} }
}