2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 15:35:51 +00:00

Added translation preferences.

This commit is contained in:
23rd
2022-11-18 13:42:12 +03:00
committed by John Preston
parent 7aede75e43
commit f82bae15f0
6 changed files with 119 additions and 26 deletions

View File

@@ -23,18 +23,21 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_options.h"
#include "ui/painter.h"
#include "storage/localstorage.h"
#include "boxes/translate_box.h"
#include "ui/boxes/confirm_box.h"
#include "mainwidget.h"
#include "mainwindow.h"
#include "core/application.h"
#include "lang/lang_instance.h"
#include "lang/lang_cloud_manager.h"
#include "settings/settings_common.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
#include "styles/style_info.h"
#include "styles/style_passport.h"
#include "styles/style_chat_helpers.h"
#include "styles/style_menu_icons.h"
#include "styles/style_settings.h"
#include <QtGui/QGuiApplication>
#include <QtGui/QClipboard>
@@ -1096,6 +1099,44 @@ void LanguageBox::prepare() {
setTitle(tr::lng_languages());
const auto topContainer = Ui::CreateChild<Ui::VerticalLayout>(this);
Settings::AddSubsectionTitle(
topContainer,
tr::lng_translate_settings_subtitle());
const auto translateEnabled = Settings::AddButton(
topContainer,
tr::lng_translate_settings_show(),
st::settingsButtonNoIcon
)->toggleOn(rpl::single(Core::App().settings().translateButtonEnabled()));
translateEnabled->toggledValue(
) | rpl::filter([](bool checked) {
return (checked != Core::App().settings().translateButtonEnabled());
}) | rpl::start_with_next([=](bool checked) {
Core::App().settings().setTranslateButtonEnabled(checked);
Core::App().saveSettingsDelayed();
}, translateEnabled->lifetime());
const auto label = lifetime().make_state<rpl::event_stream<QLocale>>();
const auto translateSkip = Settings::AddButtonWithLabel(
topContainer,
tr::lng_translate_settings_choose(),
label->events() | rpl::map(Ui::LanguageName),
st::settingsButtonNoIcon);
label->fire(QLocale(Core::App().settings().skipTranslationForLanguage()));
translateSkip->setClickedCallback([=] {
Ui::BoxShow(this).showBox(
Box(Ui::ChooseLanguageBox, [=](QLocale locale) {
label->fire(QLocale(locale));
Core::App().settings().setSkipTranslationForLanguage(
locale.language());
}),
Ui::LayerOption::KeepOther);
});
Settings::AddSkip(topContainer);
Settings::AddDividerText(
topContainer,
tr::lng_translate_settings_about());
const auto select = topContainer->add(
object_ptr<Ui::MultiSelect>(