2018-09-05 19:05:49 +00:00
|
|
|
/*
|
|
|
|
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_main.h"
|
|
|
|
|
|
|
|
#include "settings/settings_common.h"
|
2018-09-06 13:48:01 +00:00
|
|
|
#include "settings/settings_codes.h"
|
2018-10-07 11:42:09 +00:00
|
|
|
#include "settings/settings_chat.h"
|
2018-09-05 21:01:50 +00:00
|
|
|
#include "boxes/language_box.h"
|
|
|
|
#include "boxes/confirm_box.h"
|
2018-09-06 10:18:49 +00:00
|
|
|
#include "boxes/about_box.h"
|
2018-09-05 19:05:49 +00:00
|
|
|
#include "ui/wrap/vertical_layout.h"
|
2020-03-24 07:26:08 +00:00
|
|
|
#include "ui/wrap/slide_wrap.h"
|
2018-09-05 21:01:50 +00:00
|
|
|
#include "ui/widgets/labels.h"
|
|
|
|
#include "ui/widgets/discrete_sliders.h"
|
2019-11-02 17:06:47 +00:00
|
|
|
#include "ui/widgets/buttons.h"
|
2018-09-05 19:39:35 +00:00
|
|
|
#include "info/profile/info_profile_cover.h"
|
2019-01-04 11:09:48 +00:00
|
|
|
#include "data/data_user.h"
|
2019-01-18 12:27:37 +00:00
|
|
|
#include "data/data_session.h"
|
2019-09-03 15:24:51 +00:00
|
|
|
#include "data/data_cloud_themes.h"
|
2020-03-18 10:07:11 +00:00
|
|
|
#include "data/data_chat_filters.h"
|
2018-09-05 19:05:49 +00:00
|
|
|
#include "lang/lang_keys.h"
|
2020-09-30 09:11:44 +00:00
|
|
|
#include "lang/lang_instance.h"
|
2018-09-05 21:01:50 +00:00
|
|
|
#include "storage/localstorage.h"
|
2019-07-24 11:45:24 +00:00
|
|
|
#include "main/main_session.h"
|
2020-06-18 18:04:16 +00:00
|
|
|
#include "main/main_session_settings.h"
|
2020-03-18 10:07:11 +00:00
|
|
|
#include "main/main_account.h"
|
|
|
|
#include "main/main_app_config.h"
|
2018-09-06 10:18:49 +00:00
|
|
|
#include "apiwrap.h"
|
2021-08-02 19:06:33 +00:00
|
|
|
#include "api/api_cloud_password.h"
|
2020-07-03 16:53:24 +00:00
|
|
|
#include "api/api_global_privacy.h"
|
2021-08-02 19:06:33 +00:00
|
|
|
#include "api/api_sensitive_content.h"
|
2021-06-13 07:37:52 +00:00
|
|
|
#include "window/window_controller.h"
|
2019-07-24 11:13:51 +00:00
|
|
|
#include "window/window_session_controller.h"
|
2020-10-28 21:29:48 +00:00
|
|
|
#include "core/click_handler_types.h"
|
2019-09-26 10:55:35 +00:00
|
|
|
#include "base/call_delayed.h"
|
2019-09-13 06:06:02 +00:00
|
|
|
#include "facades.h"
|
|
|
|
#include "app.h"
|
2018-09-05 19:05:49 +00:00
|
|
|
#include "styles/style_settings.h"
|
|
|
|
|
|
|
|
namespace Settings {
|
2018-09-05 21:01:50 +00:00
|
|
|
|
2018-09-17 10:52:34 +00:00
|
|
|
void SetupLanguageButton(
|
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
bool icon) {
|
2018-09-07 09:40:25 +00:00
|
|
|
const auto button = AddButtonWithLabel(
|
2018-09-05 21:01:50 +00:00
|
|
|
container,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_language(),
|
2019-06-19 11:22:25 +00:00
|
|
|
rpl::single(
|
2020-09-30 09:11:44 +00:00
|
|
|
Lang::GetInstance().id()
|
2019-06-19 11:22:25 +00:00
|
|
|
) | rpl::then(
|
2020-09-30 09:11:44 +00:00
|
|
|
Lang::GetInstance().idChanges()
|
|
|
|
) | rpl::map([] { return Lang::GetInstance().nativeName(); }),
|
2018-09-17 10:52:34 +00:00
|
|
|
icon ? st::settingsSectionButton : st::settingsButton,
|
|
|
|
icon ? &st::settingsIconLanguage : nullptr);
|
2018-11-21 10:09:46 +00:00
|
|
|
const auto guard = Ui::CreateChild<base::binary_guard>(button.get());
|
2018-09-05 21:01:50 +00:00
|
|
|
button->addClickHandler([=] {
|
2018-09-27 14:27:31 +00:00
|
|
|
const auto m = button->clickModifiers();
|
|
|
|
if ((m & Qt::ShiftModifier) && (m & Qt::AltModifier)) {
|
2018-11-13 09:14:22 +00:00
|
|
|
Lang::CurrentCloudManager().switchToLanguage({ qsl("#custom") });
|
2018-09-27 14:27:31 +00:00
|
|
|
} else {
|
|
|
|
*guard = LanguageBox::Show();
|
|
|
|
}
|
2018-09-05 21:01:50 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-09-06 11:33:24 +00:00
|
|
|
void SetupSections(
|
2019-07-24 14:00:30 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
2018-09-06 11:33:24 +00:00
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
Fn<void(Type)> showOther) {
|
|
|
|
AddDivider(container);
|
|
|
|
AddSkip(container);
|
|
|
|
|
2018-09-10 12:18:39 +00:00
|
|
|
const auto addSection = [&](
|
2019-06-18 12:16:43 +00:00
|
|
|
rpl::producer<QString> label,
|
2018-09-10 12:18:39 +00:00
|
|
|
Type type,
|
|
|
|
const style::icon *icon) {
|
2018-09-07 09:40:25 +00:00
|
|
|
AddButton(
|
2018-09-06 11:33:24 +00:00
|
|
|
container,
|
2019-06-18 12:16:43 +00:00
|
|
|
std::move(label),
|
2018-09-10 12:18:39 +00:00
|
|
|
st::settingsSectionButton,
|
|
|
|
icon
|
2018-09-06 11:33:24 +00:00
|
|
|
)->addClickHandler([=] { showOther(type); });
|
|
|
|
};
|
2019-07-24 14:00:30 +00:00
|
|
|
if (controller->session().supportMode()) {
|
|
|
|
SetupSupport(controller, container);
|
2018-10-07 11:42:09 +00:00
|
|
|
|
|
|
|
AddDivider(container);
|
|
|
|
AddSkip(container);
|
|
|
|
} else {
|
|
|
|
addSection(
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_information(),
|
2018-10-07 11:42:09 +00:00
|
|
|
Type::Information,
|
|
|
|
&st::settingsIconInformation);
|
|
|
|
}
|
2018-09-10 12:18:39 +00:00
|
|
|
addSection(
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_section_notify(),
|
2018-09-10 12:18:39 +00:00
|
|
|
Type::Notifications,
|
|
|
|
&st::settingsIconNotifications);
|
|
|
|
addSection(
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_section_privacy(),
|
2018-09-10 12:18:39 +00:00
|
|
|
Type::PrivacySecurity,
|
|
|
|
&st::settingsIconPrivacySecurity);
|
|
|
|
addSection(
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_section_chat_settings(),
|
2018-09-10 12:18:39 +00:00
|
|
|
Type::Chat,
|
|
|
|
&st::settingsIconChat);
|
2020-03-24 07:26:08 +00:00
|
|
|
|
2020-03-24 08:58:47 +00:00
|
|
|
const auto preload = [=] {
|
|
|
|
controller->session().data().chatsFilters().requestSuggested();
|
|
|
|
};
|
2020-03-24 07:26:08 +00:00
|
|
|
const auto account = &controller->session().account();
|
|
|
|
const auto slided = container->add(
|
|
|
|
object_ptr<Ui::SlideWrap<Ui::SettingsButton>>(
|
|
|
|
container,
|
|
|
|
CreateButton(
|
|
|
|
container,
|
|
|
|
tr::lng_settings_section_filters(),
|
|
|
|
st::settingsSectionButton,
|
|
|
|
&st::settingsIconFolders)))->setDuration(0);
|
2020-03-18 10:07:11 +00:00
|
|
|
if (!controller->session().data().chatsFilters().list().empty()
|
2020-06-18 18:04:16 +00:00
|
|
|
|| controller->session().settings().dialogsFiltersEnabled()) {
|
2020-03-24 07:26:08 +00:00
|
|
|
slided->show(anim::type::instant);
|
2020-03-24 08:58:47 +00:00
|
|
|
preload();
|
2020-03-24 07:26:08 +00:00
|
|
|
} else {
|
|
|
|
const auto enabled = [=] {
|
2020-03-24 08:58:47 +00:00
|
|
|
const auto result = account->appConfig().get<bool>(
|
2020-03-24 07:26:08 +00:00
|
|
|
"dialog_filters_enabled",
|
|
|
|
false);
|
2020-03-24 08:58:47 +00:00
|
|
|
if (result) {
|
|
|
|
preload();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
const auto preloadIfEnabled = [=](bool enabled) {
|
|
|
|
if (enabled) {
|
|
|
|
preload();
|
|
|
|
}
|
2020-03-24 07:26:08 +00:00
|
|
|
};
|
|
|
|
slided->toggleOn(
|
|
|
|
rpl::single(
|
|
|
|
rpl::empty_value()
|
|
|
|
) | rpl::then(
|
|
|
|
account->appConfig().refreshed()
|
2020-03-24 08:58:47 +00:00
|
|
|
) | rpl::map(
|
|
|
|
enabled
|
|
|
|
) | rpl::before_next(preloadIfEnabled));
|
2020-03-18 10:07:11 +00:00
|
|
|
}
|
2020-03-24 07:26:08 +00:00
|
|
|
slided->entity()->setClickedCallback([=] {
|
|
|
|
showOther(Type::Folders);
|
|
|
|
});
|
|
|
|
|
2018-09-13 20:09:26 +00:00
|
|
|
addSection(
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_advanced(),
|
2018-09-20 16:47:02 +00:00
|
|
|
Type::Advanced,
|
2018-09-13 20:09:26 +00:00
|
|
|
&st::settingsIconGeneral);
|
2018-09-06 11:33:24 +00:00
|
|
|
|
|
|
|
SetupLanguageButton(container);
|
|
|
|
|
|
|
|
AddSkip(container);
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:07:04 +00:00
|
|
|
bool HasInterfaceScale() {
|
2018-10-15 19:42:10 +00:00
|
|
|
return true;
|
2018-09-11 18:07:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetupInterfaceScale(
|
2021-06-13 07:37:52 +00:00
|
|
|
not_null<Window::Controller*> window,
|
2018-09-11 18:07:04 +00:00
|
|
|
not_null<Ui::VerticalLayout*> container,
|
|
|
|
bool icon) {
|
|
|
|
if (!HasInterfaceScale()) {
|
2018-09-05 21:01:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-21 10:09:46 +00:00
|
|
|
const auto toggled = Ui::CreateChild<rpl::event_stream<bool>>(
|
|
|
|
container.get());
|
2018-09-05 21:01:50 +00:00
|
|
|
|
2019-09-13 10:24:06 +00:00
|
|
|
const auto switched = (cConfigScale() == style::kScaleAuto);
|
2018-09-07 09:40:25 +00:00
|
|
|
const auto button = AddButton(
|
2018-09-05 21:01:50 +00:00
|
|
|
container,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_default_scale(),
|
2018-09-17 10:52:34 +00:00
|
|
|
icon ? st::settingsSectionButton : st::settingsButton,
|
2018-09-11 18:07:04 +00:00
|
|
|
icon ? &st::settingsIconInterfaceScale : nullptr
|
2018-09-06 10:18:49 +00:00
|
|
|
)->toggleOn(toggled->events_starting_with_copy(switched));
|
2018-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
const auto slider = container->add(
|
2018-09-06 10:18:49 +00:00
|
|
|
object_ptr<Ui::SettingsSlider>(container, st::settingsSlider),
|
2018-09-11 18:07:04 +00:00
|
|
|
icon ? st::settingsScalePadding : st::settingsBigScalePadding);
|
2018-09-05 21:01:50 +00:00
|
|
|
|
2019-05-25 10:06:12 +00:00
|
|
|
static const auto ScaleValues = [&] {
|
|
|
|
auto values = (cIntRetinaFactor() > 1)
|
|
|
|
? std::vector<int>{ 100, 110, 120, 130, 140, 150 }
|
|
|
|
: std::vector<int>{ 100, 125, 150, 200, 250, 300 };
|
2019-09-13 10:24:06 +00:00
|
|
|
if (cConfigScale() == style::kScaleAuto) {
|
2019-05-25 10:06:12 +00:00
|
|
|
return values;
|
|
|
|
}
|
|
|
|
if (ranges::find(values, cConfigScale()) == end(values)) {
|
|
|
|
values.push_back(cConfigScale());
|
|
|
|
}
|
|
|
|
return values;
|
|
|
|
}();
|
|
|
|
|
2018-10-15 11:44:48 +00:00
|
|
|
const auto sectionFromScale = [](int scale) {
|
2018-10-26 10:58:46 +00:00
|
|
|
scale = cEvalScale(scale);
|
2018-10-15 11:44:48 +00:00
|
|
|
auto result = 0;
|
|
|
|
for (const auto value : ScaleValues) {
|
2019-05-25 10:06:12 +00:00
|
|
|
if (scale == value) {
|
2018-10-15 11:44:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
++result;
|
|
|
|
}
|
|
|
|
return (result == ScaleValues.size()) ? (result - 1) : result;
|
|
|
|
};
|
2020-07-06 11:51:58 +00:00
|
|
|
const auto inSetScale = container->lifetime().make_state<bool>();
|
|
|
|
const auto setScale = [=](int scale, const auto &repeatSetScale) -> void {
|
|
|
|
if (*inSetScale) {
|
|
|
|
return;
|
|
|
|
}
|
2018-09-05 21:01:50 +00:00
|
|
|
*inSetScale = true;
|
|
|
|
const auto guard = gsl::finally([=] { *inSetScale = false; });
|
|
|
|
|
2019-09-13 10:24:06 +00:00
|
|
|
toggled->fire(scale == style::kScaleAuto);
|
2018-10-15 11:44:48 +00:00
|
|
|
slider->setActiveSection(sectionFromScale(scale));
|
2018-10-26 10:58:46 +00:00
|
|
|
if (cEvalScale(scale) != cEvalScale(cConfigScale())) {
|
2018-09-05 21:01:50 +00:00
|
|
|
const auto confirmed = crl::guard(button, [=] {
|
2018-10-26 10:58:46 +00:00
|
|
|
cSetConfigScale(scale);
|
2018-09-05 21:01:50 +00:00
|
|
|
Local::writeSettings();
|
|
|
|
App::restart();
|
|
|
|
});
|
|
|
|
const auto cancelled = crl::guard(button, [=] {
|
2019-09-26 10:55:35 +00:00
|
|
|
base::call_delayed(
|
2018-09-05 21:01:50 +00:00
|
|
|
st::defaultSettingsSlider.duration,
|
|
|
|
button,
|
2020-07-06 11:51:58 +00:00
|
|
|
[=] { repeatSetScale(cConfigScale(), repeatSetScale); });
|
2018-09-05 21:01:50 +00:00
|
|
|
});
|
2021-06-13 07:37:52 +00:00
|
|
|
window->show(Box<ConfirmBox>(
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_settings_need_restart(tr::now),
|
|
|
|
tr::lng_settings_restart_now(tr::now),
|
2018-09-05 21:01:50 +00:00
|
|
|
confirmed,
|
|
|
|
cancelled));
|
2018-10-26 10:58:46 +00:00
|
|
|
} else if (scale != cConfigScale()) {
|
2018-09-05 21:01:50 +00:00
|
|
|
cSetConfigScale(scale);
|
|
|
|
Local::writeSettings();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-10-15 11:44:48 +00:00
|
|
|
const auto label = [](int scale) {
|
|
|
|
return QString::number(scale) + '%';
|
2018-09-05 21:01:50 +00:00
|
|
|
};
|
|
|
|
const auto scaleByIndex = [](int index) {
|
2018-10-15 11:44:48 +00:00
|
|
|
return *(ScaleValues.begin() + index);
|
2018-09-05 21:01:50 +00:00
|
|
|
};
|
|
|
|
|
2018-10-15 11:44:48 +00:00
|
|
|
for (const auto value : ScaleValues) {
|
|
|
|
slider->addSection(label(value));
|
|
|
|
}
|
|
|
|
slider->setActiveSectionFast(sectionFromScale(cConfigScale()));
|
2018-09-05 21:01:50 +00:00
|
|
|
slider->sectionActivated(
|
2018-10-26 10:58:46 +00:00
|
|
|
) | rpl::map([=](int section) {
|
|
|
|
return scaleByIndex(section);
|
2021-02-01 08:32:08 +00:00
|
|
|
}) | rpl::filter([=](int scale) {
|
|
|
|
return cEvalScale(scale) != cEvalScale(cConfigScale());
|
2018-10-26 10:58:46 +00:00
|
|
|
}) | rpl::start_with_next([=](int scale) {
|
2020-07-06 11:51:58 +00:00
|
|
|
setScale(
|
|
|
|
(scale == cScreenScale()) ? style::kScaleAuto : scale,
|
|
|
|
setScale);
|
2018-09-05 21:01:50 +00:00
|
|
|
}, slider->lifetime());
|
2018-10-26 10:58:46 +00:00
|
|
|
|
|
|
|
button->toggledValue(
|
|
|
|
) | rpl::map([](bool checked) {
|
2019-09-13 10:24:06 +00:00
|
|
|
return checked ? style::kScaleAuto : cEvalScale(cConfigScale());
|
2018-10-26 10:58:46 +00:00
|
|
|
}) | rpl::start_with_next([=](int scale) {
|
2020-07-06 11:51:58 +00:00
|
|
|
setScale(scale, setScale);
|
2018-10-26 10:58:46 +00:00
|
|
|
}, button->lifetime());
|
2018-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2018-09-20 17:56:45 +00:00
|
|
|
void OpenFaq() {
|
2020-10-28 21:29:48 +00:00
|
|
|
UrlClickHandler::Open(telegramFaqLink());
|
2018-09-20 17:56:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:07:04 +00:00
|
|
|
void SetupFaq(not_null<Ui::VerticalLayout*> container, bool icon) {
|
2018-09-07 09:40:25 +00:00
|
|
|
AddButton(
|
2018-09-06 10:18:49 +00:00
|
|
|
container,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_settings_faq(),
|
2018-09-17 10:52:34 +00:00
|
|
|
icon ? st::settingsSectionButton : st::settingsButton,
|
2018-09-11 18:07:04 +00:00
|
|
|
icon ? &st::settingsIconFaq : nullptr
|
2018-09-20 17:56:45 +00:00
|
|
|
)->addClickHandler(OpenFaq);
|
2018-09-11 18:07:04 +00:00
|
|
|
}
|
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
void SetupHelp(
|
|
|
|
not_null<Window::SessionController*> controller,
|
|
|
|
not_null<Ui::VerticalLayout*> container) {
|
2018-09-11 18:07:04 +00:00
|
|
|
AddDivider(container);
|
|
|
|
AddSkip(container);
|
|
|
|
|
|
|
|
SetupFaq(container);
|
2018-09-06 10:18:49 +00:00
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
const auto button = AddButton(
|
|
|
|
container,
|
|
|
|
tr::lng_settings_ask_question(),
|
|
|
|
st::settingsSectionButton);
|
2019-09-03 15:24:51 +00:00
|
|
|
const auto requestId = button->lifetime().make_state<mtpRequestId>();
|
|
|
|
button->lifetime().add([=] {
|
|
|
|
if (*requestId) {
|
|
|
|
controller->session().api().request(*requestId).cancel();
|
|
|
|
}
|
|
|
|
});
|
2019-07-24 14:00:30 +00:00
|
|
|
button->addClickHandler([=] {
|
|
|
|
const auto sure = crl::guard(button, [=] {
|
2019-09-03 15:24:51 +00:00
|
|
|
if (*requestId) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
*requestId = controller->session().api().request(
|
|
|
|
MTPhelp_GetSupport()
|
|
|
|
).done([=](const MTPhelp_Support &result) {
|
|
|
|
*requestId = 0;
|
|
|
|
result.match([&](const MTPDhelp_support &data) {
|
|
|
|
auto &owner = controller->session().data();
|
|
|
|
if (const auto user = owner.processUser(data.vuser())) {
|
|
|
|
Ui::showPeerHistory(user, ShowAtUnreadMsgId);
|
|
|
|
}
|
|
|
|
});
|
2021-03-12 12:48:00 +00:00
|
|
|
}).fail([=](const MTP::Error &error) {
|
2019-09-03 15:24:51 +00:00
|
|
|
*requestId = 0;
|
|
|
|
}).send();
|
2019-07-24 14:00:30 +00:00
|
|
|
});
|
|
|
|
auto box = Box<ConfirmBox>(
|
|
|
|
tr::lng_settings_ask_sure(tr::now),
|
|
|
|
tr::lng_settings_ask_ok(tr::now),
|
|
|
|
tr::lng_settings_faq_button(tr::now),
|
|
|
|
sure,
|
|
|
|
OpenFaq);
|
|
|
|
box->setStrictCancel(true);
|
2021-06-13 07:37:52 +00:00
|
|
|
controller->show(std::move(box));
|
2019-07-24 14:00:30 +00:00
|
|
|
});
|
2018-09-06 10:18:49 +00:00
|
|
|
|
|
|
|
AddSkip(container);
|
|
|
|
}
|
|
|
|
|
2018-09-05 19:39:35 +00:00
|
|
|
Main::Main(
|
|
|
|
QWidget *parent,
|
2019-07-24 14:00:30 +00:00
|
|
|
not_null<Window::SessionController*> controller)
|
2018-09-05 19:05:49 +00:00
|
|
|
: Section(parent)
|
2019-07-24 14:00:30 +00:00
|
|
|
, _controller(controller) {
|
2018-09-05 19:39:35 +00:00
|
|
|
setupContent(controller);
|
2018-09-05 19:05:49 +00:00
|
|
|
}
|
|
|
|
|
2018-09-06 13:48:01 +00:00
|
|
|
void Main::keyPressEvent(QKeyEvent *e) {
|
2020-03-26 10:29:27 +00:00
|
|
|
crl::on_main(this, [=, text = e->text()]{
|
|
|
|
CodesFeedString(_controller, text);
|
|
|
|
});
|
2018-09-06 13:48:01 +00:00
|
|
|
return Section::keyPressEvent(e);
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
void Main::setupContent(not_null<Window::SessionController*> controller) {
|
2018-09-05 19:05:49 +00:00
|
|
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
|
|
|
|
2018-09-05 19:39:35 +00:00
|
|
|
const auto cover = content->add(object_ptr<Info::Profile::Cover>(
|
|
|
|
content,
|
2019-07-24 14:00:30 +00:00
|
|
|
controller->session().user(),
|
2018-09-05 19:39:35 +00:00
|
|
|
controller));
|
|
|
|
cover->setOnlineCount(rpl::single(0));
|
|
|
|
|
2019-07-24 14:00:30 +00:00
|
|
|
SetupSections(controller, content, [=](Type type) {
|
2018-09-06 11:33:24 +00:00
|
|
|
_showOther.fire_copy(type);
|
|
|
|
});
|
2018-09-11 18:07:04 +00:00
|
|
|
if (HasInterfaceScale()) {
|
|
|
|
AddDivider(content);
|
|
|
|
AddSkip(content);
|
2021-06-13 07:37:52 +00:00
|
|
|
SetupInterfaceScale(&controller->window(), content);
|
2018-09-11 18:07:04 +00:00
|
|
|
AddSkip(content);
|
|
|
|
}
|
2019-07-24 14:00:30 +00:00
|
|
|
SetupHelp(controller, content);
|
2018-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
Ui::ResizeFitChild(this, content);
|
2018-09-09 12:10:54 +00:00
|
|
|
|
|
|
|
// If we load this in advance it won't jump when we open its' section.
|
2021-08-02 19:06:33 +00:00
|
|
|
controller->session().api().cloudPassword().reload();
|
2019-07-24 11:13:51 +00:00
|
|
|
controller->session().api().reloadContactSignupSilent();
|
2020-07-03 16:53:24 +00:00
|
|
|
controller->session().api().sensitiveContent().reload();
|
|
|
|
controller->session().api().globalPrivacy().reload();
|
2019-09-03 15:24:51 +00:00
|
|
|
controller->session().data().cloudThemes().refresh();
|
2018-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2018-09-05 19:05:49 +00:00
|
|
|
rpl::producer<Type> Main::sectionShowOther() {
|
|
|
|
return _showOther.events();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Settings
|