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.Controls.Basic as Control
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Linphone
|
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 {
|
Control.TextField {
|
||||||
id: mainItem
|
id: mainItem
|
||||||
|
|
@ -10,8 +10,18 @@ Control.TextField {
|
||||||
width: (customWidth ? customWidth - 1 : 360) * DefaultStyle.dp
|
width: (customWidth ? customWidth - 1 : 360) * DefaultStyle.dp
|
||||||
height: 49 * DefaultStyle.dp
|
height: 49 * DefaultStyle.dp
|
||||||
leftPadding: 15 * 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
|
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
|
verticalAlignment: TextInput.AlignVCenter
|
||||||
color: isError ? DefaultStyle.danger_500main : DefaultStyle.main2_600
|
color: isError ? DefaultStyle.danger_500main : DefaultStyle.main2_600
|
||||||
placeholderTextColor: DefaultStyle.placeholders
|
placeholderTextColor: DefaultStyle.placeholders
|
||||||
|
|
@ -46,7 +56,8 @@ Control.TextField {
|
||||||
}
|
}
|
||||||
property bool toValidate: false
|
property bool toValidate: false
|
||||||
property int idleTimeOut: 200
|
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
|
: mainItem.propertyOwner != undefined && mainItem.propertyOwner[mainItem.propertyName]?.length == 0
|
||||||
property bool canBeEmpty: true
|
property bool canBeEmpty: true
|
||||||
|
|
||||||
|
|
@ -56,9 +67,10 @@ Control.TextField {
|
||||||
text = initialText
|
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()
|
idleTimer.stop()
|
||||||
updateText()
|
updateText()
|
||||||
}
|
}
|
||||||
|
|
@ -85,7 +97,8 @@ Control.TextField {
|
||||||
mainItem.propertyOwner[mainItem.propertyName] = text
|
mainItem.propertyOwner[mainItem.propertyName] = text
|
||||||
}
|
}
|
||||||
mainItem.validationChecked(true)
|
mainItem.validationChecked(true)
|
||||||
} else mainItem.validationChecked(false)
|
} else
|
||||||
|
mainItem.validationChecked(false)
|
||||||
}
|
}
|
||||||
// Validation textfield functions
|
// Validation textfield functions
|
||||||
Timer {
|
Timer {
|
||||||
|
|
@ -104,11 +117,7 @@ Control.TextField {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: 79 * DefaultStyle.dp
|
radius: 79 * DefaultStyle.dp
|
||||||
color: mainItem.enabled ? mainItem.backgroundColor : mainItem.disabledBackgroundColor
|
color: mainItem.enabled ? mainItem.backgroundColor : mainItem.disabledBackgroundColor
|
||||||
border.color: mainItem.isError
|
border.color: mainItem.isError ? DefaultStyle.danger_500main : mainItem.activeFocus ? DefaultStyle.main1_500_main : mainItem.backgroundBorderColor
|
||||||
? DefaultStyle.danger_500main
|
|
||||||
: mainItem.activeFocus
|
|
||||||
? DefaultStyle.main1_500_main
|
|
||||||
: mainItem.backgroundBorderColor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cursorDelegate: Rectangle {
|
cursorDelegate: Rectangle {
|
||||||
|
|
@ -146,17 +155,20 @@ Control.TextField {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Keys.onPressed: (event) => {
|
Keys.onPressed: event => {
|
||||||
if (event.key == Qt.Key_Control) mainItem.controlIsDown = true
|
if (event.key == Qt.Key_Control)
|
||||||
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
mainItem.controlIsDown = true
|
||||||
|
if (event.key === Qt.Key_Enter
|
||||||
|
|| event.key === Qt.Key_Return) {
|
||||||
enterPressed()
|
enterPressed()
|
||||||
if (mainItem.controlIsDown) {
|
if (mainItem.controlIsDown) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Keys.onReleased: (event) => {
|
Keys.onReleased: event => {
|
||||||
if (event.jey == Qt.Key_Control) mainItem.controlIsDown = false
|
if (event.jey == Qt.Key_Control)
|
||||||
|
mainItem.controlIsDown = false
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
|
|
@ -177,4 +189,3 @@ Control.TextField {
|
||||||
anchors.rightMargin: rightMargin
|
anchors.rightMargin: rightMargin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue