mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Added ability to remove previous sections from stack in info widget.
This commit is contained in:
parent
549d7c77e5
commit
972666440e
7 changed files with 46 additions and 1 deletions
|
@ -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(
|
auto Controller::produceSearchQuery(
|
||||||
const QString &query) const -> SearchQuery {
|
const QString &query) const -> SearchQuery {
|
||||||
Expects(_key.peer() != nullptr);
|
Expects(_key.peer() != nullptr);
|
||||||
|
|
|
@ -212,6 +212,8 @@ public:
|
||||||
void showBackFromStack(
|
void showBackFromStack(
|
||||||
const Window::SectionShow ¶ms = Window::SectionShow()) override;
|
const Window::SectionShow ¶ms = Window::SectionShow()) override;
|
||||||
|
|
||||||
|
void removeFromStack(const std::vector<Section> §ions) const;
|
||||||
|
|
||||||
rpl::lifetime &lifetime() {
|
rpl::lifetime &lifetime() {
|
||||||
return _lifetime;
|
return _lifetime;
|
||||||
}
|
}
|
||||||
|
@ -240,4 +242,4 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Info
|
} // namespace Info
|
||||||
|
|
|
@ -596,6 +596,26 @@ bool WrapWidget::showBackFromStackInternal(
|
||||||
return (wrap() == Wrap::Layer);
|
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 {
|
not_null<Ui::RpWidget*> WrapWidget::topWidget() const {
|
||||||
// This was done for tabs support.
|
// This was done for tabs support.
|
||||||
//
|
//
|
||||||
|
|
|
@ -106,6 +106,7 @@ public:
|
||||||
not_null<Window::SectionMemento*> memento,
|
not_null<Window::SectionMemento*> memento,
|
||||||
const Window::SectionShow ¶ms) override;
|
const Window::SectionShow ¶ms) override;
|
||||||
bool showBackFromStackInternal(const Window::SectionShow ¶ms);
|
bool showBackFromStackInternal(const Window::SectionShow ¶ms);
|
||||||
|
void removeFromStack(const std::vector<Section> §ions);
|
||||||
std::shared_ptr<Window::SectionMemento> createMemento() override;
|
std::shared_ptr<Window::SectionMemento> createMemento() override;
|
||||||
|
|
||||||
rpl::producer<int> desiredHeightValue() const override;
|
rpl::producer<int> desiredHeightValue() const override;
|
||||||
|
|
|
@ -59,6 +59,16 @@ Widget::Widget(
|
||||||
controller->showBackFromStack();
|
controller->showBackFromStack();
|
||||||
}, _inner->lifetime());
|
}, _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) {
|
if (_pinnedToTop) {
|
||||||
_inner->widthValue(
|
_inner->widthValue(
|
||||||
) | rpl::start_with_next([=](int w) {
|
) | rpl::start_with_next([=](int w) {
|
||||||
|
@ -104,6 +114,9 @@ void Widget::saveChanges(FnMut<void()> done) {
|
||||||
|
|
||||||
void Widget::showFinished() {
|
void Widget::showFinished() {
|
||||||
_inner->showFinished();
|
_inner->showFinished();
|
||||||
|
|
||||||
|
_inner->removeFromStack(
|
||||||
|
) | rpl::start_to_stream(_removesFromStack, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setInnerFocus() {
|
void Widget::setInnerFocus() {
|
||||||
|
|
|
@ -84,6 +84,8 @@ private:
|
||||||
not_null<::Settings::AbstractSection*> _inner;
|
not_null<::Settings::AbstractSection*> _inner;
|
||||||
QPointer<Ui::RpWidget> _pinnedToTop;
|
QPointer<Ui::RpWidget> _pinnedToTop;
|
||||||
|
|
||||||
|
rpl::event_stream<std::vector<Type>> _removesFromStack;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
|
|
|
@ -81,6 +81,9 @@ public:
|
||||||
[[nodiscard]] virtual rpl::producer<> sectionShowBack() {
|
[[nodiscard]] virtual rpl::producer<> sectionShowBack() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] virtual rpl::producer<std::vector<Type>> removeFromStack() {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
[[nodiscard]] virtual rpl::producer<QString> title() = 0;
|
[[nodiscard]] virtual rpl::producer<QString> title() = 0;
|
||||||
virtual void sectionSaveChanges(FnMut<void()> done) {
|
virtual void sectionSaveChanges(FnMut<void()> done) {
|
||||||
done();
|
done();
|
||||||
|
|
Loading…
Add table
Reference in a new issue