Added ability to transfer variant data between nearest setting sections.

This commit is contained in:
23rd 2022-05-05 23:20:05 +03:00
parent 2eaa17b938
commit fbd9437775
5 changed files with 21 additions and 2 deletions

View file

@ -342,6 +342,14 @@ rpl::producer<SparseIdsMergedSlice> Controller::mediaSource(
limitAfter); limitAfter);
} }
std::any &Controller::stepDataReference() {
return _stepData;
}
void Controller::takeStepData(not_null<Controller*> another) {
_stepData = base::take(another->_stepData);
}
Controller::~Controller() = default; Controller::~Controller() = default;
} // namespace Info } // namespace Info

View file

@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <rpl/variable.h> #include <rpl/variable.h>
#include "data/data_search_controller.h" #include "data/data_search_controller.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "settings/settings_common.h"
namespace Ui { namespace Ui {
class SearchFieldController; class SearchFieldController;
@ -214,6 +213,9 @@ public:
void removeFromStack(const std::vector<Section> &sections) const; void removeFromStack(const std::vector<Section> &sections) const;
void takeStepData(not_null<Controller*> another);
std::any &stepDataReference();
rpl::lifetime &lifetime() { rpl::lifetime &lifetime() {
return _lifetime; return _lifetime;
} }
@ -238,6 +240,9 @@ private:
rpl::variable<bool> _seachEnabledByContent = false; rpl::variable<bool> _seachEnabledByContent = false;
bool _searchStartsFocused = false; bool _searchStartsFocused = false;
// Data between sections based on steps.
std::any _stepData;
rpl::lifetime _lifetime; rpl::lifetime _lifetime;
}; };

View file

@ -920,6 +920,9 @@ void WrapWidget::showNewContent(
auto newController = createController( auto newController = createController(
_controller->parentController(), _controller->parentController(),
memento); memento);
if (_controller && newController) {
newController->takeStepData(_controller.get());
}
auto newContent = object_ptr<ContentWidget>(nullptr); auto newContent = object_ptr<ContentWidget>(nullptr);
if (needAnimation) { if (needAnimation) {
newContent = createContent(memento, newController.get()); newContent = createContent(memento, newController.get());

View file

@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/settings/info_settings_widget.h" #include "info/settings/info_settings_widget.h"
#include "info/info_memento.h" #include "info/info_memento.h"
#include "info/info_controller.h"
#include "settings/settings_common.h" #include "settings/settings_common.h"
#include "settings/settings_main.h" #include "settings/settings_main.h"
#include "settings/settings_information.h" #include "settings/settings_information.h"
@ -60,6 +59,8 @@ Widget::Widget(
controller->showBackFromStack(); controller->showBackFromStack();
}, _inner->lifetime()); }, _inner->lifetime());
_inner->setStepDataReference(controller->stepDataReference());
_removesFromStack.events( _removesFromStack.events(
) | rpl::start_with_next([=](const std::vector<Type> &types) { ) | rpl::start_with_next([=](const std::vector<Type> &types) {
const auto sections = ranges::views::all( const auto sections = ranges::views::all(

View file

@ -100,6 +100,8 @@ public:
not_null<Ui::RpWidget*> parent) { not_null<Ui::RpWidget*> parent) {
return nullptr; return nullptr;
} }
virtual void setStepDataReference(std::any &data) {
}
}; };
template <typename SectionType> template <typename SectionType>