2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 08:55:59 +00:00

Adjusted code for refactor of input fields in lib_ui.

This commit is contained in:
23rd
2023-08-31 14:21:24 +03:00
committed by John Preston
parent ae2182c1e5
commit 98bb520f47
89 changed files with 413 additions and 300 deletions

View File

@@ -190,16 +190,18 @@ void EditLinkBox(
}
};
QObject::connect(text, &Ui::InputField::submitted, [=] {
text->submits(
) | rpl::start_with_next([=] {
url->setFocusFast();
});
QObject::connect(url, &Ui::InputField::submitted, [=] {
}, text->lifetime());
url->submits(
) | rpl::start_with_next([=] {
if (text->getLastText().isEmpty()) {
text->setFocusFast();
} else {
submit();
}
});
}, url->lifetime());
box->setTitle(url->getLastText().isEmpty()
? tr::lng_formatting_link_create_title()
@@ -223,8 +225,14 @@ void EditLinkBox(
url->customTab(true);
text->customTab(true);
QObject::connect(url, &Ui::InputField::tabbed, [=] { text->setFocus(); });
QObject::connect(text, &Ui::InputField::tabbed, [=] { url->setFocus(); });
url->tabbed(
) | rpl::start_with_next([=] {
text->setFocus();
}, url->lifetime());
text->tabbed(
) | rpl::start_with_next([=] {
url->setFocus();
}, text->lifetime());
}
TextWithEntities StripSupportHashtag(TextWithEntities text) {
@@ -590,7 +598,8 @@ AutocompleteQuery ParseMentionHashtagBotCommandQuery(
MessageLinksParser::MessageLinksParser(not_null<Ui::InputField*> field)
: _field(field)
, _timer([=] { parse(); }) {
_connection = QObject::connect(_field, &Ui::InputField::changed, [=] {
_lifetime = _field->changes(
) | rpl::start_with_next([=] {
const auto length = _field->getTextWithTags().text.size();
const auto timeout = (std::abs(length - _lastLength) > 2)
? 0