summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-05-27 17:18:27 +0300
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-08-11 13:27:37 +0000
commit8de79dbcecb2ac3eb9c07d9e401c25733e1dc192 (patch)
tree168ac5b9200a4d82cc60903b5e236cfb86cf07eb /src/widgets/widgets
parent49cb039a5c15d434514e81a7573778c8b2db566a (diff)
Widgets: Fix ImSurroundingText query for a QLineEdit with mask
QLineEdit with a mask does not return empty fields with the ImSurroundingText query. This is a problem for the input context that is not aware of the mask and relies on the fact that the cursor position never exceeds the boundaries of the surrounding text. This change fixes the issue by returning unmasked text with the ImSurroundingText query. [ChangeLog][QtWidgets][QLineEdit] Fixed behavior of the ImSurroundingText query. Previously, it returned a masked text whose length may be less than the cursor position. Now it returns unmasked text, so the text length is always greater than or equal to the cursor position. Task-number: QTBUG-60319 Change-Id: I1c8009164836a1baa2e3a45958bf1ea5fa9be38d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qlineedit.cpp2
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h5
2 files changed, 6 insertions, 1 deletions
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 50eb1a7371..449a9c0b33 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1773,7 +1773,7 @@ QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property, QVariant arg
return QVariant(d->xToPos(pt.x(), QTextLine::CursorBetweenCharacters));
return QVariant(d->control->cursor()); }
case Qt::ImSurroundingText:
- return QVariant(d->control->text());
+ return QVariant(d->control->surroundingText());
case Qt::ImCurrentSelection:
return QVariant(selectedText());
case Qt::ImMaximumTextLength:
diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h
index b9340c0aff..257402e9dc 100644
--- a/src/widgets/widgets/qwidgetlinecontrol_p.h
+++ b/src/widgets/widgets/qwidgetlinecontrol_p.h
@@ -250,6 +250,11 @@ public:
QString displayText() const { return m_textLayout.text(); }
+ QString surroundingText() const
+ {
+ return m_text.isNull() ? QString::fromLatin1("") : m_text;
+ }
+
void backspace();
void del();
void deselect() { internalDeselect(); finishChange(); }