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())
, _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;

View File

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

View File

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