mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed autodownloading of dictionaries at logout.
This commit is contained in:
parent
972bbbce6a
commit
2576312cd4
1 changed files with 31 additions and 19 deletions
|
@ -14,6 +14,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "lang/lang_instance.h"
|
#include "lang/lang_instance.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "main/main_account.h"
|
||||||
|
#include "main/main_domain.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "spellcheck/platform/platform_spellcheck.h"
|
#include "spellcheck/platform/platform_spellcheck.h"
|
||||||
|
@ -377,6 +379,7 @@ void Start(not_null<Main::Session*> session) {
|
||||||
{ &ph::lng_spellchecker_ignore, tr::lng_spellchecker_ignore() },
|
{ &ph::lng_spellchecker_ignore, tr::lng_spellchecker_ignore() },
|
||||||
} });
|
} });
|
||||||
const auto settings = &Core::App().settings();
|
const auto settings = &Core::App().settings();
|
||||||
|
auto &lifetime = session->lifetime();
|
||||||
|
|
||||||
const auto onEnabled = [=](auto enabled) {
|
const auto onEnabled = [=](auto enabled) {
|
||||||
Platform::Spellchecker::UpdateLanguages(
|
Platform::Spellchecker::UpdateLanguages(
|
||||||
|
@ -390,31 +393,25 @@ void Start(not_null<Main::Session*> session) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Platform::Spellchecker::IsSystemSpellchecker()) {
|
if (Platform::Spellchecker::IsSystemSpellchecker()) {
|
||||||
|
Spellchecker::SupportedScriptsChanged()
|
||||||
const auto scriptsLifetime =
|
| rpl::take(1)
|
||||||
session->lifetime().make_state<rpl::lifetime>();
|
| rpl::start_with_next(AddExceptions, lifetime);
|
||||||
|
|
||||||
Spellchecker::SupportedScriptsChanged(
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
AddExceptions();
|
|
||||||
scriptsLifetime->destroy();
|
|
||||||
}, *scriptsLifetime);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Spellchecker::SupportedScriptsChanged(
|
Spellchecker::SupportedScriptsChanged(
|
||||||
) | rpl::start_with_next(AddExceptions, session->lifetime());
|
) | rpl::start_with_next(AddExceptions, lifetime);
|
||||||
|
|
||||||
Spellchecker::SetWorkingDirPath(DictionariesPath());
|
Spellchecker::SetWorkingDirPath(DictionariesPath());
|
||||||
|
|
||||||
settings->dictionariesEnabledChanges(
|
settings->dictionariesEnabledChanges(
|
||||||
) | rpl::start_with_next([](auto dictionaries) {
|
) | rpl::start_with_next([](auto dictionaries) {
|
||||||
Platform::Spellchecker::UpdateLanguages(dictionaries);
|
Platform::Spellchecker::UpdateLanguages(dictionaries);
|
||||||
}, session->lifetime());
|
}, lifetime);
|
||||||
|
|
||||||
settings->spellcheckerEnabledChanges(
|
settings->spellcheckerEnabledChanges(
|
||||||
) | rpl::start_with_next(onEnabled, session->lifetime());
|
) | rpl::start_with_next(onEnabled, lifetime);
|
||||||
|
|
||||||
const auto method = QGuiApplication::inputMethod();
|
const auto method = QGuiApplication::inputMethod();
|
||||||
|
|
||||||
|
@ -448,11 +445,30 @@ void Start(not_null<Main::Session*> session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadDictionaryInBackground(session, 0, DefaultLanguages());
|
DownloadDictionaryInBackground(session, 0, DefaultLanguages());
|
||||||
}, session->lifetime());
|
}, lifetime);
|
||||||
|
|
||||||
connectInput();
|
connectInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto disconnect = [=] {
|
||||||
|
QObject::disconnect(
|
||||||
|
method,
|
||||||
|
&QInputMethod::localeChanged,
|
||||||
|
nullptr,
|
||||||
|
nullptr);
|
||||||
|
};
|
||||||
|
lifetime.add([=] {
|
||||||
|
disconnect();
|
||||||
|
for (auto &[index, account] : session->domain().accounts()) {
|
||||||
|
if (const auto anotherSession = account->maybeSession()) {
|
||||||
|
if (anotherSession->uniqueId() != session->uniqueId()) {
|
||||||
|
Spellchecker::Start(anotherSession);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
settings->spellcheckerEnabledValue(),
|
settings->spellcheckerEnabledValue(),
|
||||||
settings->autoDownloadDictionariesValue()
|
settings->autoDownloadDictionariesValue()
|
||||||
|
@ -461,12 +477,8 @@ void Start(not_null<Main::Session*> session) {
|
||||||
connectInput();
|
connectInput();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QObject::disconnect(
|
disconnect();
|
||||||
method,
|
}, lifetime);
|
||||||
&QInputMethod::localeChanged,
|
|
||||||
nullptr,
|
|
||||||
nullptr);
|
|
||||||
}, session->lifetime());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue