From 639ed8b973a891524322e675b6e169b9d841dcec Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 1 May 2022 15:33:32 +0300 Subject: [PATCH] Added ability to append pinned to top content to settings sections. --- .../info/settings/info_settings_widget.cpp | 16 +++++++++++++++- .../info/settings/info_settings_widget.h | 1 + Telegram/SourceFiles/settings/settings_common.h | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/info/settings/info_settings_widget.cpp b/Telegram/SourceFiles/info/settings/info_settings_widget.cpp index 7c5ff4620b..02d6d6c8d6 100644 --- a/Telegram/SourceFiles/info/settings/info_settings_widget.cpp +++ b/Telegram/SourceFiles/info/settings/info_settings_widget.cpp @@ -47,11 +47,25 @@ Widget::Widget( , _type(controller->section().settingsType()) , _inner( setInnerWidget( - _type()->create(this, controller->parentController()))) { + _type()->create(this, controller->parentController()))) +, _pinnedToTop(_inner->createPinnedToTop(this)) { _inner->sectionShowOther( ) | rpl::start_with_next([=](Type type) { controller->showSettings(type); }, _inner->lifetime()); + + if (_pinnedToTop) { + _inner->widthValue( + ) | rpl::start_with_next([=](int w) { + _pinnedToTop->resizeToWidth(w); + setScrollTopSkip(_pinnedToTop->height()); + }, _pinnedToTop->lifetime()); + + _pinnedToTop->heightValue( + ) | rpl::start_with_next([=](int h) { + setScrollTopSkip(h); + }, _pinnedToTop->lifetime()); + } } Widget::~Widget() = default; diff --git a/Telegram/SourceFiles/info/settings/info_settings_widget.h b/Telegram/SourceFiles/info/settings/info_settings_widget.h index 2e8ae3a772..6dddc62b60 100644 --- a/Telegram/SourceFiles/info/settings/info_settings_widget.h +++ b/Telegram/SourceFiles/info/settings/info_settings_widget.h @@ -81,6 +81,7 @@ private: Type _type = Type(); not_null<::Settings::AbstractSection*> _inner; + QPointer _pinnedToTop; }; diff --git a/Telegram/SourceFiles/settings/settings_common.h b/Telegram/SourceFiles/settings/settings_common.h index 96297f72fc..5118350375 100644 --- a/Telegram/SourceFiles/settings/settings_common.h +++ b/Telegram/SourceFiles/settings/settings_common.h @@ -80,6 +80,10 @@ public: } virtual void showFinished() { } + [[nodiscard]] virtual QPointer createPinnedToTop( + not_null parent) { + return nullptr; + } }; template