From 488f6412f2dafd12654a048eddf4bc5bd9e9bf18 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 13 Apr 2022 12:05:10 +0400 Subject: [PATCH] Change phone number section instead of a box. --- Telegram/SourceFiles/boxes/boxes.style | 19 ++- .../SourceFiles/boxes/change_phone_box.cpp | 157 +++++++++--------- Telegram/SourceFiles/boxes/change_phone_box.h | 36 +--- Telegram/SourceFiles/boxes/sessions_box.cpp | 2 +- Telegram/SourceFiles/boxes/sessions_box.h | 2 +- .../SourceFiles/info/info_content_widget.h | 2 + .../SourceFiles/info/info_wrap_widget.cpp | 1 + .../info/settings/info_settings_widget.cpp | 6 +- .../info/settings/info_settings_widget.h | 2 + .../settings/settings_advanced.cpp | 2 +- .../SourceFiles/settings/settings_advanced.h | 2 +- .../SourceFiles/settings/settings_calls.cpp | 2 +- .../SourceFiles/settings/settings_calls.h | 2 +- .../SourceFiles/settings/settings_chat.cpp | 2 +- Telegram/SourceFiles/settings/settings_chat.h | 2 +- .../SourceFiles/settings/settings_common.cpp | 35 ++++ .../SourceFiles/settings/settings_common.h | 20 ++- .../settings/settings_experimental.cpp | 2 +- .../settings/settings_experimental.h | 2 +- .../SourceFiles/settings/settings_folders.cpp | 2 +- .../SourceFiles/settings/settings_folders.h | 2 +- .../settings/settings_information.cpp | 9 +- .../settings/settings_information.h | 2 +- .../SourceFiles/settings/settings_main.cpp | 2 +- Telegram/SourceFiles/settings/settings_main.h | 2 +- .../settings/settings_notifications.cpp | 2 +- .../settings/settings_notifications.h | 2 +- .../settings/settings_privacy_security.cpp | 2 +- .../settings/settings_privacy_security.h | 2 +- 29 files changed, 189 insertions(+), 136 deletions(-) diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 68eb0b492..98f306627 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -576,13 +576,24 @@ colorValueInput: InputField(defaultInputField) { colorResultInput: InputField(colorValueInput) { } -changePhoneDescription: FlatLabel(boxLabel) { +changePhoneButton: RoundButton(defaultActiveButton) { + width: 256px; + height: 42px; + textTop: 11px; + font: boxButtonFont; +} +changePhoneButtonPadding: margins(0px, 32px, 0px, 44px); +changePhoneTitle: FlatLabel(boxTitle) { +} +changePhoneTitlePadding: margins(0px, 8px, 0px, 8px); +changePhoneDescription: FlatLabel(defaultFlatLabel) { minWidth: 332px; align: align(top); + textFg: windowSubTextFg; } -changePhoneIconTop: 16px; -changePhoneIconSize: 96px; -changePhoneDescriptionTop: 128px; +changePhoneDescriptionPadding: margins(0px, 1px, 0px, 8px); +changePhoneIconPadding: margins(0px, 39px, 0px, 5px); +changePhoneIconSize: 120px; 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 9d7869863..bb2d840d8 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/change_phone_box.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "ui/widgets/labels.h" #include "ui/widgets/sent_code_field.h" +#include "ui/widgets/buttons.h" #include "ui/wrap/fade_wrap.h" #include "ui/toast/toast.h" #include "ui/text/format_values.h" // Ui::FormatPhone @@ -21,8 +22,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "data/data_session.h" #include "data/data_user.h" -#include "mtproto/sender.h" +#include "info/profile/info_profile_values.h" #include "lottie/lottie_icon.h" +#include "mtproto/sender.h" #include "apiwrap.h" #include "window/window_session_controller.h" #include "styles/style_layers.h" @@ -69,25 +71,7 @@ void CreateErrorLabel( 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 { +class ChangePhone::EnterPhone : public Ui::BoxContent { public: EnterPhone(QWidget*, not_null controller); @@ -118,7 +102,7 @@ private: }; -class ChangePhoneBox::EnterCode : public Ui::BoxContent { +class ChangePhone::EnterCode : public Ui::BoxContent { public: EnterCode( QWidget*, @@ -161,14 +145,14 @@ private: }; -ChangePhoneBox::EnterPhone::EnterPhone( +ChangePhone::EnterPhone::EnterPhone( QWidget*, not_null controller) : _controller(controller) , _api(&controller->session().mtp()) { } -void ChangePhoneBox::EnterPhone::prepare() { +void ChangePhone::EnterPhone::prepare() { setTitle(tr::lng_change_phone_title()); const auto phoneValue = QString(); @@ -204,7 +188,7 @@ void ChangePhoneBox::EnterPhone::prepare() { addButton(tr::lng_cancel(), [this] { closeBox(); }); } -void ChangePhoneBox::EnterPhone::submit() { +void ChangePhone::EnterPhone::submit() { if (_requestId) { return; } @@ -223,7 +207,7 @@ void ChangePhoneBox::EnterPhone::submit() { }).handleFloodErrors().send(); } -void ChangePhoneBox::EnterPhone::sendPhoneDone( +void ChangePhone::EnterPhone::sendPhoneDone( const MTPauth_SentCode &result, const QString &phoneNumber) { using CodeData = const MTPDauth_sentCode&; @@ -276,7 +260,7 @@ void ChangePhoneBox::EnterPhone::sendPhoneDone( Ui::LayerOption::KeepOther); } -void ChangePhoneBox::EnterPhone::sendPhoneFail( +void ChangePhone::EnterPhone::sendPhoneFail( const MTP::Error &error, const QString &phoneNumber) { if (MTP::IsFloodError(error)) { @@ -298,7 +282,7 @@ void ChangePhoneBox::EnterPhone::sendPhoneFail( } } -void ChangePhoneBox::EnterPhone::showError(const QString &text) { +void ChangePhone::EnterPhone::showError(const QString &text) { CreateErrorLabel( this, _error, @@ -310,7 +294,7 @@ void ChangePhoneBox::EnterPhone::showError(const QString &text) { } } -ChangePhoneBox::EnterCode::EnterCode( +ChangePhone::EnterCode::EnterCode( QWidget*, not_null controller, const QString &phone, @@ -326,7 +310,7 @@ ChangePhoneBox::EnterCode::EnterCode( , _call([this] { sendCall(); }, [this] { updateCall(); }) { } -void ChangePhoneBox::EnterCode::prepare() { +void ChangePhone::EnterCode::prepare() { setTitle(tr::lng_change_phone_title()); const auto descriptionText = tr::lng_change_phone_code_description( @@ -364,13 +348,13 @@ void ChangePhoneBox::EnterCode::prepare() { addButton(tr::lng_cancel(), [=] { closeBox(); }); } -int ChangePhoneBox::EnterCode::countHeight() { +int ChangePhone::EnterCode::countHeight() { const auto errorSkip = st::boxLittleSkip + st::changePhoneError.style.font->height; return _code->bottomNoMargins() + errorSkip + 3 * st::boxLittleSkip; } -void ChangePhoneBox::EnterCode::submit() { +void ChangePhone::EnterCode::submit() { if (_requestId) { return; } @@ -400,7 +384,7 @@ void ChangePhoneBox::EnterCode::submit() { })).handleFloodErrors().send(); } -void ChangePhoneBox::EnterCode::sendCall() { +void ChangePhone::EnterCode::sendCall() { _api.request(MTPauth_ResendCode( MTP_string(_phone), MTP_string(_hash) @@ -409,7 +393,7 @@ void ChangePhoneBox::EnterCode::sendCall() { }).send(); } -void ChangePhoneBox::EnterCode::updateCall() { +void ChangePhone::EnterCode::updateCall() { const auto text = _call.getText(); if (text.isEmpty()) { _callLabel.destroy(); @@ -424,7 +408,7 @@ void ChangePhoneBox::EnterCode::updateCall() { } } -void ChangePhoneBox::EnterCode::showError(const QString &text) { +void ChangePhone::EnterCode::showError(const QString &text) { CreateErrorLabel( this, _error, @@ -436,7 +420,7 @@ void ChangePhoneBox::EnterCode::showError(const QString &text) { } } -void ChangePhoneBox::EnterCode::sendCodeFail(const MTP::Error &error) { +void ChangePhone::EnterCode::sendCodeFail(const MTP::Error &error) { if (MTP::IsFloodError(error)) { showError(tr::lng_flood_error(tr::now)); } else if (error.type() == qstr("PHONE_CODE_EMPTY") @@ -452,66 +436,81 @@ void ChangePhoneBox::EnterCode::sendCodeFail(const MTP::Error &error) { } } -ChangePhoneBox::ChangePhoneBox( - QWidget*, +ChangePhone::ChangePhone( + QWidget *parent, not_null controller) -: _controller(controller) -, _icon(Lottie::MakeIcon({ - .name = u"change_number"_q, - .sizeOverride = { - st::changePhoneIconSize, - st::changePhoneIconSize, - }, -})) { +: Section(parent) +, _controller(controller) { + setupContent(); } -void ChangePhoneBox::showFinished() { - animateIcon(); +rpl::producer ChangePhone::title() { + return Info::Profile::PhoneValue( + _controller->session().user() + ) | rpl::map([](const TextWithEntities &text) { + return text.text; + }); } -void ChangePhoneBox::animateIcon() { - _icon->animate([=] { update(); }, 0, _icon->framesCount()); -} +void ChangePhone::setupContent() { + const auto content = Ui::CreateChild(this); -void ChangePhoneBox::prepare() { - setTitle(tr::lng_change_phone_title()); - addButton(tr::lng_change_phone_button(), [=, controller = _controller] { + auto icon = CreateLottieIcon(content, { + .name = u"change_number"_q, + .sizeOverride = { + st::changePhoneIconSize, + st::changePhoneIconSize, + }, + }, st::changePhoneIconPadding); + content->add(std::move(icon.widget)); + _animate = std::move(icon.animate); + + content->add( + object_ptr>( + content, + object_ptr( + content, + tr::lng_change_phone_button(), + st::changePhoneTitle)), + st::changePhoneTitlePadding); + + content->add( + object_ptr>( + content, + object_ptr( + content, + tr::lng_change_phone_about(Ui::Text::RichLangValue), + st::changePhoneDescription)), + st::changePhoneDescriptionPadding); + + const auto button = content->add( + object_ptr>( + content, + object_ptr( + content, + tr::lng_change_phone_button(), + st::changePhoneButton)), + st::changePhoneButtonPadding)->entity(); + button->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); + button->setClickedCallback([=] { auto callback = [=] { - controller->show( - Box(controller), + _controller->show( + Box(_controller), Ui::LayerOption::CloseOther); }; - controller->show( + _controller->show( Ui::MakeConfirmBox({ .text = tr::lng_change_phone_warning(), .confirmed = std::move(callback), }), Ui::LayerOption::CloseOther); }); - addButton(tr::lng_cancel(), [this] { - closeBox(); - }); - const auto label = Ui::CreateChild( - this, - tr::lng_change_phone_about(Ui::Text::RichLangValue), - st::changePhoneDescription); - label->moveToLeft( - (st::boxWideWidth - label->width()) / 2, - st::changePhoneDescriptionTop); - - setDimensions( - st::boxWideWidth, - label->bottomNoMargins() + st::boxLittleSkip); + Ui::ResizeFitChild(this, content); } -void ChangePhoneBox::paintEvent(QPaintEvent *e) { - BoxContent::paintEvent(e); - - Painter p(this); - const auto left = (width() - st::changePhoneIconSize) / 2; - _icon->paint(p, left, st::changePhoneIconTop); - if (!_icon->animating() && _icon->frameIndex() > 0) { - animateIcon(); - } +void ChangePhone::showFinished() { + _animate(); } + +} // namespace Settings diff --git a/Telegram/SourceFiles/boxes/change_phone_box.h b/Telegram/SourceFiles/boxes/change_phone_box.h index a7dbb1f80..ecaf197fe 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.h +++ b/Telegram/SourceFiles/boxes/change_phone_box.h @@ -26,36 +26,18 @@ public: QWidget *parent, not_null controller); - [[nodiscard]] static rpl::producer Title(); + void showFinished() override; + [[nodiscard]] rpl::producer title() override; private: - void setupContent(not_null controller); + class EnterPhone; + class EnterCode; + + void setupContent(); + + const not_null _controller; + Fn _animate; }; } // namespace Settings - -class ChangePhoneBox : public Ui::BoxContent { -public: - ChangePhoneBox( - QWidget*, - not_null controller); - - void showFinished() override; - -protected: - void prepare() override; - - 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/sessions_box.cpp b/Telegram/SourceFiles/boxes/sessions_box.cpp index dc0566344..e762a7b67 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.cpp +++ b/Telegram/SourceFiles/boxes/sessions_box.cpp @@ -1163,7 +1163,7 @@ Sessions::Sessions( setupContent(controller); } -rpl::producer Sessions::Title() { +rpl::producer Sessions::title() { return tr::lng_settings_sessions_title(); } diff --git a/Telegram/SourceFiles/boxes/sessions_box.h b/Telegram/SourceFiles/boxes/sessions_box.h index c096b0a55..d735189a5 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.h +++ b/Telegram/SourceFiles/boxes/sessions_box.h @@ -22,7 +22,7 @@ public: QWidget *parent, not_null controller); - [[nodiscard]] static rpl::producer Title(); + [[nodiscard]] rpl::producer title() override; private: void setupContent(not_null controller); diff --git a/Telegram/SourceFiles/info/info_content_widget.h b/Telegram/SourceFiles/info/info_content_widget.h index b1b5656bb..3cc5b34a5 100644 --- a/Telegram/SourceFiles/info/info_content_widget.h +++ b/Telegram/SourceFiles/info/info_content_widget.h @@ -54,6 +54,8 @@ public: bool hasTopBarShadow() const; virtual void setInnerFocus(); + virtual void showFinished() { + } // When resizing the widget with top edge moved up or down and we // want to add this top movement to the scroll position, so inner diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index c63fb8a39..f20ffd682 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -777,6 +777,7 @@ void WrapWidget::showFinishedHook() { // Restore shadow visibility after showChildren() call. _topShadow->toggle(_topShadow->toggled(), anim::type::instant); _topBarSurrogate.destroy(); + _content->showFinished(); } bool WrapWidget::showInternal( diff --git a/Telegram/SourceFiles/info/settings/info_settings_widget.cpp b/Telegram/SourceFiles/info/settings/info_settings_widget.cpp index fa825fc7c..7c5ff4620 100644 --- a/Telegram/SourceFiles/info/settings/info_settings_widget.cpp +++ b/Telegram/SourceFiles/info/settings/info_settings_widget.cpp @@ -83,6 +83,10 @@ void Widget::saveChanges(FnMut done) { _inner->sectionSaveChanges(std::move(done)); } +void Widget::showFinished() { + _inner->showFinished(); +} + rpl::producer Widget::desiredShadowVisibility() const { return (_type == ::Settings::Main::Id() || _type == ::Settings::Information::Id()) @@ -91,7 +95,7 @@ rpl::producer Widget::desiredShadowVisibility() const { } rpl::producer Widget::title() { - return _type()->title(); + return _inner->title(); } std::shared_ptr Widget::doCreateMemento() { diff --git a/Telegram/SourceFiles/info/settings/info_settings_widget.h b/Telegram/SourceFiles/info/settings/info_settings_widget.h index 2959b2be4..2e8ae3a77 100644 --- a/Telegram/SourceFiles/info/settings/info_settings_widget.h +++ b/Telegram/SourceFiles/info/settings/info_settings_widget.h @@ -65,6 +65,8 @@ public: void saveChanges(FnMut done) override; + void showFinished() override; + rpl::producer desiredShadowVisibility() const override; rpl::producer title() override; diff --git a/Telegram/SourceFiles/settings/settings_advanced.cpp b/Telegram/SourceFiles/settings/settings_advanced.cpp index d7ffcafe9..272778ccb 100644 --- a/Telegram/SourceFiles/settings/settings_advanced.cpp +++ b/Telegram/SourceFiles/settings/settings_advanced.cpp @@ -741,7 +741,7 @@ Advanced::Advanced( setupContent(controller); } -rpl::producer Advanced::Title() { +rpl::producer Advanced::title() { return tr::lng_settings_advanced(); } diff --git a/Telegram/SourceFiles/settings/settings_advanced.h b/Telegram/SourceFiles/settings/settings_advanced.h index 4b1d64ed9..ff7685f96 100644 --- a/Telegram/SourceFiles/settings/settings_advanced.h +++ b/Telegram/SourceFiles/settings/settings_advanced.h @@ -38,7 +38,7 @@ public: QWidget *parent, not_null controller); - [[nodiscard]] static rpl::producer Title(); + [[nodiscard]] rpl::producer title() override; rpl::producer sectionShowOther() override; diff --git a/Telegram/SourceFiles/settings/settings_calls.cpp b/Telegram/SourceFiles/settings/settings_calls.cpp index 65c72965f..cb3df10dd 100644 --- a/Telegram/SourceFiles/settings/settings_calls.cpp +++ b/Telegram/SourceFiles/settings/settings_calls.cpp @@ -56,7 +56,7 @@ Calls::Calls( Calls::~Calls() = default; -rpl::producer Calls::Title() { +rpl::producer Calls::title() { return tr::lng_settings_section_call_settings(); } diff --git a/Telegram/SourceFiles/settings/settings_calls.h b/Telegram/SourceFiles/settings/settings_calls.h index b469ff084..8fe0d1f5f 100644 --- a/Telegram/SourceFiles/settings/settings_calls.h +++ b/Telegram/SourceFiles/settings/settings_calls.h @@ -38,7 +38,7 @@ public: Calls(QWidget *parent, not_null controller); ~Calls(); - [[nodiscard]] static rpl::producer Title(); + [[nodiscard]] rpl::producer title() override; void sectionSaveChanges(FnMut done) override; diff --git a/Telegram/SourceFiles/settings/settings_chat.cpp b/Telegram/SourceFiles/settings/settings_chat.cpp index 65a2914c6..d9b0df664 100644 --- a/Telegram/SourceFiles/settings/settings_chat.cpp +++ b/Telegram/SourceFiles/settings/settings_chat.cpp @@ -1607,7 +1607,7 @@ Chat::Chat(QWidget *parent, not_null controller) setupContent(controller); } -rpl::producer Chat::Title() { +rpl::producer Chat::title() { return tr::lng_settings_section_chat_settings(); } diff --git a/Telegram/SourceFiles/settings/settings_chat.h b/Telegram/SourceFiles/settings/settings_chat.h index 777182184..7db9acb6a 100644 --- a/Telegram/SourceFiles/settings/settings_chat.h +++ b/Telegram/SourceFiles/settings/settings_chat.h @@ -35,7 +35,7 @@ class Chat : public Section { public: Chat(QWidget *parent, not_null controller); - [[nodiscard]] static rpl::producer Title(); + [[nodiscard]] rpl::producer title() override; private: void setupContent(not_null controller); diff --git a/Telegram/SourceFiles/settings/settings_common.cpp b/Telegram/SourceFiles/settings/settings_common.cpp index 701a2e8e4..92cf74939 100644 --- a/Telegram/SourceFiles/settings/settings_common.cpp +++ b/Telegram/SourceFiles/settings/settings_common.cpp @@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwindow.h" #include "main/main_session.h" #include "main/main_domain.h" +#include "lottie/lottie_icon.h" #include "base/options.h" #include "styles/style_layers.h" #include "styles/style_settings.h" @@ -245,6 +246,40 @@ not_null AddSubsectionTitle( st::settingsSubsectionTitlePadding + addPadding); } +LottieIcon CreateLottieIcon( + not_null parent, + Lottie::IconDescriptor &&descriptor, + style::margins padding) { + auto object = object_ptr(parent); + const auto raw = object.data(); + + const auto width = descriptor.sizeOverride.width(); + raw->resize(QRect( + QPoint(), + descriptor.sizeOverride).marginsAdded(padding).size()); + + auto owned = Lottie::MakeIcon(std::move(descriptor)); + const auto icon = owned.get(); + + raw->lifetime().add([kept = std::move(owned)]{}); + + const auto animate = [=] { + icon->animate([=] { raw->update(); }, 0, icon->framesCount()); + }; + raw->paintRequest( + ) | rpl::start_with_next([=] { + auto p = QPainter(raw); + const auto left = (raw->width() - width) / 2; + icon->paint(p, left, padding.top()); + if (!icon->animating() && icon->frameIndex() > 0) { + animate(); + } + + }, raw->lifetime()); + + return { .widget = std::move(object), .animate = std::move(animate) }; +} + void FillMenu( not_null controller, Type type, diff --git a/Telegram/SourceFiles/settings/settings_common.h b/Telegram/SourceFiles/settings/settings_common.h index b302580cb..96297f72f 100644 --- a/Telegram/SourceFiles/settings/settings_common.h +++ b/Telegram/SourceFiles/settings/settings_common.h @@ -33,6 +33,10 @@ struct FlatLabel; struct SettingsButton; } // namespace style +namespace Lottie { +struct IconDescriptor; +} // namespace Lottie + namespace Settings { extern const char kOptionMonoSettingsIcons[]; @@ -45,7 +49,6 @@ struct SectionMeta { [[nodiscard]] virtual object_ptr create( not_null parent, not_null controller) const = 0; - [[nodiscard]] virtual rpl::producer title() const = 0; }; template @@ -56,9 +59,6 @@ struct SectionMetaImplementation : SectionMeta { ) 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; @@ -74,9 +74,12 @@ public: [[nodiscard]] virtual rpl::producer sectionShowOther() { return nullptr; } + [[nodiscard]] virtual rpl::producer title() = 0; virtual void sectionSaveChanges(FnMut done) { done(); } + virtual void showFinished() { + } }; template @@ -171,6 +174,15 @@ not_null AddSubsectionTitle( style::margins addPadding = {}, const style::FlatLabel *st = nullptr); +struct LottieIcon { + object_ptr widget; + Fn animate; +}; +[[nodiscard]] LottieIcon CreateLottieIcon( + not_null parent, + Lottie::IconDescriptor &&descriptor, + style::margins padding = {}); + void FillMenu( not_null controller, Type type, diff --git a/Telegram/SourceFiles/settings/settings_experimental.cpp b/Telegram/SourceFiles/settings/settings_experimental.cpp index 3fbfcf13c..23aed8987 100644 --- a/Telegram/SourceFiles/settings/settings_experimental.cpp +++ b/Telegram/SourceFiles/settings/settings_experimental.cpp @@ -146,7 +146,7 @@ Experimental::Experimental( setupContent(controller); } -rpl::producer Experimental::Title() { +rpl::producer Experimental::title() { return tr::lng_settings_experimental(); } diff --git a/Telegram/SourceFiles/settings/settings_experimental.h b/Telegram/SourceFiles/settings/settings_experimental.h index 892b4c9d6..e465b6c5c 100644 --- a/Telegram/SourceFiles/settings/settings_experimental.h +++ b/Telegram/SourceFiles/settings/settings_experimental.h @@ -17,7 +17,7 @@ public: QWidget *parent, not_null controller); - [[nodiscard]] static rpl::producer Title(); + [[nodiscard]] rpl::producer title() override; private: void setupContent(not_null controller); diff --git a/Telegram/SourceFiles/settings/settings_folders.cpp b/Telegram/SourceFiles/settings/settings_folders.cpp index 7076591a0..96f1b91a8 100644 --- a/Telegram/SourceFiles/settings/settings_folders.cpp +++ b/Telegram/SourceFiles/settings/settings_folders.cpp @@ -580,7 +580,7 @@ Folders::~Folders() { } } -rpl::producer Folders::Title() { +rpl::producer Folders::title() { return tr::lng_filters_title(); } diff --git a/Telegram/SourceFiles/settings/settings_folders.h b/Telegram/SourceFiles/settings/settings_folders.h index b771292a8..ada023f59 100644 --- a/Telegram/SourceFiles/settings/settings_folders.h +++ b/Telegram/SourceFiles/settings/settings_folders.h @@ -18,7 +18,7 @@ public: not_null controller); ~Folders(); - [[nodiscard]] static rpl::producer Title(); + [[nodiscard]] rpl::producer title() override; private: void setupContent(not_null controller); diff --git a/Telegram/SourceFiles/settings/settings_information.cpp b/Telegram/SourceFiles/settings/settings_information.cpp index 0bfa54114..d246e5f1f 100644 --- a/Telegram/SourceFiles/settings/settings_information.cpp +++ b/Telegram/SourceFiles/settings/settings_information.cpp @@ -39,6 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_domain.h" #include "mtproto/mtproto_dc_options.h" #include "window/window_session_controller.h" +#include "window/window_controller.h" #include "window/window_peer_menu.h" #include "apiwrap.h" #include "api/api_peer_photo.h" @@ -285,12 +286,16 @@ void SetupRows( [=] { controller->show(Box(self)); }, { &st::settingsIconUser, kIconLightBlue }); + const auto showChangePhone = [=] { + controller->showSettings(ChangePhone::Id()); + controller->window().activate(); + }; AddRow( container, tr::lng_settings_phone_label(), Info::Profile::PhoneValue(self), tr::lng_profile_copy_phone(tr::now), - [=] { controller->show(Box(controller)); }, + showChangePhone, { &st::settingsIconCalls, kIconGreen }); auto username = Info::Profile::UsernameValue(self); @@ -798,7 +803,7 @@ Information::Information( setupContent(controller); } -rpl::producer Information::Title() { +rpl::producer Information::title() { return tr::lng_settings_section_info(); } diff --git a/Telegram/SourceFiles/settings/settings_information.h b/Telegram/SourceFiles/settings/settings_information.h index 05ea4e349..fea72a8de 100644 --- a/Telegram/SourceFiles/settings/settings_information.h +++ b/Telegram/SourceFiles/settings/settings_information.h @@ -21,7 +21,7 @@ public: QWidget *parent, not_null controller); - [[nodiscard]] static rpl::producer Title(); + [[nodiscard]] rpl::producer title() override; private: void setupContent(not_null controller); diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index 696305290..0c2644198 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -530,7 +530,7 @@ Main::Main( setupContent(controller); } -rpl::producer Main::Title() { +rpl::producer Main::title() { return tr::lng_menu_settings(); } diff --git a/Telegram/SourceFiles/settings/settings_main.h b/Telegram/SourceFiles/settings/settings_main.h index 860ea2781..9f00296ad 100644 --- a/Telegram/SourceFiles/settings/settings_main.h +++ b/Telegram/SourceFiles/settings/settings_main.h @@ -36,7 +36,7 @@ class Main : public Section
{ public: Main(QWidget *parent, not_null controller); - [[nodiscard]] static rpl::producer Title(); + [[nodiscard]] rpl::producer title() override; rpl::producer sectionShowOther() override; diff --git a/Telegram/SourceFiles/settings/settings_notifications.cpp b/Telegram/SourceFiles/settings/settings_notifications.cpp index 861393915..51d6923c1 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications.cpp @@ -1143,7 +1143,7 @@ Notifications::Notifications( setupContent(controller); } -rpl::producer Notifications::Title() { +rpl::producer Notifications::title() { return tr::lng_settings_section_notify(); } diff --git a/Telegram/SourceFiles/settings/settings_notifications.h b/Telegram/SourceFiles/settings/settings_notifications.h index c405ce96d..d895e20f2 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.h +++ b/Telegram/SourceFiles/settings/settings_notifications.h @@ -17,7 +17,7 @@ public: QWidget *parent, not_null controller); - [[nodiscard]] static rpl::producer Title(); + [[nodiscard]] rpl::producer title() override; 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 aa1b090e2..22af983bc 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_security.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_security.cpp @@ -965,7 +965,7 @@ PrivacySecurity::PrivacySecurity( setupContent(controller); } -rpl::producer PrivacySecurity::Title() { +rpl::producer PrivacySecurity::title() { return tr::lng_settings_section_privacy(); } diff --git a/Telegram/SourceFiles/settings/settings_privacy_security.h b/Telegram/SourceFiles/settings/settings_privacy_security.h index a47feca1d..67b2fcc64 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_security.h +++ b/Telegram/SourceFiles/settings/settings_privacy_security.h @@ -40,7 +40,7 @@ public: QWidget *parent, not_null controller); - [[nodiscard]] static rpl::producer Title(); + [[nodiscard]] rpl::producer title() override; rpl::producer sectionShowOther() override;