diff --git a/Telegram/SourceFiles/boxes/create_poll_box.cpp b/Telegram/SourceFiles/boxes/create_poll_box.cpp index 8ab638bf8a..960f82418a 100644 --- a/Telegram/SourceFiles/boxes/create_poll_box.cpp +++ b/Telegram/SourceFiles/boxes/create_poll_box.cpp @@ -137,7 +137,9 @@ void InitField( not_null field) { field->setInstantReplaces(Ui::InstantReplaces::Default()); field->setInstantReplacesEnabled(Global::ReplaceEmojiValue()); - Ui::Emoji::SuggestionsController::Init(container, field); + auto options = Ui::Emoji::SuggestionsController::Options(); + options.suggestExactFirstWord = false; + Ui::Emoji::SuggestionsController::Init(container, field, options); } not_null CreateWarningLabel( diff --git a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp index e765a49953..a0137f5a6a 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp @@ -503,9 +503,11 @@ void SuggestionsWidget::leaveEventHook(QEvent *e) { SuggestionsController::SuggestionsController( not_null outer, - not_null field) + not_null field, + const Options &options) : _field(field) -, _showExactTimer([=] { showWithQuery(getEmojiQuery()); }) { +, _showExactTimer([=] { showWithQuery(getEmojiQuery()); }) +, _options(options) { _container = base::make_unique_q( outer, st::emojiSuggestionsDropdown); @@ -555,11 +557,13 @@ SuggestionsController::SuggestionsController( SuggestionsController *SuggestionsController::Init( not_null outer, - not_null field) { + not_null field, + const Options &options) { const auto result = Ui::CreateChild( field.get(), outer, - field->rawTextEdit()); + field->rawTextEdit(), + options); result->setReplaceCallback([=]( int from, int till, @@ -679,7 +683,8 @@ QString SuggestionsController::getEmojiQuery() { const auto is = [&](QLatin1String string) { return (text.compare(string, Qt::CaseInsensitive) == 0); }; - if (!length + if (!_options.suggestExactFirstWord + || !length || text[0].isSpace() || (length > modernLimit) || (_queryStartPosition != 0) diff --git a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.h b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.h index 79a164d917..ffafb2ebe0 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.h +++ b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.h @@ -96,9 +96,14 @@ private: class SuggestionsController { public: + struct Options { + bool suggestExactFirstWord = true; + }; + SuggestionsController( not_null outer, - not_null field); + not_null field, + const Options &options); void raise(); void setReplaceCallback(Fn outer, - not_null field); + not_null field, + const Options &options = Options()); private: void handleCursorPositionChange(); @@ -139,6 +145,7 @@ private: base::Timer _showExactTimer; bool _keywordsRefreshed = false; QString _lastShownQuery; + Options _options; rpl::lifetime _lifetime;