diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index bb74d7311..dcebb2628 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -1068,7 +1068,7 @@ void EditTagBox( } }, field->lifetime()); - AddLengthLimitLabel(field, kTagNameLimit); + Ui::AddLengthLimitLabel(field, kTagNameLimit); const auto save = [=] { const auto text = field->getLastText(); @@ -1828,40 +1828,4 @@ bool ItemHasTtl(HistoryItem *item) { : false; } -void AddLengthLimitLabel(not_null field, int limit) { - struct State { - rpl::variable length; - }; - const auto state = field->lifetime().make_state(); - state->length = rpl::single( - rpl::empty - ) | rpl::then(field->changes()) | rpl::map([=] { - return int(field->getLastText().size()); - }); - auto warningText = state->length.value() | rpl::map([=](int count) { - const auto threshold = std::min(limit / 2, 9); - const auto left = limit - count; - return (left < threshold) ? QString::number(left) : QString(); - }); - const auto warning = Ui::CreateChild( - field.get(), - std::move(warningText), - st::editTagLimit); - state->length.value() | rpl::map( - rpl::mappers::_1 > limit - ) | rpl::start_with_next([=](bool exceeded) { - warning->setTextColorOverride(exceeded - ? st::attentionButtonFg->c - : std::optional()); - }, warning->lifetime()); - rpl::combine( - field->sizeValue(), - warning->sizeValue() - ) | rpl::start_with_next([=] { - warning->moveToRight(0, 0); - }, warning->lifetime()); - warning->setAttribute(Qt::WA_TransparentForMouseEvents); - -} - } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.h b/Telegram/SourceFiles/history/view/history_view_context_menu.h index 8582a57fb..8f00f4da8 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.h +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.h @@ -123,6 +123,4 @@ void AddEmojiPacksAction( [[nodiscard]] bool ItemHasTtl(HistoryItem *item); -void AddLengthLimitLabel(not_null field, int limit); - } // namespace HistoryView diff --git a/Telegram/SourceFiles/settings/business/settings_chat_intro.cpp b/Telegram/SourceFiles/settings/business/settings_chat_intro.cpp index b8a7607f6..b9fa7c68c 100644 --- a/Telegram/SourceFiles/settings/business/settings_chat_intro.cpp +++ b/Telegram/SourceFiles/settings/business/settings_chat_intro.cpp @@ -164,7 +164,7 @@ private: current), st::settingsChatIntroFieldMargins); field->setMaxLength(limit); - AddLengthLimitLabel(field, limit); + Ui::AddLengthLimitLabel(field, limit); return field; } diff --git a/Telegram/SourceFiles/settings/business/settings_quick_replies.cpp b/Telegram/SourceFiles/settings/business/settings_quick_replies.cpp index 57e74cf25..941409f98 100644 --- a/Telegram/SourceFiles/settings/business/settings_quick_replies.cpp +++ b/Telegram/SourceFiles/settings/business/settings_quick_replies.cpp @@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/application.h" #include "data/business/data_shortcut_messages.h" #include "data/data_session.h" -#include "history/view/history_view_context_menu.h" // AddLengthLimitLabel. #include "lang/lang_keys.h" #include "main/main_account.h" #include "main/main_session.h" @@ -214,7 +213,7 @@ void EditShortcutNameBox( field->selectAll(); field->setMaxLength(kShortcutLimit * 2); - HistoryView::AddLengthLimitLabel(field, kShortcutLimit); + Ui::AddLengthLimitLabel(field, kShortcutLimit); const auto callback = [=] { const auto name = field->getLastText().trimmed();