1
0
Fork 0
mirror of https://github.com/HenkKalkwater/sddm-nx synced 2024-07-01 09:23:51 +00:00
sddm-nx/components/PasswordOverlay.qml

140 lines
4.5 KiB
QML
Raw Normal View History

2020-05-14 23:12:55 +00:00
import QtQuick 2.6
import QtQuick.Controls 2.6
2020-05-18 10:54:49 +00:00
2020-05-14 23:12:55 +00:00
import ".."
FocusScope {
id: overlay
property string username
signal passwordEntered(string password)
signal cancelled()
Connections {
target: Qt.inputMethod
onVisibleChanged: {
if (!Qt.inputMethod.visible) cancelled()
}
}
Rectangle {
anchors.fill: parent
color: Style.overlayColor
2020-05-18 10:54:49 +00:00
Item {
2020-05-14 23:12:55 +00:00
anchors.left: parent.left
2020-05-18 10:54:49 +00:00
anchors.top: parent.top
2020-05-14 23:12:55 +00:00
anchors.right: parent.right
2020-05-18 10:54:49 +00:00
anchors.bottom: virtualKeyboard.top
TextField {
id: passwordField
focus: true
//anchors.top: parent.top
/*property real _vkeyboardOffset: Qt.inputMethod.visible
? root.height - Qt.inputMethod.keyboardRectangle.top : 0
y: (parent.height - _vkeyboardOffset) / 2 - height / 2*/
Behavior on y { NumberAnimation { duration: 100 }}
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
//anchors.topMargin: Style.horizontalPadding
anchors.leftMargin: Style.horizontalContentPadding
anchors.rightMargin: Style.horizontalContentPadding
padding: Style.mediumPadding
color: Style.foregroundColor
echoMode: TextInput.Password
placeholderText: "Enter the password for %1".arg(username)
//color: Style.foregroundColor
font.pixelSize: Style.fontTitleSize
background: Rectangle {
color: "#00000000"
border.width: Style.highlightBorderSize
border.color: Style.backgroundColor2
}
Keys.onEscapePressed: cancelled()
onAccepted: {
passwordEntered(text)
text = ""
}
}
}
// Optional virtual keyboard
Loader {
id: virtualKeyboard
source: Qt.resolvedUrl("VirtualKeyboard.qml")
width: parent.width
anchors.bottom: parent.bottom
2020-05-14 23:12:55 +00:00
2020-05-18 10:54:49 +00:00
onLoaded: {
item.activated = Style.virtualKeyboard
Qt.inputMethod.show()
//state = "visible"
2020-05-14 23:12:55 +00:00
}
2020-05-18 10:54:49 +00:00
//opacity: item ? item.visible ? 1 : 0 : 0
state: item ? (item.active ? "visible" : "hidden" ) : "hidden"
2020-05-14 23:12:55 +00:00
2020-05-18 10:54:49 +00:00
states: [
State {
name: "visible"
PropertyChanges {
target: virtualKeyboard
anchors.bottomMargin: 0
}
},
State {
name: "hidden"
PropertyChanges {
target: virtualKeyboard
anchors.bottomMargin: -virtualKeyboard.height
}
}
]
2020-05-14 23:12:55 +00:00
2020-05-18 10:54:49 +00:00
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
}
}
}
]
2020-05-14 23:12:55 +00:00
}
}
}