Added ability to remove previous sections from stack in info widget.
This commit is contained in:
parent
549d7c77e5
commit
972666440e
|
@ -290,6 +290,10 @@ void Controller::showBackFromStack(const Window::SectionShow ¶ms) {
|
|||
}
|
||||
}
|
||||
|
||||
void Controller::removeFromStack(const std::vector<Section> §ions) const {
|
||||
_widget->removeFromStack(sections);
|
||||
}
|
||||
|
||||
auto Controller::produceSearchQuery(
|
||||
const QString &query) const -> SearchQuery {
|
||||
Expects(_key.peer() != nullptr);
|
||||
|
|
|
@ -212,6 +212,8 @@ public:
|
|||
void showBackFromStack(
|
||||
const Window::SectionShow ¶ms = Window::SectionShow()) override;
|
||||
|
||||
void removeFromStack(const std::vector<Section> §ions) const;
|
||||
|
||||
rpl::lifetime &lifetime() {
|
||||
return _lifetime;
|
||||
}
|
||||
|
@ -240,4 +242,4 @@ private:
|
|||
|
||||
};
|
||||
|
||||
} // namespace Info
|
||||
} // namespace Info
|
||||
|
|
|
@ -596,6 +596,26 @@ bool WrapWidget::showBackFromStackInternal(
|
|||
return (wrap() == Wrap::Layer);
|
||||
}
|
||||
|
||||
void WrapWidget::removeFromStack(const std::vector<Section> §ions) {
|
||||
for (const auto §ion : sections) {
|
||||
const auto it = ranges::find_if(_historyStack, [&](
|
||||
const StackItem &item) {
|
||||
const auto &s = item.section->section();
|
||||
if (s.type() != section.type()) {
|
||||
return false;
|
||||
} else if (s.type() == Section::Type::Media) {
|
||||
return (s.mediaType() == section.mediaType());
|
||||
} else if (s.type() == Section::Type::Settings) {
|
||||
return (s.settingsType() == section.settingsType());
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (it != end(_historyStack)) {
|
||||
_historyStack.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
not_null<Ui::RpWidget*> WrapWidget::topWidget() const {
|
||||
// This was done for tabs support.
|
||||
//
|
||||
|
|
|
@ -106,6 +106,7 @@ public:
|
|||
not_null<Window::SectionMemento*> memento,
|
||||
const Window::SectionShow ¶ms) override;
|
||||
bool showBackFromStackInternal(const Window::SectionShow ¶ms);
|
||||
void removeFromStack(const std::vector<Section> §ions);
|
||||
std::shared_ptr<Window::SectionMemento> createMemento() override;
|
||||
|
||||
rpl::producer<int> desiredHeightValue() const override;
|
||||
|
|
|
@ -59,6 +59,16 @@ Widget::Widget(
|
|||
controller->showBackFromStack();
|
||||
}, _inner->lifetime());
|
||||
|
||||
_removesFromStack.events(
|
||||
) | rpl::start_with_next([=](const std::vector<Type> &types) {
|
||||
const auto sections = ranges::views::all(
|
||||
types
|
||||
) | ranges::views::transform([](Type type) {
|
||||
return Section(type);
|
||||
}) | ranges::to_vector;
|
||||
controller->removeFromStack(sections);
|
||||
}, _inner->lifetime());
|
||||
|
||||
if (_pinnedToTop) {
|
||||
_inner->widthValue(
|
||||
) | rpl::start_with_next([=](int w) {
|
||||
|
@ -104,6 +114,9 @@ void Widget::saveChanges(FnMut<void()> done) {
|
|||
|
||||
void Widget::showFinished() {
|
||||
_inner->showFinished();
|
||||
|
||||
_inner->removeFromStack(
|
||||
) | rpl::start_to_stream(_removesFromStack, lifetime());
|
||||
}
|
||||
|
||||
void Widget::setInnerFocus() {
|
||||
|
|
|
@ -84,6 +84,8 @@ private:
|
|||
not_null<::Settings::AbstractSection*> _inner;
|
||||
QPointer<Ui::RpWidget> _pinnedToTop;
|
||||
|
||||
rpl::event_stream<std::vector<Type>> _removesFromStack;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
|
|
|
@ -81,6 +81,9 @@ public:
|
|||
[[nodiscard]] virtual rpl::producer<> sectionShowBack() {
|
||||
return nullptr;
|
||||
}
|
||||
[[nodiscard]] virtual rpl::producer<std::vector<Type>> removeFromStack() {
|
||||
return nullptr;
|
||||
}
|
||||
[[nodiscard]] virtual rpl::producer<QString> title() = 0;
|
||||
virtual void sectionSaveChanges(FnMut<void()> done) {
|
||||
done();
|
||||
|
|
Loading…
Reference in New Issue