workaround for Qt bug on Password echo mode in textfields
This commit is contained in:
parent
711feabcf0
commit
de0728651e
1 changed files with 146 additions and 135 deletions
|
|
@ -2,7 +2,7 @@ import QtQuick
|
|||
import QtQuick.Controls.Basic as Control
|
||||
import QtQuick.Layouts
|
||||
import Linphone
|
||||
import 'qrc:/qt/qml/Linphone/view/Style/buttonStyle.js' as ButtonStyle
|
||||
import "qrc:/qt/qml/Linphone/view/Style/buttonStyle.js" as ButtonStyle
|
||||
|
||||
Control.TextField {
|
||||
id: mainItem
|
||||
|
|
@ -10,8 +10,18 @@ Control.TextField {
|
|||
width: (customWidth ? customWidth - 1 : 360) * DefaultStyle.dp
|
||||
height: 49 * DefaultStyle.dp
|
||||
leftPadding: 15 * DefaultStyle.dp
|
||||
rightPadding: eyeButton.visible ? 5 * DefaultStyle.dp + eyeButton.width + eyeButton.rightMargin : 15 * DefaultStyle.dp
|
||||
rightPadding: eyeButton.visible
|
||||
? 5 * DefaultStyle.dp + eyeButton.width + eyeButton.rightMargin
|
||||
: 15 * DefaultStyle.dp
|
||||
echoMode: (hidden && !eyeButton.checked) ? TextInput.Password : TextInput.Normal
|
||||
|
||||
// Workaround for Windows slowness when first typing a password
|
||||
// due to Qt not initializing the Password echo mode before the first letter is typed
|
||||
Component.onCompleted: {
|
||||
text = "workaround"
|
||||
resetText()
|
||||
}
|
||||
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
color: isError ? DefaultStyle.danger_500main : DefaultStyle.main2_600
|
||||
placeholderTextColor: DefaultStyle.placeholders
|
||||
|
|
@ -46,7 +56,8 @@ Control.TextField {
|
|||
}
|
||||
property bool toValidate: false
|
||||
property int idleTimeOut: 200
|
||||
property bool empty: propertyOwnerGui ? mainItem.propertyOwnerGui.core != undefined && mainItem.propertyOwnerGui.core[mainItem.propertyName]?.length == 0
|
||||
property bool empty: propertyOwnerGui
|
||||
? mainItem.propertyOwnerGui.core != undefined && mainItem.propertyOwnerGui.core[mainItem.propertyName]?.length == 0
|
||||
: mainItem.propertyOwner != undefined && mainItem.propertyOwner[mainItem.propertyName]?.length == 0
|
||||
property bool canBeEmpty: true
|
||||
|
||||
|
|
@ -56,9 +67,10 @@ Control.TextField {
|
|||
text = initialText
|
||||
}
|
||||
|
||||
signal enterPressed()
|
||||
signal enterPressed
|
||||
|
||||
onAccepted: {// No need to process changing focus because of TextEdited callback.
|
||||
onAccepted: {
|
||||
// No need to process changing focus because of TextEdited callback.
|
||||
idleTimer.stop()
|
||||
updateText()
|
||||
}
|
||||
|
|
@ -85,7 +97,8 @@ Control.TextField {
|
|||
mainItem.propertyOwner[mainItem.propertyName] = text
|
||||
}
|
||||
mainItem.validationChecked(true)
|
||||
} else mainItem.validationChecked(false)
|
||||
} else
|
||||
mainItem.validationChecked(false)
|
||||
}
|
||||
// Validation textfield functions
|
||||
Timer {
|
||||
|
|
@ -104,11 +117,7 @@ Control.TextField {
|
|||
anchors.fill: parent
|
||||
radius: 79 * DefaultStyle.dp
|
||||
color: mainItem.enabled ? mainItem.backgroundColor : mainItem.disabledBackgroundColor
|
||||
border.color: mainItem.isError
|
||||
? DefaultStyle.danger_500main
|
||||
: mainItem.activeFocus
|
||||
? DefaultStyle.main1_500_main
|
||||
: mainItem.backgroundBorderColor
|
||||
border.color: mainItem.isError ? DefaultStyle.danger_500main : mainItem.activeFocus ? DefaultStyle.main1_500_main : mainItem.backgroundBorderColor
|
||||
}
|
||||
|
||||
cursorDelegate: Rectangle {
|
||||
|
|
@ -146,17 +155,20 @@ Control.TextField {
|
|||
}
|
||||
}
|
||||
}
|
||||
Keys.onPressed: (event) => {
|
||||
if (event.key == Qt.Key_Control) mainItem.controlIsDown = true
|
||||
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
||||
Keys.onPressed: event => {
|
||||
if (event.key == Qt.Key_Control)
|
||||
mainItem.controlIsDown = true
|
||||
if (event.key === Qt.Key_Enter
|
||||
|| event.key === Qt.Key_Return) {
|
||||
enterPressed()
|
||||
if (mainItem.controlIsDown) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Keys.onReleased: (event) => {
|
||||
if (event.jey == Qt.Key_Control) mainItem.controlIsDown = false
|
||||
Keys.onReleased: event => {
|
||||
if (event.jey == Qt.Key_Control)
|
||||
mainItem.controlIsDown = false
|
||||
}
|
||||
|
||||
Button {
|
||||
|
|
@ -177,4 +189,3 @@ Control.TextField {
|
|||
anchors.rightMargin: rightMargin
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue