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>
This commit is contained in:
Volker Hilsheimer 2021-05-06 17:07:41 +02:00
parent 35396e12eb
commit d85794c231

View File

@ -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();