summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-05-06 17:07:41 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-05-12 14:49:45 +0200
commitd85794c231dba314889cc2941014c422d22871db (patch)
treed0a93499f5630b2bb9d28c8a731447a31261070e /src
parent35396e12eb73c5d7d45e903a1d617e76ad0aca3f (diff)
Respect Password and NoEcho mode while pre-editing
During composition of text using an input method, incomplete characters should not be visible at all in NoEcho mode, and should be replaced by the password character in Password mode. In NoEcho mode, when the cursor is always at position 0, the pre-edit cursor should also always be at that position so that the UI doesn't give away the length of the text entered so far. Task-number: QTBUG-84664 Change-Id: I44a30eee3f5c6fe9fa00073b0a8ac3c333fbaa59 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 77c62b106b..35541b455c 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -573,7 +573,21 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
}
}
#ifndef QT_NO_IM
- setPreeditArea(m_cursor, event->preeditString());
+ // in NoEcho mode, the cursor is always at the beginning of the lineedit
+ switch (m_echoMode) {
+ case QLineEdit::NoEcho:
+ setPreeditArea(0, QString());
+ break;
+ case QLineEdit::Password: {
+ QString preeditString = event->preeditString();
+ preeditString.fill(m_passwordCharacter);
+ setPreeditArea(m_cursor, preeditString);
+ break;
+ }
+ default:
+ setPreeditArea(m_cursor, event->preeditString());
+ break;
+ }
#endif //QT_NO_IM
const int oldPreeditCursor = m_preeditCursor;
m_preeditCursor = event->preeditString().length();