diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index d57e83359..33be82082 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -1802,4 +1802,44 @@ SessionController::~SessionController() { resetFakeUnreadWhileOpened(); } +Show::Show(not_null navigation) +: Show(&navigation->parentController()->window()) { +} + +Show::Show(not_null window) +: _window(base::make_weak(window.get())) { +} + +Show::~Show() = default; + +void Show::showBox( + object_ptr content, + Ui::LayerOptions options) const { + if (const auto window = _window.get()) { + window->show(std::move(content), options); + } +} + +void Show::hideLayer() const { + if (const auto window = _window.get()) { + window->show( + object_ptr{ nullptr }, + Ui::LayerOption::CloseOther); + } +} + +not_null Show::toastParent() const { + const auto window = _window.get(); + Assert(window != nullptr); + return window->widget()->bodyWidget(); +} + +bool Show::valid() const { + return !_window.empty(); +} + +Show::operator bool() const { + return valid(); +} + } // namespace Window diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 2d6e62581..be44cf407 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/timer.h" #include "dialogs/dialogs_key.h" #include "ui/layers/layer_widget.h" +#include "ui/layers/show.h" #include "window/window_adaptive.h" class PhotoData; @@ -568,4 +569,20 @@ private: void ActivateWindow(not_null controller); +class Show : public Ui::Show { +public: + explicit Show(not_null navigation); + explicit Show(not_null window); + ~Show(); + void showBox( + object_ptr content, + Ui::LayerOptions options = Ui::LayerOption::KeepOther) const override; + void hideLayer() const override; + [[nodiscard]] not_null toastParent() const override; + [[nodiscard]] bool valid() const override; + operator bool() const override; +private: + const base::weak_ptr _window; +}; + } // namespace Window diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 214c5e8e2..d2e482dac 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 214c5e8e226172e07f6e36984a65e0757a994a32 +Subproject commit d2e482dac3e5ddbc200228d14d04d7d624c98af7