mirror of
https://github.com/HenkKalkwater/sddm-nx
synced 2024-12-22 15:55:18 +00:00
Added proper Virtual Keyboard support
This commit is contained in:
parent
636e786f88
commit
c928a3556f
2
Main.qml
2
Main.qml
|
@ -1,5 +1,5 @@
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtGamepad 1.0
|
//import QtGamepad 1.0
|
||||||
import SddmComponents 2.0
|
import SddmComponents 2.0
|
||||||
|
|
||||||
import "components"
|
import "components"
|
||||||
|
|
|
@ -24,4 +24,5 @@ QtObject {
|
||||||
property int fontNormalSize: 24
|
property int fontNormalSize: 24
|
||||||
|
|
||||||
property string background: config.background ? config.background : Qt.resolvedUrl("bg.png")
|
property string background: config.background ? config.background : Qt.resolvedUrl("bg.png")
|
||||||
|
property bool virtualKeyboard: true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import QtQuick 2.6
|
import QtQuick 2.6
|
||||||
import QtQuick.Controls 2.6
|
import QtQuick.Controls 2.6
|
||||||
|
|
||||||
|
|
||||||
import ".."
|
import ".."
|
||||||
|
|
||||||
FocusScope {
|
FocusScope {
|
||||||
|
@ -22,17 +23,23 @@ FocusScope {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: Style.overlayColor
|
color: Style.overlayColor
|
||||||
|
Item {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: virtualKeyboard.top
|
||||||
TextField {
|
TextField {
|
||||||
|
id: passwordField
|
||||||
focus: true
|
focus: true
|
||||||
//anchors.top: parent.top
|
//anchors.top: parent.top
|
||||||
property real _vkeyboardOffset: Qt.inputMethod.visible
|
/*property real _vkeyboardOffset: Qt.inputMethod.visible
|
||||||
? root.height - Qt.inputMethod.keyboardRectangle.top : 0
|
? root.height - Qt.inputMethod.keyboardRectangle.top : 0
|
||||||
y: (parent.height - _vkeyboardOffset) / 2 - height / 2
|
y: (parent.height - _vkeyboardOffset) / 2 - height / 2*/
|
||||||
Behavior on y { NumberAnimation { duration: 100 }}
|
Behavior on y { NumberAnimation { duration: 100 }}
|
||||||
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
//anchors.topMargin: Style.horizontalPadding
|
//anchors.topMargin: Style.horizontalPadding
|
||||||
anchors.leftMargin: Style.horizontalContentPadding
|
anchors.leftMargin: Style.horizontalContentPadding
|
||||||
anchors.rightMargin: Style.horizontalContentPadding
|
anchors.rightMargin: Style.horizontalContentPadding
|
||||||
|
@ -60,4 +67,73 @@ FocusScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Optional virtual keyboard
|
||||||
|
Loader {
|
||||||
|
id: virtualKeyboard
|
||||||
|
source: Qt.resolvedUrl("VirtualKeyboard.qml")
|
||||||
|
width: parent.width
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
|
onLoaded: {
|
||||||
|
item.activated = Style.virtualKeyboard
|
||||||
|
Qt.inputMethod.show()
|
||||||
|
//state = "visible"
|
||||||
|
}
|
||||||
|
|
||||||
|
//opacity: item ? item.visible ? 1 : 0 : 0
|
||||||
|
state: item ? (item.active ? "visible" : "hidden" ) : "hidden"
|
||||||
|
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "visible"
|
||||||
|
PropertyChanges {
|
||||||
|
target: virtualKeyboard
|
||||||
|
anchors.bottomMargin: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "hidden"
|
||||||
|
PropertyChanges {
|
||||||
|
target: virtualKeyboard
|
||||||
|
anchors.bottomMargin: -virtualKeyboard.height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
transitions: [
|
||||||
|
Transition {
|
||||||
|
from: "visible"
|
||||||
|
to: "hidden"
|
||||||
|
|
||||||
|
SequentialAnimation {
|
||||||
|
NumberAnimation {
|
||||||
|
target: virtualKeyboard
|
||||||
|
property: "anchors.bottomMargin"
|
||||||
|
duration: 250
|
||||||
|
easing.type: Easing.InQuad
|
||||||
|
}
|
||||||
|
ScriptAction {
|
||||||
|
script: Qt.inputMethod.hide()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Transition {
|
||||||
|
from: "hidden"
|
||||||
|
to: "visible"
|
||||||
|
|
||||||
|
SequentialAnimation {
|
||||||
|
ScriptAction {
|
||||||
|
script: Qt.inputMethod.show()
|
||||||
|
}
|
||||||
|
NumberAnimation {
|
||||||
|
target: virtualKeyboard
|
||||||
|
property: "anchors.bottomMargin"
|
||||||
|
duration: 250
|
||||||
|
easing.type: Easing.OutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
9
components/VirtualKeyboard.qml
Normal file
9
components/VirtualKeyboard.qml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import QtQuick 2.6
|
||||||
|
import QtQuick.VirtualKeyboard 2.4
|
||||||
|
|
||||||
|
InputPanel {
|
||||||
|
id: virtualKeyboard
|
||||||
|
property bool activated: false
|
||||||
|
active: Qt.inputMethod.visible && activated
|
||||||
|
//visible: active
|
||||||
|
}
|
Loading…
Reference in a new issue