mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/telegramdesktop/tdesktop
synced 2026-09-21 00:23:56 +08:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user