diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index f119a1041..803808420 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1071,6 +1071,7 @@ PRIVATE settings/settings_privacy_controllers.h settings/settings_privacy_security.cpp settings/settings_privacy_security.h + settings/settings_type.h storage/details/storage_file_utilities.cpp storage/details/storage_file_utilities.h storage/details/storage_settings_scheme.cpp @@ -1286,6 +1287,8 @@ PRIVATE qrc/emoji_6.qrc qrc/emoji_7.qrc qrc/emoji_preview.qrc + qrc/telegram/animations.qrc + qrc/telegram/export.qrc qrc/telegram/telegram.qrc qrc/telegram/sounds.qrc winrc/Telegram.rc diff --git a/Telegram/Resources/animations/change_number.tgs b/Telegram/Resources/animations/change_number.tgs new file mode 100644 index 000000000..fc113e1da Binary files /dev/null and b/Telegram/Resources/animations/change_number.tgs differ diff --git a/Telegram/Resources/icons/phone_simcard_from.png b/Telegram/Resources/icons/phone_simcard_from.png deleted file mode 100644 index e9a8e089a..000000000 Binary files a/Telegram/Resources/icons/phone_simcard_from.png and /dev/null differ diff --git a/Telegram/Resources/icons/phone_simcard_from@2x.png b/Telegram/Resources/icons/phone_simcard_from@2x.png deleted file mode 100644 index 5eb9e027b..000000000 Binary files a/Telegram/Resources/icons/phone_simcard_from@2x.png and /dev/null differ diff --git a/Telegram/Resources/icons/phone_simcard_from@3x.png b/Telegram/Resources/icons/phone_simcard_from@3x.png deleted file mode 100644 index a0df7abaa..000000000 Binary files a/Telegram/Resources/icons/phone_simcard_from@3x.png and /dev/null differ diff --git a/Telegram/Resources/icons/phone_simcard_migrate.png b/Telegram/Resources/icons/phone_simcard_migrate.png deleted file mode 100644 index 4f260997c..000000000 Binary files a/Telegram/Resources/icons/phone_simcard_migrate.png and /dev/null differ diff --git a/Telegram/Resources/icons/phone_simcard_migrate@2x.png b/Telegram/Resources/icons/phone_simcard_migrate@2x.png deleted file mode 100644 index 4a27a4aaf..000000000 Binary files a/Telegram/Resources/icons/phone_simcard_migrate@2x.png and /dev/null differ diff --git a/Telegram/Resources/icons/phone_simcard_migrate@3x.png b/Telegram/Resources/icons/phone_simcard_migrate@3x.png deleted file mode 100644 index 4df340aff..000000000 Binary files a/Telegram/Resources/icons/phone_simcard_migrate@3x.png and /dev/null differ diff --git a/Telegram/Resources/icons/phone_simcard_to.png b/Telegram/Resources/icons/phone_simcard_to.png deleted file mode 100644 index ace803c02..000000000 Binary files a/Telegram/Resources/icons/phone_simcard_to.png and /dev/null differ diff --git a/Telegram/Resources/icons/phone_simcard_to@2x.png b/Telegram/Resources/icons/phone_simcard_to@2x.png deleted file mode 100644 index 710808ec2..000000000 Binary files a/Telegram/Resources/icons/phone_simcard_to@2x.png and /dev/null differ diff --git a/Telegram/Resources/icons/phone_simcard_to@3x.png b/Telegram/Resources/icons/phone_simcard_to@3x.png deleted file mode 100644 index fa2d93ffa..000000000 Binary files a/Telegram/Resources/icons/phone_simcard_to@3x.png and /dev/null differ diff --git a/Telegram/Resources/qrc/telegram/animations.qrc b/Telegram/Resources/qrc/telegram/animations.qrc new file mode 100644 index 000000000..eac41dc7f --- /dev/null +++ b/Telegram/Resources/qrc/telegram/animations.qrc @@ -0,0 +1,5 @@ + + + ../../animations/change_number.tgs + + diff --git a/Telegram/Resources/qrc/telegram/export.qrc b/Telegram/Resources/qrc/telegram/export.qrc new file mode 100644 index 000000000..06ecc7eb7 --- /dev/null +++ b/Telegram/Resources/qrc/telegram/export.qrc @@ -0,0 +1,44 @@ + + + ../../export_html/css/style.css + ../../export_html/images/back.png + ../../export_html/images/back@2x.png + ../../export_html/images/media_call.png + ../../export_html/images/media_call@2x.png + ../../export_html/images/media_contact.png + ../../export_html/images/media_contact@2x.png + ../../export_html/images/media_file.png + ../../export_html/images/media_file@2x.png + ../../export_html/images/media_game.png + ../../export_html/images/media_game@2x.png + ../../export_html/images/media_location.png + ../../export_html/images/media_location@2x.png + ../../export_html/images/media_music.png + ../../export_html/images/media_music@2x.png + ../../export_html/images/media_photo.png + ../../export_html/images/media_photo@2x.png + ../../export_html/images/media_shop.png + ../../export_html/images/media_shop@2x.png + ../../export_html/images/media_video.png + ../../export_html/images/media_video@2x.png + ../../export_html/images/media_voice.png + ../../export_html/images/media_voice@2x.png + ../../export_html/images/section_calls.png + ../../export_html/images/section_calls@2x.png + ../../export_html/images/section_chats.png + ../../export_html/images/section_chats@2x.png + ../../export_html/images/section_contacts.png + ../../export_html/images/section_contacts@2x.png + ../../export_html/images/section_frequent.png + ../../export_html/images/section_frequent@2x.png + ../../export_html/images/section_other.png + ../../export_html/images/section_other@2x.png + ../../export_html/images/section_photos.png + ../../export_html/images/section_photos@2x.png + ../../export_html/images/section_sessions.png + ../../export_html/images/section_sessions@2x.png + ../../export_html/images/section_web.png + ../../export_html/images/section_web@2x.png + ../../export_html/js/script.js + + diff --git a/Telegram/Resources/qrc/telegram/telegram.qrc b/Telegram/Resources/qrc/telegram/telegram.qrc index 9826d3107..6e477ef03 100644 --- a/Telegram/Resources/qrc/telegram/telegram.qrc +++ b/Telegram/Resources/qrc/telegram/telegram.qrc @@ -1,46 +1,4 @@ - - ../../export_html/css/style.css - ../../export_html/images/back.png - ../../export_html/images/back@2x.png - ../../export_html/images/media_call.png - ../../export_html/images/media_call@2x.png - ../../export_html/images/media_contact.png - ../../export_html/images/media_contact@2x.png - ../../export_html/images/media_file.png - ../../export_html/images/media_file@2x.png - ../../export_html/images/media_game.png - ../../export_html/images/media_game@2x.png - ../../export_html/images/media_location.png - ../../export_html/images/media_location@2x.png - ../../export_html/images/media_music.png - ../../export_html/images/media_music@2x.png - ../../export_html/images/media_photo.png - ../../export_html/images/media_photo@2x.png - ../../export_html/images/media_shop.png - ../../export_html/images/media_shop@2x.png - ../../export_html/images/media_video.png - ../../export_html/images/media_video@2x.png - ../../export_html/images/media_voice.png - ../../export_html/images/media_voice@2x.png - ../../export_html/images/section_calls.png - ../../export_html/images/section_calls@2x.png - ../../export_html/images/section_chats.png - ../../export_html/images/section_chats@2x.png - ../../export_html/images/section_contacts.png - ../../export_html/images/section_contacts@2x.png - ../../export_html/images/section_frequent.png - ../../export_html/images/section_frequent@2x.png - ../../export_html/images/section_other.png - ../../export_html/images/section_other@2x.png - ../../export_html/images/section_photos.png - ../../export_html/images/section_photos@2x.png - ../../export_html/images/section_sessions.png - ../../export_html/images/section_sessions@2x.png - ../../export_html/images/section_web.png - ../../export_html/images/section_web@2x.png - ../../export_html/js/script.js - ../../art/background.tgv ../../art/bg_thumbnail.png diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 2525fc5be..111bea5b8 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -576,17 +576,13 @@ colorValueInput: InputField(defaultInputField) { colorResultInput: InputField(colorValueInput) { } -changePhoneIcon: icon { - { "phone_simcard_from", changePhoneSimcardFrom }, - { "phone_simcard_migrate", changePhoneSimcardTo, point(30px, 11px) }, - { "phone_simcard_to", changePhoneSimcardTo, point(78px, 0px) } -}; changePhoneDescription: FlatLabel(boxLabel) { minWidth: 332px; align: align(top); } -changePhoneIconTop: 20px; -changePhoneDescriptionTop: 96px; +changePhoneIconTop: 16px; +changePhoneIconSize: 96px; +changePhoneDescriptionTop: 128px; changePhoneLabel: FlatLabel(defaultFlatLabel) { minWidth: 275px; textFg: windowSubTextFg; diff --git a/Telegram/SourceFiles/boxes/change_phone_box.cpp b/Telegram/SourceFiles/boxes/change_phone_box.cpp index 0fc45233e..643f04b0f 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/change_phone_box.cpp @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_user.h" #include "mtproto/sender.h" +#include "lottie/lottie_icon.h" #include "apiwrap.h" #include "window/window_session_controller.h" #include "styles/style_layers.h" @@ -66,6 +67,26 @@ void CreateErrorLabel( } // namespace +namespace Settings { + +ChangePhone::ChangePhone( + QWidget *parent, + not_null controller) +: Section(parent) { + setupContent(controller); +} + +rpl::producer ChangePhone::Title() { + return tr::lng_change_phone_button(); +} + +void ChangePhone::setupContent( + not_null controller) { + +} + +} // namespace Settings + class ChangePhoneBox::EnterPhone : public Ui::BoxContent { public: EnterPhone(QWidget*, not_null controller); @@ -434,7 +455,22 @@ void ChangePhoneBox::EnterCode::sendCodeFail(const MTP::Error &error) { ChangePhoneBox::ChangePhoneBox( QWidget*, not_null controller) -: _controller(controller) { +: _controller(controller) +, _icon(Lottie::MakeIcon({ + .name = u"change_number"_q, + .sizeOverride = { + st::changePhoneIconSize, + st::changePhoneIconSize, + }, +})) { +} + +void ChangePhoneBox::showFinished() { + animateIcon(); +} + +void ChangePhoneBox::animateIcon() { + _icon->animate([=] { update(); }, 0, _icon->framesCount()); } void ChangePhoneBox::prepare() { @@ -473,9 +509,9 @@ void ChangePhoneBox::paintEvent(QPaintEvent *e) { BoxContent::paintEvent(e); Painter p(this); - st::changePhoneIcon.paint( - p, - (width() - st::changePhoneIcon.width()) / 2, - st::changePhoneIconTop, - width()); + const auto left = (width() - st::changePhoneIconSize) / 2; + _icon->paint(p, left, st::changePhoneIconTop); + if (!_icon->animating() && _icon->frameIndex() > 0) { + animateIcon(); + } } diff --git a/Telegram/SourceFiles/boxes/change_phone_box.h b/Telegram/SourceFiles/boxes/change_phone_box.h index ee34b7776..a7dbb1f80 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.h +++ b/Telegram/SourceFiles/boxes/change_phone_box.h @@ -8,14 +8,40 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "boxes/abstract_box.h" +#include "settings/settings_common.h" + +namespace Lottie { +class Icon; +} // namespace Lottie namespace Window { class SessionController; } // namespace Window +namespace Settings { + +class ChangePhone : public Section { +public: + ChangePhone( + QWidget *parent, + not_null controller); + + [[nodiscard]] static rpl::producer Title(); + +private: + void setupContent(not_null controller); + +}; + +} // namespace Settings + class ChangePhoneBox : public Ui::BoxContent { public: - ChangePhoneBox(QWidget*, not_null controller); + ChangePhoneBox( + QWidget*, + not_null controller); + + void showFinished() override; protected: void prepare() override; @@ -23,10 +49,13 @@ protected: void paintEvent(QPaintEvent *e) override; private: + void animateIcon(); + class EnterPhone; class EnterCode; const not_null _controller; + const std::unique_ptr _icon; }; diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_reactions.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_reactions.cpp index bc2a029ff..c571ebdd5 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_reactions.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_reactions.cpp @@ -53,7 +53,7 @@ void AddReactionIcon( }, icon->lifetime()); const auto initLottie = [=] { - state->icon = std::make_unique(Lottie::IconDescriptor{ + state->icon = Lottie::MakeIcon({ .path = state->media->owner()->filepath(true), .json = state->media->bytes(), .sizeOverride = QSize(size, size), diff --git a/Telegram/SourceFiles/boxes/sessions_box.cpp b/Telegram/SourceFiles/boxes/sessions_box.cpp index 6af1aaf57..dc0566344 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.cpp +++ b/Telegram/SourceFiles/boxes/sessions_box.cpp @@ -289,7 +289,7 @@ void RenameBox(not_null box) { Unexpected("Type in LottieForType."); }(); const auto size = st::sessionBigLottieSize; - return std::make_unique(Lottie::IconDescriptor{ + return Lottie::MakeIcon({ .path = u":/icons/settings/devices/"_q + path + u".lottie"_q, .sizeOverride = QSize(size, size), }); @@ -1163,6 +1163,10 @@ Sessions::Sessions( setupContent(controller); } +rpl::producer Sessions::Title() { + return tr::lng_settings_sessions_title(); +} + void Sessions::setupContent(not_null controller) { const auto container = Ui::CreateChild(this); AddSkip(container, st::settingsPrivacySkip); diff --git a/Telegram/SourceFiles/boxes/sessions_box.h b/Telegram/SourceFiles/boxes/sessions_box.h index ac6654015..c096b0a55 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.h +++ b/Telegram/SourceFiles/boxes/sessions_box.h @@ -16,12 +16,14 @@ class Session; namespace Settings { -class Sessions : public Section { +class Sessions : public Section { public: Sessions( QWidget *parent, not_null controller); + [[nodiscard]] static rpl::producer Title(); + private: void setupContent(not_null controller); diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index a75c5e39e..d8c4f4b92 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -38,6 +38,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_controller.h" #include "window/themes/window_theme_editor_box.h" // GenerateSlug. #include "settings/settings_common.h" +#include "settings/settings_folders.h" +#include "settings/settings_main.h" #include "mainwidget.h" #include "main/main_session.h" #include "main/main_session_settings.h" @@ -435,10 +437,10 @@ bool ResolveSettings( controller->session().api().authorizations().reload(); } const auto type = (section == qstr("folders")) - ? ::Settings::Type::Folders + ? ::Settings::Folders::Id() : (section == qstr("devices")) - ? ::Settings::Type::Sessions - : ::Settings::Type::Main; + ? ::Settings::Sessions::Id() + : ::Settings::Main::Id(); controller->showSettings(type); return true; } diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp index 2cec99a73..2d27e9c40 100644 --- a/Telegram/SourceFiles/core/update_checker.cpp +++ b/Telegram/SourceFiles/core/update_checker.cpp @@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/info_memento.h" #include "info/settings/info_settings_widget.h" #include "window/window_session_controller.h" +#include "settings/settings_advanced.h" #include "settings/settings_intro.h" #include "ui/layers/box_content.h" @@ -1652,7 +1653,7 @@ void UpdateApplication() { controller->showSection( std::make_shared( Info::Settings::Tag{ controller->session().user() }, - Info::Section::SettingsType::Advanced), + ::Settings::Advanced::Id()), Window::SectionShow()); } else { window->showSpecialLayer( diff --git a/Telegram/SourceFiles/data/data_message_reactions.cpp b/Telegram/SourceFiles/data/data_message_reactions.cpp index 42aac1b24..958b85bcf 100644 --- a/Telegram/SourceFiles/data/data_message_reactions.cpp +++ b/Telegram/SourceFiles/data/data_message_reactions.cpp @@ -234,7 +234,7 @@ void Reactions::loadImage( void Reactions::setLottie(ImageSet &set) { const auto size = style::ConvertScale(kSizeForDownscale); - set.icon = std::make_unique(Lottie::IconDescriptor{ + set.icon = Lottie::MakeIcon({ .path = set.media->owner()->filepath(true), .json = set.media->bytes(), .sizeOverride = QSize(size, size), diff --git a/Telegram/SourceFiles/history/view/history_view_react_animation.cpp b/Telegram/SourceFiles/history/view/history_view_react_animation.cpp index c5804559d..f332fba6f 100644 --- a/Telegram/SourceFiles/history/view/history_view_react_animation.cpp +++ b/Telegram/SourceFiles/history/view/history_view_react_animation.cpp @@ -45,7 +45,7 @@ Animation::Animation( if (!media || !media->loaded()) { return false; } - icon = std::make_unique(Lottie::IconDescriptor{ + icon = Lottie::MakeIcon({ .path = document->filepath(true), .json = media->bytes(), .sizeOverride = QSize(size, size), diff --git a/Telegram/SourceFiles/info/info_top_bar.cpp b/Telegram/SourceFiles/info/info_top_bar.cpp index daf21dcc6..3b7155349 100644 --- a/Telegram/SourceFiles/info/info_top_bar.cpp +++ b/Telegram/SourceFiles/info/info_top_bar.cpp @@ -617,29 +617,7 @@ rpl::producer TitleValue( return tr::lng_profile_participants_section(); case Section::Type::Settings: - switch (section.settingsType()) { - case Section::SettingsType::Main: - return tr::lng_menu_settings(); - case Section::SettingsType::Information: - return tr::lng_settings_section_info(); - case Section::SettingsType::Notifications: - return tr::lng_settings_section_notify(); - case Section::SettingsType::PrivacySecurity: - return tr::lng_settings_section_privacy(); - case Section::SettingsType::Sessions: - return tr::lng_settings_sessions_title(); - case Section::SettingsType::Advanced: - return tr::lng_settings_advanced(); - case Section::SettingsType::Chat: - return tr::lng_settings_section_chat_settings(); - case Section::SettingsType::Folders: - return tr::lng_filters_title(); - case Section::SettingsType::Calls: - return tr::lng_settings_section_call_settings(); - case Section::SettingsType::Experimental: - return tr::lng_settings_experimental(); - } - Unexpected("Bad settings type in Info::TitleValue()"); + return section.settingsType()()->title(); case Section::Type::PollResults: return key.poll()->quiz() diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index 28da06c3f..e3c07c3b7 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -14,6 +14,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/info_controller.h" #include "info/info_memento.h" #include "info/info_top_bar.h" +#include "settings/settings_chat.h" +#include "settings/settings_main.h" #include "ui/widgets/discrete_sliders.h" #include "ui/widgets/buttons.h" #include "ui/widgets/shadow.h" @@ -395,8 +397,8 @@ void WrapWidget::createTopBar() { addTopBarMenuButton(); addProfileCallsButton(); } else if (section.type() == Section::Type::Settings - && (section.settingsType() == Section::SettingsType::Main - || section.settingsType() == Section::SettingsType::Chat)) { + && (section.settingsType() == ::Settings::Main::Id() + || section.settingsType() == ::Settings::Chat::Id())) { addTopBarMenuButton(); } else if (section.type() == Section::Type::Downloads) { auto &manager = Core::App().downloadManager(); diff --git a/Telegram/SourceFiles/info/settings/info_settings_widget.cpp b/Telegram/SourceFiles/info/settings/info_settings_widget.cpp index ed1b7ee25..57e6152c1 100644 --- a/Telegram/SourceFiles/info/settings/info_settings_widget.cpp +++ b/Telegram/SourceFiles/info/settings/info_settings_widget.cpp @@ -10,6 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/info_memento.h" #include "info/info_controller.h" #include "settings/settings_common.h" +#include "settings/settings_main.h" +#include "settings/settings_information.h" #include "ui/ui_utility.h" namespace Info { @@ -43,11 +45,9 @@ Widget::Widget( : ContentWidget(parent, controller) , _self(controller->key().settingsSelf()) , _type(controller->section().settingsType()) -, _inner(setInnerWidget( - ::Settings::CreateSection( - _type, - this, - controller->parentController()))) { +, _inner( + setInnerWidget( + _type()->create(this, controller->parentController()))) { _inner->sectionShowOther( ) | rpl::start_with_next([=](Type type) { controller->showSettings(type); @@ -84,7 +84,8 @@ void Widget::saveChanges(FnMut done) { } rpl::producer Widget::desiredShadowVisibility() const { - return (_type == Type::Main || _type == Type::Information) + return (_type == ::Settings::Main::Id() + || _type == ::Settings::Information::Id()) ? ContentWidget::desiredShadowVisibility() : rpl::single(true); } diff --git a/Telegram/SourceFiles/info/settings/info_settings_widget.h b/Telegram/SourceFiles/info/settings/info_settings_widget.h index 604b589e7..6c95e1c94 100644 --- a/Telegram/SourceFiles/info/settings/info_settings_widget.h +++ b/Telegram/SourceFiles/info/settings/info_settings_widget.h @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/info_controller.h" namespace Settings { -class Section; +class AbstractSection; } // namespace Settings namespace Info { @@ -76,7 +76,7 @@ private: not_null _self; Type _type = Type(); - not_null<::Settings::Section*> _inner; + not_null<::Settings::AbstractSection*> _inner; }; diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index d28be32fd..5005e4152 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -682,6 +682,12 @@ std::unique_ptr MakeAttachBotsMenu( const auto raw = result.get(); const auto refresh = [=] { raw->clearActions(); + raw->addAction(u"Photo or video"_q, [=] { + + }); + raw->addAction(u"Document"_q, [=] { + + }); for (const auto &bot : bots->attachBots()) { const auto callback = [=] { const auto active = controller->activeChatCurrent(); diff --git a/Telegram/SourceFiles/settings/settings_advanced.cpp b/Telegram/SourceFiles/settings/settings_advanced.cpp index 19554b10f..d7ffcafe9 100644 --- a/Telegram/SourceFiles/settings/settings_advanced.cpp +++ b/Telegram/SourceFiles/settings/settings_advanced.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "settings/settings_common.h" #include "settings/settings_chat.h" +#include "settings/settings_experimental.h" #include "ui/wrap/vertical_layout.h" #include "ui/wrap/slide_wrap.h" #include "ui/widgets/labels.h" @@ -133,7 +134,7 @@ void SetupUpdate( experimental->toggleOn(install->toggledValue()); } experimental->entity()->setClickedCallback([=] { - showOther(Type::Experimental); + showOther(Experimental::Id()); }); } @@ -740,6 +741,10 @@ Advanced::Advanced( setupContent(controller); } +rpl::producer Advanced::Title() { + return tr::lng_settings_advanced(); +} + rpl::producer Advanced::sectionShowOther() { return _showOther.events(); } diff --git a/Telegram/SourceFiles/settings/settings_advanced.h b/Telegram/SourceFiles/settings/settings_advanced.h index 97109e508..4b1d64ed9 100644 --- a/Telegram/SourceFiles/settings/settings_advanced.h +++ b/Telegram/SourceFiles/settings/settings_advanced.h @@ -21,7 +21,7 @@ namespace Settings { void SetupConnectionType( not_null controller, - not_null account, + not_null<::Main::Account*> account, not_null container); bool HasUpdate(); void SetupUpdate( @@ -32,12 +32,14 @@ void SetupSystemIntegrationContent( not_null container); void SetupAnimations(not_null container); -class Advanced : public Section { +class Advanced : public Section { public: Advanced( QWidget *parent, not_null controller); + [[nodiscard]] static rpl::producer Title(); + rpl::producer sectionShowOther() override; private: diff --git a/Telegram/SourceFiles/settings/settings_calls.cpp b/Telegram/SourceFiles/settings/settings_calls.cpp index 4b39177b9..65c72965f 100644 --- a/Telegram/SourceFiles/settings/settings_calls.cpp +++ b/Telegram/SourceFiles/settings/settings_calls.cpp @@ -56,6 +56,10 @@ Calls::Calls( Calls::~Calls() = default; +rpl::producer Calls::Title() { + return tr::lng_settings_section_call_settings(); +} + Webrtc::VideoTrack *Calls::AddCameraSubsection( std::shared_ptr show, not_null content, diff --git a/Telegram/SourceFiles/settings/settings_calls.h b/Telegram/SourceFiles/settings/settings_calls.h index dbc6af95c..b469ff084 100644 --- a/Telegram/SourceFiles/settings/settings_calls.h +++ b/Telegram/SourceFiles/settings/settings_calls.h @@ -33,11 +33,13 @@ class VideoTrack; namespace Settings { -class Calls : public Section { +class Calls : public Section { public: Calls(QWidget *parent, not_null controller); ~Calls(); + [[nodiscard]] static rpl::producer Title(); + void sectionSaveChanges(FnMut done) override; static Webrtc::VideoTrack *AddCameraSubsection( diff --git a/Telegram/SourceFiles/settings/settings_chat.cpp b/Telegram/SourceFiles/settings/settings_chat.cpp index cd3971286..26102e082 100644 --- a/Telegram/SourceFiles/settings/settings_chat.cpp +++ b/Telegram/SourceFiles/settings/settings_chat.cpp @@ -1513,6 +1513,10 @@ Chat::Chat(QWidget *parent, not_null controller) setupContent(controller); } +rpl::producer Chat::Title() { + return tr::lng_settings_section_chat_settings(); +} + void Chat::setupContent(not_null controller) { const auto content = Ui::CreateChild(this); diff --git a/Telegram/SourceFiles/settings/settings_chat.h b/Telegram/SourceFiles/settings/settings_chat.h index ff2153b91..777182184 100644 --- a/Telegram/SourceFiles/settings/settings_chat.h +++ b/Telegram/SourceFiles/settings/settings_chat.h @@ -31,10 +31,12 @@ void SetupExport( not_null controller, not_null container); -class Chat : public Section { +class Chat : public Section { public: Chat(QWidget *parent, not_null controller); + [[nodiscard]] static rpl::producer Title(); + private: void setupContent(not_null controller); diff --git a/Telegram/SourceFiles/settings/settings_codes.cpp b/Telegram/SourceFiles/settings/settings_codes.cpp index 536cdd2c6..c8968ef53 100644 --- a/Telegram/SourceFiles/settings/settings_codes.cpp +++ b/Telegram/SourceFiles/settings/settings_codes.cpp @@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_session_controller.h" #include "media/audio/media_audio_track.h" #include "settings/settings_common.h" +#include "settings/settings_folders.h" #include "api/api_updates.h" #include "base/qt/qt_common_adapters.h" #include "base/custom_app_icon.h" @@ -171,7 +172,7 @@ auto GenerateCodes() { }); codes.emplace(qsl("folders"), [](SessionController *window) { if (window) { - window->showSettings(Settings::Type::Folders); + window->showSettings(Settings::Folders::Id()); } }); codes.emplace(qsl("registertg"), [](SessionController *window) { diff --git a/Telegram/SourceFiles/settings/settings_common.cpp b/Telegram/SourceFiles/settings/settings_common.cpp index 4aba174cc..3f7cf3f3f 100644 --- a/Telegram/SourceFiles/settings/settings_common.cpp +++ b/Telegram/SourceFiles/settings/settings_common.cpp @@ -106,35 +106,6 @@ QSize Icon::size() const { return _icon->size(); } -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); - case Type::Experimental: - return object_ptr(parent, controller); - } - Unexpected("Settings section type in Widget::createInnerWidget."); -} - void AddSkip(not_null container) { AddSkip(container, st::settingsSectionSkip); } @@ -278,7 +249,7 @@ void FillMenu( Fn showOther, MenuCallback addAction) { const auto window = &controller->window(); - if (type == Type::Chat) { + if (type == Chat::Id()) { addAction( tr::lng_settings_bg_theme_create(tr::now), [=] { window->show(Box(Window::Theme::CreateBox, window)); }, @@ -293,7 +264,7 @@ void FillMenu( if (!controller->session().supportMode()) { addAction( tr::lng_settings_information(tr::now), - [=] { showOther(Type::Information); }, + [=] { showOther(Information::Id()); }, &st::menuIconInfo); } addAction( diff --git a/Telegram/SourceFiles/settings/settings_common.h b/Telegram/SourceFiles/settings/settings_common.h index 03108a47b..b912ed476 100644 --- a/Telegram/SourceFiles/settings/settings_common.h +++ b/Telegram/SourceFiles/settings/settings_common.h @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" #include "ui/round_rect.h" #include "base/object_ptr.h" +#include "settings/settings_type.h" namespace Main { class Session; @@ -35,32 +36,59 @@ namespace Settings { extern const char kOptionMonoSettingsIcons[]; -enum class Type { - Main, - Information, - Notifications, - PrivacySecurity, - Sessions, - Advanced, - Chat, - Folders, - Calls, - Experimental, -}; - using Button = Ui::SettingsButton; -class Section : public Ui::RpWidget { +class AbstractSection; + +struct SectionMeta { + [[nodiscard]] virtual object_ptr create( + not_null parent, + not_null controller) const = 0; + [[nodiscard]] virtual rpl::producer title() const = 0; +}; + +template +struct SectionMetaImplementation : SectionMeta { + object_ptr create( + not_null parent, + not_null controller + ) const final override { + return object_ptr(parent, controller); + } + rpl::producer title() const final override { + return SectionType::Title(); + } + + [[nodiscard]] static not_null Meta() { + static SectionMetaImplementation result; + return &result; + } +}; + +class AbstractSection : public Ui::RpWidget { public: using RpWidget::RpWidget; - virtual rpl::producer sectionShowOther() { + [[nodiscard]] virtual Type id() const = 0; + [[nodiscard]] virtual rpl::producer sectionShowOther() { return nullptr; } virtual void sectionSaveChanges(FnMut done) { done(); } +}; +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; @@ -105,11 +133,6 @@ private: }; -object_ptr
CreateSection( - Type type, - not_null parent, - not_null controller); - void AddSkip(not_null container); void AddSkip(not_null container, int skip); void AddDivider(not_null container); diff --git a/Telegram/SourceFiles/settings/settings_experimental.cpp b/Telegram/SourceFiles/settings/settings_experimental.cpp index b07e549f4..3fbfcf13c 100644 --- a/Telegram/SourceFiles/settings/settings_experimental.cpp +++ b/Telegram/SourceFiles/settings/settings_experimental.cpp @@ -146,6 +146,10 @@ Experimental::Experimental( setupContent(controller); } +rpl::producer Experimental::Title() { + return tr::lng_settings_experimental(); +} + void Experimental::setupContent( not_null controller) { const auto content = Ui::CreateChild(this); diff --git a/Telegram/SourceFiles/settings/settings_experimental.h b/Telegram/SourceFiles/settings/settings_experimental.h index 0d0e79dc4..892b4c9d6 100644 --- a/Telegram/SourceFiles/settings/settings_experimental.h +++ b/Telegram/SourceFiles/settings/settings_experimental.h @@ -11,12 +11,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Settings { -class Experimental : public Section { +class Experimental : public Section { public: Experimental( QWidget *parent, not_null controller); + [[nodiscard]] static rpl::producer Title(); + private: void setupContent(not_null controller); diff --git a/Telegram/SourceFiles/settings/settings_folders.cpp b/Telegram/SourceFiles/settings/settings_folders.cpp index 646191e57..7076591a0 100644 --- a/Telegram/SourceFiles/settings/settings_folders.cpp +++ b/Telegram/SourceFiles/settings/settings_folders.cpp @@ -580,6 +580,10 @@ Folders::~Folders() { } } +rpl::producer Folders::Title() { + return tr::lng_filters_title(); +} + void Folders::setupContent(not_null controller) { controller->session().data().chatsFilters().requestSuggested(); diff --git a/Telegram/SourceFiles/settings/settings_folders.h b/Telegram/SourceFiles/settings/settings_folders.h index 63089cf5f..b771292a8 100644 --- a/Telegram/SourceFiles/settings/settings_folders.h +++ b/Telegram/SourceFiles/settings/settings_folders.h @@ -11,13 +11,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Settings { -class Folders : public Section { +class Folders : public Section { public: Folders( QWidget *parent, not_null controller); ~Folders(); + [[nodiscard]] static rpl::producer Title(); + private: void setupContent(not_null controller); diff --git a/Telegram/SourceFiles/settings/settings_information.cpp b/Telegram/SourceFiles/settings/settings_information.cpp index 8ed2f32e6..e406d1da6 100644 --- a/Telegram/SourceFiles/settings/settings_information.cpp +++ b/Telegram/SourceFiles/settings/settings_information.cpp @@ -793,6 +793,10 @@ Information::Information( setupContent(controller); } +rpl::producer Information::Title() { + return tr::lng_settings_section_info(); +} + void Information::setupContent( not_null controller) { const auto content = Ui::CreateChild(this); diff --git a/Telegram/SourceFiles/settings/settings_information.h b/Telegram/SourceFiles/settings/settings_information.h index 21fbb081b..05ea4e349 100644 --- a/Telegram/SourceFiles/settings/settings_information.h +++ b/Telegram/SourceFiles/settings/settings_information.h @@ -15,12 +15,14 @@ struct UnreadBadgeStyle; namespace Settings { -class Information : public Section { +class Information : public Section { public: Information( QWidget *parent, not_null controller); + [[nodiscard]] static rpl::producer Title(); + private: void setupContent(not_null controller); diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index 5906aed48..696305290 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -10,6 +10,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "settings/settings_common.h" #include "settings/settings_codes.h" #include "settings/settings_chat.h" +#include "settings/settings_information.h" +#include "settings/settings_notifications.h" +#include "settings/settings_privacy_security.h" +#include "settings/settings_advanced.h" +#include "settings/settings_folders.h" +#include "settings/settings_calls.h" #include "boxes/language_box.h" #include "boxes/username_box.h" #include "ui/boxes/confirm_box.h" @@ -251,20 +257,20 @@ void SetupSections( } else { addSection( tr::lng_settings_information(), - Type::Information, + Information::Id(), { &st::settingsIconAccount, kIconLightOrange }); } addSection( tr::lng_settings_section_notify(), - Type::Notifications, + Notifications::Id(), { &st::settingsIconNotifications, kIconRed }); addSection( tr::lng_settings_section_privacy(), - Type::PrivacySecurity, + PrivacySecurity::Id(), { &st::settingsIconLock, kIconGreen }); addSection( tr::lng_settings_section_chat_settings(), - Type::Chat, + Chat::Id(), { &st::settingsIconChat, kIconLightBlue }); const auto preload = [=] { @@ -307,16 +313,16 @@ void SetupSections( ) | rpl::before_next(preloadIfEnabled)); } slided->entity()->setClickedCallback([=] { - showOther(Type::Folders); + showOther(Folders::Id()); }); addSection( tr::lng_settings_advanced(), - Type::Advanced, + Advanced::Id(), { &st::settingsIconGeneral, kIconPurple }); addSection( tr::lng_settings_section_call_settings(), - Type::Calls, + Calls::Id(), { &st::settingsIconCalls, kIconGreen }); SetupLanguageButton(container); @@ -524,6 +530,10 @@ Main::Main( setupContent(controller); } +rpl::producer Main::Title() { + return tr::lng_menu_settings(); +} + void Main::keyPressEvent(QKeyEvent *e) { crl::on_main(this, [=, text = e->text()]{ CodesFeedString(_controller, text); diff --git a/Telegram/SourceFiles/settings/settings_main.h b/Telegram/SourceFiles/settings/settings_main.h index c90f8bf8c..860ea2781 100644 --- a/Telegram/SourceFiles/settings/settings_main.h +++ b/Telegram/SourceFiles/settings/settings_main.h @@ -32,10 +32,12 @@ void SetupFaq( not_null container, bool icon = true); -class Main : public Section { +class Main : public Section
{ public: Main(QWidget *parent, not_null controller); + [[nodiscard]] static rpl::producer Title(); + rpl::producer sectionShowOther() override; protected: diff --git a/Telegram/SourceFiles/settings/settings_notifications.cpp b/Telegram/SourceFiles/settings/settings_notifications.cpp index 0697b3fa1..a2ff8cc8c 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications.cpp @@ -1097,6 +1097,10 @@ Notifications::Notifications( setupContent(controller); } +rpl::producer Notifications::Title() { + return tr::lng_settings_section_notify(); +} + void Notifications::setupContent( not_null controller) { const auto content = Ui::CreateChild(this); diff --git a/Telegram/SourceFiles/settings/settings_notifications.h b/Telegram/SourceFiles/settings/settings_notifications.h index 38327de92..c405ce96d 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.h +++ b/Telegram/SourceFiles/settings/settings_notifications.h @@ -11,12 +11,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Settings { -class Notifications : public Section { +class Notifications : public Section { public: Notifications( QWidget *parent, not_null controller); + [[nodiscard]] static rpl::producer Title(); + private: void setupContent(not_null controller); diff --git a/Telegram/SourceFiles/settings/settings_privacy_security.cpp b/Telegram/SourceFiles/settings/settings_privacy_security.cpp index c3500e8af..989a76779 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_security.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_security.cpp @@ -820,7 +820,7 @@ void SetupSessionsList( st::settingsButton, { &st::settingsIconLaptop, kIconLightOrange } )->addClickHandler([=] { - showOther(Type::Sessions); + showOther(Sessions::Id()); }); } @@ -971,6 +971,10 @@ PrivacySecurity::PrivacySecurity( setupContent(controller); } +rpl::producer PrivacySecurity::Title() { + return tr::lng_settings_section_privacy(); +} + rpl::producer PrivacySecurity::sectionShowOther() { return _showOther.events(); } diff --git a/Telegram/SourceFiles/settings/settings_privacy_security.h b/Telegram/SourceFiles/settings/settings_privacy_security.h index 5b12525c8..a47feca1d 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_security.h +++ b/Telegram/SourceFiles/settings/settings_privacy_security.h @@ -34,12 +34,14 @@ void AddPrivacyButton( Api::UserPrivacy::Key key, Fn()> controllerFactory); -class PrivacySecurity : public Section { +class PrivacySecurity : public Section { public: PrivacySecurity( QWidget *parent, not_null controller); + [[nodiscard]] static rpl::producer Title(); + rpl::producer sectionShowOther() override; private: diff --git a/Telegram/SourceFiles/settings/settings_type.h b/Telegram/SourceFiles/settings/settings_type.h new file mode 100644 index 000000000..76b8d9840 --- /dev/null +++ b/Telegram/SourceFiles/settings/settings_type.h @@ -0,0 +1,15 @@ +/* +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 + +namespace Settings { + +struct SectionMeta; +using Type = not_null(*)(); + +} // namespace Settings diff --git a/Telegram/SourceFiles/window/window_filters_menu.cpp b/Telegram/SourceFiles/window/window_filters_menu.cpp index 36ccdcfc5..853cccad4 100644 --- a/Telegram/SourceFiles/window/window_filters_menu.cpp +++ b/Telegram/SourceFiles/window/window_filters_menu.cpp @@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/boxes/confirm_box.h" #include "boxes/filters/edit_filter_box.h" #include "settings/settings_common.h" +#include "settings/settings_folders.h" #include "api/api_chat_filters.h" #include "apiwrap.h" #include "styles/style_widgets.h" @@ -275,13 +276,13 @@ base::unique_qptr FiltersMenu::prepareButton( } else { const auto filters = &_session->session().data().chatsFilters(); if (filters->suggestedLoaded()) { - _session->showSettings(Settings::Type::Folders); + _session->showSettings(Settings::Folders::Id()); } else if (!_waitingSuggested) { _waitingSuggested = true; filters->requestSuggested(); filters->suggestedUpdated( ) | rpl::take(1) | rpl::start_with_next([=] { - _session->showSettings(Settings::Type::Folders); + _session->showSettings(Settings::Folders::Id()); }, _outer.lifetime()); } } diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index c89402eb4..4c0b69502 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/storage_account.h" #include "support/support_templates.h" #include "settings/settings_common.h" +#include "settings/settings_calls.h" #include "settings/settings_information.h" #include "base/qt_signal_producer.h" #include "boxes/about_box.h" @@ -85,7 +86,7 @@ void ShowCallsBox(not_null window) { st::popupMenuWithIcons); const auto showSettings = [=] { window->showSettings( - Settings::Type::Calls, + Settings::Calls::Id(), Window::SectionShow(anim::type::instant)); }; const auto clearAll = crl::guard(box, [=] { diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 830ac0fbc..2362b6b97 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -76,6 +76,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/file_upload.h" #include "facades.h" #include "window/themes/window_theme.h" +#include "settings/settings_main.h" +#include "settings/settings_privacy_security.h" #include "styles/style_window.h" #include "styles/style_dialogs.h" #include "styles/style_layers.h" // st::boxLabel @@ -567,7 +569,7 @@ void SessionNavigation::showSettings( } void SessionNavigation::showSettings(const SectionShow ¶ms) { - showSettings(Settings::Type::Main, params); + showSettings(Settings::Main::Id(), params); } void SessionNavigation::showPollResults( @@ -667,7 +669,7 @@ void SessionController::suggestArchiveAndMute() { tr::lng_suggest_hide_new_about(Ui::Text::RichLangValue), st::boxLabel)); box->addButton(tr::lng_suggest_hide_new_to_settings(), [=] { - showSettings(Settings::Type::PrivacySecurity); + showSettings(Settings::PrivacySecurity::Id()); }); box->setCloseByOutsideClick(false); box->boxClosing( diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 71c57a713..c93744d9e 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "dialogs/dialogs_key.h" #include "ui/layers/layer_widget.h" #include "ui/layers/show.h" +#include "settings/settings_type.h" #include "window/window_adaptive.h" #include "mtproto/sender.h" @@ -40,10 +41,6 @@ namespace InlineBots { class AttachWebView; } // namespace InlineBots -namespace Settings { -enum class Type; -} // namespace Settings - namespace Calls { struct StartGroupCallArgs; } // namespace Calls diff --git a/Telegram/lib_lottie b/Telegram/lib_lottie index e05282127..2ae9d2928 160000 --- a/Telegram/lib_lottie +++ b/Telegram/lib_lottie @@ -1 +1 @@ -Subproject commit e052821270b913798b65f3a1a292b7ab74107ff6 +Subproject commit 2ae9d2928a406da58e510bdda54a99e44c4eff10