Added ability to append pinned to top content to settings sections.

This commit is contained in:
23rd 2022-05-01 15:33:32 +03:00
parent 2f5db08c9b
commit 639ed8b973
3 changed files with 20 additions and 1 deletions

View file

@ -47,11 +47,25 @@ Widget::Widget(
, _type(controller->section().settingsType()) , _type(controller->section().settingsType())
, _inner( , _inner(
setInnerWidget( setInnerWidget(
_type()->create(this, controller->parentController()))) { _type()->create(this, controller->parentController())))
, _pinnedToTop(_inner->createPinnedToTop(this)) {
_inner->sectionShowOther( _inner->sectionShowOther(
) | rpl::start_with_next([=](Type type) { ) | rpl::start_with_next([=](Type type) {
controller->showSettings(type); controller->showSettings(type);
}, _inner->lifetime()); }, _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; Widget::~Widget() = default;

View file

@ -81,6 +81,7 @@ private:
Type _type = Type(); Type _type = Type();
not_null<::Settings::AbstractSection*> _inner; not_null<::Settings::AbstractSection*> _inner;
QPointer<Ui::RpWidget> _pinnedToTop;
}; };

View file

@ -80,6 +80,10 @@ public:
} }
virtual void showFinished() { virtual void showFinished() {
} }
[[nodiscard]] virtual QPointer<Ui::RpWidget> createPinnedToTop(
not_null<QWidget*> parent) {
return nullptr;
}
}; };
template <typename SectionType> template <typename SectionType>