diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 1b2d530834..1425682857 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -283,15 +283,34 @@ void InitSpellchecker( if (!Platform::Spellchecker::IsAvailable()) { return; } + + Spellchecker::SetWorkingDirPath(Spellchecker::DictionariesPath()); + const auto s = Ui::CreateChild( field.get(), session->settings().spellcheckerEnabledValue()); + + const auto applyDictionaries = [=] { + crl::async([=] { + Platform::Spellchecker::UpdateLanguages( + session->settings().dictionariesEnabled()); + crl::on_main([=] { + s->checkCurrentText(); + }); + }); + }; + session->settings().dictionariesChanges( + ) | rpl::start_with_next(applyDictionaries, field->lifetime()); + Spellchecker::SetPhrases({ { { &ph::lng_spellchecker_add, tr::lng_spellchecker_add() }, { &ph::lng_spellchecker_remove, tr::lng_spellchecker_remove() }, { &ph::lng_spellchecker_ignore, tr::lng_spellchecker_ignore() }, } }); + field->setExtendedContextMenu(s->contextMenuCreated()); + + applyDictionaries(); #endif // TDESKTOP_DISABLE_SPELLCHECK } diff --git a/Telegram/SourceFiles/chat_helpers/message_field.h b/Telegram/SourceFiles/chat_helpers/message_field.h index 8f95a93239..49c4ec8fb5 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.h +++ b/Telegram/SourceFiles/chat_helpers/message_field.h @@ -12,7 +12,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/qt_connection.h" #ifndef TDESKTOP_DISABLE_SPELLCHECK +#include "boxes/dictionaries_manager.h" #include "spellcheck/spelling_highlighter.h" +#include "spellcheck/spellcheck_value.h" #endif // TDESKTOP_DISABLE_SPELLCHECK #include