From 7b44d107c9d7cd134aba4b20c4846e663dbf6110 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 30 Mar 2020 15:10:08 +0400 Subject: [PATCH] Don't use default title if it doesn't fit. --- Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp b/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp index db935d7cc..d0cea28d9 100644 --- a/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp +++ b/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp @@ -468,6 +468,10 @@ void CreateIconSelector( return QString(); } +[[nodiscard]] QString TrimDefaultTitle(const QString &title) { + return (title.size() <= kMaxFilterTitleLength) ? title : QString(); +} + } // namespace void EditFilterBox( @@ -511,7 +515,7 @@ void EditFilterBox( if (nameEditing->custom) { return; } - const auto title = DefaultTitle(filter); + const auto title = TrimDefaultTitle(DefaultTitle(filter)); if (nameEditing->field->getLastText() != title) { nameEditing->settingDefault = true; nameEditing->field->setText(title);