/* 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_common.h" #include "settings/settings_chat.h" #include "settings/settings_advanced.h" #include "settings/settings_information.h" #include "settings/settings_main.h" #include "settings/settings_notifications.h" #include "settings/settings_privacy_security.h" #include "settings/settings_folders.h" #include "settings/settings_calls.h" #include "core/application.h" #include "ui/wrap/padding_wrap.h" #include "ui/wrap/vertical_layout.h" #include "ui/widgets/labels.h" #include "ui/widgets/box_content_divider.h" #include "ui/widgets/buttons.h" #include "boxes/abstract_box.h" #include "boxes/sessions_box.h" #include "window/themes/window_theme_editor_box.h" #include "window/window_session_controller.h" #include "window/window_controller.h" #include "lang/lang_keys.h" #include "mainwindow.h" #include "main/main_session.h" #include "main/main_domain.h" #include "styles/style_layers.h" #include "styles/style_settings.h" namespace Settings { object_ptr
CreateSection( Type type, not_null parent, not_null controller) { switch (type) { case Type::Main: return object_ptr
(parent, controller); case Type::Information: return object_ptr(parent, controller); case Type::Notifications: return object_ptr(parent, controller); case Type::PrivacySecurity: return object_ptr(parent, controller); case Type::Sessions: return object_ptr(parent, controller); case Type::Advanced: return object_ptr(parent, controller); case Type::Folders: return object_ptr(parent, controller); case Type::Chat: return object_ptr(parent, controller); case Type::Calls: return object_ptr(parent, controller); } Unexpected("Settings section type in Widget::createInnerWidget."); } void AddSkip(not_null container) { AddSkip(container, st::settingsSectionSkip); } void AddSkip(not_null container, int skip) { container->add(object_ptr( container, skip)); } void AddDivider(not_null container) { container->add(object_ptr(container)); } void AddDividerText( not_null container, rpl::producer text) { container->add(object_ptr( container, object_ptr( container, std::move(text), st::boxDividerLabel), st::settingsDividerLabelPadding)); } not_null AddButtonIcon( not_null button, const style::icon *leftIcon, int iconLeft, const style::color *leftIconOver) { const auto icon = Ui::CreateChild(button.get()); icon->setAttribute(Qt::WA_TransparentForMouseEvents); icon->resize(leftIcon->size()); button->sizeValue( ) | rpl::start_with_next([=](QSize size) { icon->moveToLeft( iconLeft ? iconLeft : st::settingsSectionIconLeft, (size.height() - icon->height()) / 2, size.width()); }, icon->lifetime()); icon->paintRequest( ) | rpl::start_with_next([=] { Painter p(icon); const auto width = icon->width(); const auto paintOver = (button->isOver() || button->isDown()) && !button->isDisabled(); if (!paintOver) { leftIcon->paint(p, QPoint(), width); } else if (leftIconOver) { leftIcon->paint(p, QPoint(), width, (*leftIconOver)->c); } else { leftIcon->paint(p, QPoint(), width, st::menuIconFgOver->c); } }, icon->lifetime()); return icon; } object_ptr