/* 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/text/text_utilities.h" // Ui::Text::ToUpper #include "boxes/connection_box.h" #include "boxes/about_box.h" #include "boxes/confirm_box.h" #include "platform/platform_specific.h" #include "base/platform/base_platform_info.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 "data/data_session.h" #include "main/main_session.h" #include "layout.h" #include "facades.h" #include "app.h" #include "styles/style_settings.h" #ifndef TDESKTOP_DISABLE_SPELLCHECK #include "spellcheck/platform/platform_spellcheck.h" #endif // !TDESKTOP_DISABLE_SPELLCHECK namespace Settings { bool HasConnectionType() { #ifndef TDESKTOP_DISABLE_NETWORK_PROXY return true; #endif // TDESKTOP_DISABLE_NETWORK_PROXY return false; } void SetupConnectionType(not_null container) { if (!HasConnectionType()) { return; } #ifndef TDESKTOP_DISABLE_NETWORK_PROXY const auto connectionType = [] { const auto transport = MTP::dctransport(); if (Global::ProxySettings() != MTP::ProxyData::Settings::Enabled) { 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::single( rpl::empty_value() ) | rpl::then(base::ObservableViewer( Global::RefConnectionTypeChanged() )) | rpl::map(connectionType), st::settingsButton); button->addClickHandler([] { Ui::show(ProxiesBoxController::CreateOwningBox()); }); #endif // TDESKTOP_DISABLE_NETWORK_PROXY } 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