/* 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 */ #pragma once #include "menu/add_action_callback.h" #include "ui/rp_widget.h" #include "ui/round_rect.h" #include "base/object_ptr.h" #include "settings/settings_type.h" namespace Main { class Session; } // namespace Main namespace Ui { class VerticalLayout; class FlatLabel; class SettingsButton; class AbstractButton; } // namespace Ui namespace Window { class SessionController; } // namespace Window namespace style { struct FlatLabel; struct SettingsButton; } // namespace style namespace Lottie { struct IconDescriptor; } // namespace Lottie namespace Settings { extern const char kOptionMonoSettingsIcons[]; using Button = Ui::SettingsButton; class AbstractSection; struct SectionMeta { [[nodiscard]] virtual object_ptr create( not_null parent, not_null controller) const = 0; }; template struct SectionMetaImplementation : SectionMeta { object_ptr create( not_null parent, not_null controller ) const final override { return object_ptr(parent, controller); } [[nodiscard]] static not_null Meta() { static SectionMetaImplementation result; return &result; } }; class AbstractSection : public Ui::RpWidget { public: using RpWidget::RpWidget; [[nodiscard]] virtual Type id() const = 0; [[nodiscard]] virtual rpl::producer sectionShowOther() { return nullptr; } [[nodiscard]] virtual rpl::producer title() = 0; virtual void sectionSaveChanges(FnMut done) { done(); } virtual void showFinished() { } }; template class Section : public AbstractSection { public: using AbstractSection::AbstractSection; [[nodiscard]] static Type Id() { return &SectionMetaImplementation::Meta; } [[nodiscard]] Type id() const final override { return Id(); } }; inline constexpr auto kIconRed = 1; inline constexpr auto kIconGreen = 2; inline constexpr auto kIconLightOrange = 3; inline constexpr auto kIconLightBlue = 4; inline constexpr auto kIconDarkBlue = 5; inline constexpr auto kIconPurple = 6; inline constexpr auto kIconDarkOrange = 8; inline constexpr auto kIconGray = 9; enum class IconType { Rounded, Round, }; struct IconDescriptor { const style::icon *icon = nullptr; int color = 0; // settingsIconBg{color}, 9 for settingsIconBgArchive. IconType type = IconType::Rounded; const style::color *background = nullptr; explicit operator bool() const { return (icon != nullptr); } }; class Icon final { public: explicit Icon(IconDescriptor descriptor); void paint(QPainter &p, QPoint position) const; void paint(QPainter &p, int x, int y) const; [[nodiscard]] int width() const; [[nodiscard]] int height() const; [[nodiscard]] QSize size() const; private: not_null _icon; std::optional _background; }; void AddSkip(not_null container); void AddSkip(not_null container, int skip); void AddDivider(not_null container); void AddDividerText( not_null container, rpl::producer text); void AddButtonIcon( not_null button, const style::SettingsButton &st, IconDescriptor &&descriptor); object_ptr