From e2207e33eff16f51da459255e8f843c828ce197b Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 6 Sep 2018 13:18:49 +0300 Subject: [PATCH] Add FAQ and support buttons to settings. --- Telegram/SourceFiles/apiwrap.cpp | 17 +++++++ Telegram/SourceFiles/apiwrap.h | 4 ++ Telegram/SourceFiles/settings/settings.style | 5 +++ .../SourceFiles/settings/settings_main.cpp | 45 +++++++++++++++++-- 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index c3e3c6f16..1ee3b2ed2 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -4776,6 +4776,23 @@ FileLoadTo ApiWrap::fileLoadTaskOptions(const SendOptions &options) const { options.replyTo); } +void ApiWrap::requestSupportContact(FnMut callback) { + _supportContactCallbacks.push_back(std::move(callback)); + if (_supportContactCallbacks.size() > 1) { + return; + } + request(MTPhelp_GetSupport( + )).done([=](const MTPhelp_Support &result) { + result.match([&](const MTPDhelp_support &data) { + for (auto &handler : base::take(_supportContactCallbacks)) { + handler(data.vuser); + } + }); + }).fail([=](const RPCError &error) { + _supportContactCallbacks.clear(); + }).send(); +} + void ApiWrap::readServerHistory(not_null history) { if (history->unreadCount()) { readServerHistoryForce(history); diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index 43843d94e..5fe1b98a8 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -322,6 +322,8 @@ public: TextWithEntities caption, const SendOptions &options); + void requestSupportContact(FnMut callback); + ~ApiWrap(); private: @@ -648,4 +650,6 @@ private: TimeMs _termsUpdateSendAt = 0; mtpRequestId _termsUpdateRequestId = 0; + std::vector> _supportContactCallbacks; + }; diff --git a/Telegram/SourceFiles/settings/settings.style b/Telegram/SourceFiles/settings/settings.style index ac05d7ad5..6fedca26e 100644 --- a/Telegram/SourceFiles/settings/settings.style +++ b/Telegram/SourceFiles/settings/settings.style @@ -15,3 +15,8 @@ settingsButtonRightPosition: point(28px, 10px); settingsButtonRight: FlatLabel(defaultFlatLabel) { textFg: windowActiveTextFg; } +settingsScalePadding: margins(79px, 10px, 28px, 8px); +settingsSlider: SettingsSlider(defaultSettingsSlider) { + labelFg: windowSubTextFg; + labelFgActive: windowActiveTextFg; +} diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index 9ca787f69..f803a7f99 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/abstract_box.h" #include "boxes/language_box.h" #include "boxes/confirm_box.h" +#include "boxes/about_box.h" #include "ui/wrap/vertical_layout.h" #include "ui/wrap/padding_wrap.h" #include "ui/widgets/labels.h" @@ -19,6 +20,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/profile/info_profile_cover.h" #include "lang/lang_keys.h" #include "storage/localstorage.h" +#include "auth_session.h" +#include "apiwrap.h" #include "styles/style_settings.h" namespace Settings { @@ -68,15 +71,17 @@ void SetupInterfaceScale(not_null container) { container, rpl::event_stream()); + const auto switched = (cConfigScale() == dbisAuto) + || (cConfigScale() == cScreenScale()); const auto button = container->add(object_ptr