mirror of
https://github.com/vale981/tdesktop
synced 2025-03-04 17:21:40 -05:00
Added new setting to disable spellchecker.
This commit is contained in:
parent
d535f5b3bc
commit
1056021059
4 changed files with 55 additions and 0 deletions
|
@ -410,6 +410,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_settings_enable_animations" = "Enable animations";
|
||||
"lng_settings_autoplay_gifs" = "Autoplay GIFs";
|
||||
|
||||
"lng_settings_spellchecker" = "Spell checker";
|
||||
"lng_settings_system_spellchecker" = "Use system spell checker";
|
||||
|
||||
"lng_backgrounds_header" = "Choose your new chat background";
|
||||
"lng_theme_sure_keep" = "Keep this theme?";
|
||||
"lng_theme_reverting#one" = "Reverting to the old theme in {count} second.";
|
||||
|
|
|
@ -89,6 +89,7 @@ QByteArray Settings::serialize() const {
|
|||
stream << qint32(_variables.replaceEmoji.current() ? 1 : 0);
|
||||
stream << qint32(_variables.suggestEmoji ? 1 : 0);
|
||||
stream << qint32(_variables.suggestStickersByEmoji ? 1 : 0);
|
||||
stream << qint32(_variables.spellcheckerEnabled.current() ? 1 : 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -135,6 +136,7 @@ void Settings::constructFromSerialized(const QByteArray &serialized) {
|
|||
qint32 replaceEmoji = _variables.replaceEmoji.current() ? 1 : 0;
|
||||
qint32 suggestEmoji = _variables.suggestEmoji ? 1 : 0;
|
||||
qint32 suggestStickersByEmoji = _variables.suggestStickersByEmoji ? 1 : 0;
|
||||
qint32 spellcheckerEnabled = _variables.spellcheckerEnabled.current() ? 1 : 0;
|
||||
|
||||
stream >> selectorTab;
|
||||
stream >> lastSeenWarningSeen;
|
||||
|
@ -234,6 +236,9 @@ void Settings::constructFromSerialized(const QByteArray &serialized) {
|
|||
stream >> suggestEmoji;
|
||||
stream >> suggestStickersByEmoji;
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> spellcheckerEnabled;
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for Main::Settings::constructFromSerialized()"));
|
||||
|
@ -313,6 +318,7 @@ void Settings::constructFromSerialized(const QByteArray &serialized) {
|
|||
_variables.replaceEmoji = (replaceEmoji == 1);
|
||||
_variables.suggestEmoji = (suggestEmoji == 1);
|
||||
_variables.suggestStickersByEmoji = (suggestStickersByEmoji == 1);
|
||||
_variables.spellcheckerEnabled = (spellcheckerEnabled == 1);
|
||||
}
|
||||
|
||||
void Settings::setSupportChatsTimeSlice(int slice) {
|
||||
|
|
|
@ -231,6 +231,19 @@ public:
|
|||
_variables.suggestStickersByEmoji = value;
|
||||
}
|
||||
|
||||
void setSpellcheckerEnabled(bool value) {
|
||||
_variables.spellcheckerEnabled = value;
|
||||
}
|
||||
bool spellcheckerEnabled() const {
|
||||
return _variables.spellcheckerEnabled.current();
|
||||
}
|
||||
rpl::producer<bool> spellcheckerEnabledValue() const {
|
||||
return _variables.spellcheckerEnabled.value();
|
||||
}
|
||||
rpl::producer<bool> spellcheckerEnabledChanges() const {
|
||||
return _variables.spellcheckerEnabled.changes();
|
||||
}
|
||||
|
||||
private:
|
||||
struct Variables {
|
||||
Variables();
|
||||
|
@ -270,6 +283,7 @@ private:
|
|||
rpl::variable<bool> replaceEmoji = true;
|
||||
bool suggestEmoji = true;
|
||||
bool suggestStickersByEmoji = true;
|
||||
rpl::variable<bool> spellcheckerEnabled = true;
|
||||
|
||||
static constexpr auto kDefaultSupportChatsLimitSlice
|
||||
= 7 * 24 * 60 * 60;
|
||||
|
|
|
@ -243,6 +243,30 @@ void SetupUpdate(not_null<Ui::VerticalLayout*> container) {
|
|||
});
|
||||
}
|
||||
|
||||
bool HasSystemSpellchecker() {
|
||||
return (Platform::IsWindows() && Platform::IsWindows8OrGreater())
|
||||
|| Platform::IsMac();
|
||||
}
|
||||
|
||||
void SetupSpellchecker(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
const auto session = &controller->session();
|
||||
AddButton(
|
||||
container,
|
||||
tr::lng_settings_system_spellchecker(),
|
||||
st::settingsButton
|
||||
)->toggleOn(
|
||||
rpl::single(session->settings().spellcheckerEnabled())
|
||||
)->toggledValue(
|
||||
) | rpl::filter([=](bool enabled) {
|
||||
return (enabled != session->settings().spellcheckerEnabled());
|
||||
}) | rpl::start_with_next([=](bool enabled) {
|
||||
session->settings().setSpellcheckerEnabled(enabled);
|
||||
session->saveSettingsDelayed();
|
||||
}, container->lifetime());
|
||||
}
|
||||
|
||||
bool HasTray() {
|
||||
return cSupportTray() || Platform::IsWindows();
|
||||
}
|
||||
|
@ -515,6 +539,14 @@ void Advanced::setupContent(not_null<Window::SessionController*> controller) {
|
|||
SetupPerformance(controller, content);
|
||||
AddSkip(content);
|
||||
|
||||
if (HasSystemSpellchecker()) {
|
||||
AddSkip(content);
|
||||
AddDivider(content);
|
||||
AddSubsectionTitle(content, tr::lng_settings_spellchecker());
|
||||
SetupSpellchecker(controller, content);
|
||||
AddSkip(content);
|
||||
}
|
||||
|
||||
if (cAutoUpdate()) {
|
||||
addUpdate();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue