/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "settings/settings_advanced.h" #include "settings/settings_common.h" #include "settings/settings_chat.h" #include "ui/wrap/vertical_layout.h" #include "ui/wrap/slide_wrap.h" #include "ui/widgets/labels.h" #include "ui/widgets/checkbox.h" #include "ui/widgets/buttons.h" #include "ui/gl/gl_detection.h" #include "ui/text/text_utilities.h" // Ui::Text::ToUpper #include "ui/text/format_values.h" #include "ui/boxes/single_choice_box.h" #include "boxes/connection_box.h" #include "boxes/about_box.h" #include "boxes/confirm_box.h" #include "platform/platform_specific.h" #include "ui/platform/ui_platform_window.h" #include "base/platform/base_platform_info.h" #include "window/window_controller.h" #include "window/window_session_controller.h" #include "lang/lang_keys.h" #include "core/update_checker.h" #include "core/application.h" #include "storage/localstorage.h" #include "storage/storage_domain.h" #include "data/data_session.h" #include "main/main_account.h" #include "main/main_domain.h" #include "main/main_session.h" #include "mtproto/facade.h" #include "app.h" #include "styles/style_settings.h" #ifndef TDESKTOP_DISABLE_SPELLCHECK #include "boxes/dictionaries_manager.h" #include "chat_helpers/spellchecker_common.h" #include "spellcheck/platform/platform_spellcheck.h" #endif // !TDESKTOP_DISABLE_SPELLCHECK namespace Settings { void SetupConnectionType( not_null controller, not_null account, not_null container) { const auto connectionType = [=] { const auto transport = account->mtp().dctransport(); if (!Core::App().settings().proxy().isEnabled()) { return transport.isEmpty() ? tr::lng_connection_auto_connecting(tr::now) : tr::lng_connection_auto(tr::now, lt_transport, transport); } else { return transport.isEmpty() ? tr::lng_connection_proxy_connecting(tr::now) : tr::lng_connection_proxy(tr::now, lt_transport, transport); } }; const auto button = AddButtonWithLabel( container, tr::lng_settings_connection_type(), rpl::merge( Core::App().settings().proxy().connectionTypeChanges(), // Handle language switch. tr::lng_connection_auto_connecting() | rpl::to_empty ) | rpl::map(connectionType), st::settingsButton); button->addClickHandler([=] { controller->show(ProxiesBoxController::CreateOwningBox(account)); }); } bool HasUpdate() { return !Core::UpdaterDisabled(); } void SetupUpdate(not_null container) { if (!HasUpdate()) { return; } const auto texts = Ui::CreateChild>( container.get()); const auto downloading = Ui::CreateChild>( container.get()); const auto version = tr::lng_settings_current_version( tr::now, lt_version, currentVersionText()); const auto toggle = AddButton( container, tr::lng_settings_update_automatically(), st::settingsUpdateToggle); const auto label = Ui::CreateChild( toggle.get(), texts->events(), st::settingsUpdateState); const auto options = container->add( object_ptr>( container, object_ptr(container))); const auto inner = options->entity(); const auto install = cAlphaVersion() ? nullptr : AddButton( inner, tr::lng_settings_install_beta(), st::settingsButton).get(); const auto check = AddButton( inner, tr::lng_settings_check_now(), st::settingsButton); const auto update = Ui::CreateChild