Added updating of spell highlighter when enabled languages are changed.

This commit is contained in:
23rd 2020-01-31 01:58:08 +03:00
parent 4cc46f1ffa
commit 26a45885ff
2 changed files with 21 additions and 0 deletions

View File

@ -283,15 +283,34 @@ void InitSpellchecker(
if (!Platform::Spellchecker::IsAvailable()) {
return;
}
Spellchecker::SetWorkingDirPath(Spellchecker::DictionariesPath());
const auto s = Ui::CreateChild<Spellchecker::SpellingHighlighter>(
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
}

View File

@ -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 <QtGui/QClipboard>