fix(@desktop/general): use utf-8 text for calculating 'StatusBaseInput' text length and current length in 'StatusInput'
This commit is contained in:
parent
69677a7c1c
commit
e3b088eaea
|
@ -371,7 +371,8 @@ Item {
|
||||||
}
|
}
|
||||||
root.dirty = true
|
root.dirty = true
|
||||||
if (root.maximumLength > 0) {
|
if (root.maximumLength > 0) {
|
||||||
if (text.length > root.maximumLength) {
|
let utf8Length = Utils.encodeUtf8(text).length
|
||||||
|
if (utf8Length > root.maximumLength) {
|
||||||
var cursor = cursorPosition
|
var cursor = cursorPosition
|
||||||
text = previousText
|
text = previousText
|
||||||
if (cursor > text.length) {
|
if (cursor > text.length) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import StatusQ.Core.Backpressure 1.0
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
import StatusQ.Controls 0.1
|
import StatusQ.Controls 0.1
|
||||||
import StatusQ.Controls.Validators 0.1
|
import StatusQ.Controls.Validators 0.1
|
||||||
|
import StatusQ.Core.Utils 0.1
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\qmltype StatusInput
|
\qmltype StatusInput
|
||||||
|
@ -256,10 +257,12 @@ Item {
|
||||||
\qmlmethod
|
\qmlmethod
|
||||||
This function validates the text input's text.
|
This function validates the text input's text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function validate(force) {
|
function validate(force) {
|
||||||
if (!force && !statusBaseInput.dirty && validationMode === StatusInput.ValidationMode.OnlyWhenDirty) {
|
if (!force && !statusBaseInput.dirty && validationMode === StatusInput.ValidationMode.OnlyWhenDirty) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
statusBaseInput.valid = true
|
statusBaseInput.valid = true
|
||||||
if (validators.length) {
|
if (validators.length) {
|
||||||
for (let idx in validators) {
|
for (let idx in validators) {
|
||||||
|
@ -403,7 +406,7 @@ Item {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
height: visible ? contentHeight : 0
|
height: visible ? contentHeight : 0
|
||||||
visible: root.charLimit > 0
|
visible: root.charLimit > 0
|
||||||
text: "%1 / %2".arg(statusBaseInput.text.length).arg(root.charLimit)
|
text: "%1 / %2".arg(Utils.encodeUtf8(statusBaseInput.text).length).arg(root.charLimit)
|
||||||
font.pixelSize: 12
|
font.pixelSize: 12
|
||||||
color: statusBaseInput.enabled ? Theme.palette.baseColor1 : Theme.palette.directColor6
|
color: statusBaseInput.enabled ? Theme.palette.baseColor1 : Theme.palette.directColor6
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,6 +265,10 @@ QtObject {
|
||||||
else if (flickableBottom <= rectBottom)
|
else if (flickableBottom <= rectBottom)
|
||||||
flickable.contentY = rectBottom - flickable.height
|
flickable.contentY = rectBottom - flickable.height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function encodeUtf8(str){
|
||||||
|
return unescape( encodeURIComponent(str));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue