Set input method hints in typed input fields

Phone, e-mail, URL, username, code, date and amount fields now tell the
input method what they are for, so it can pick a suitable layout and skip
predictive text where it only gets in the way. One-time codes and secrets
are additionally marked with Qt::ImhSensitiveData.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilya Fedin
2026-08-12 12:11:34 +04:00
committed by John Preston
parent 998c2456d8
commit 6989eeb1be
21 changed files with 111 additions and 1 deletions

View File

@@ -31,6 +31,8 @@ CountryCodeInput::CountryCodeInput(
QWidget *parent,
const style::InputField &st)
: MaskedInputField(parent, st) {
setInputMethodHints(Qt::ImhDialableCharactersOnly
| Qt::ImhNoPredictiveText);
}
void CountryCodeInput::startErasing(QKeyEvent *e) {
@@ -111,6 +113,8 @@ PhonePartInput::PhonePartInput(
PhonePartInput::GroupsCallback groupsCallback)
: MaskedInputField(parent, st/*, tr::lng_phone_ph(tr::now)*/)
, _groupsCallback(std::move(groupsCallback)) {
setInputMethodHints(Qt::ImhDialableCharactersOnly
| Qt::ImhNoPredictiveText);
}
void PhonePartInput::paintAdditionalPlaceholder(QPainter &p) {
@@ -269,6 +273,9 @@ UsernameInput::UsernameInput(
const QString &val,
const QString &linkPlaceholder)
: MaskedInputField(parent, st, std::move(placeholder), val) {
setInputMethodHints(Qt::ImhLatinOnly
| Qt::ImhNoAutoUppercase
| Qt::ImhNoPredictiveText);
setLinkPlaceholder(linkPlaceholder);
}
@@ -332,6 +339,8 @@ PhoneInput::PhoneInput(
: MaskedInputField(parent, st, std::move(placeholder), value)
, _defaultValue(defaultValue)
, _groupsCallback(std::move(groupsCallback)) {
setInputMethodHints(Qt::ImhDialableCharactersOnly
| Qt::ImhNoPredictiveText);
if (value.isEmpty()) {
clearText();
} else {