diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 8105039c96..e56420650f 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -43,6 +43,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/platform/base_platform_info.h" #include "ui/platform/ui_platform_utility.h" #include "base/call_delayed.h" +#include "base/variant.h" #include "window/notifications_manager.h" #include "window/themes/window_theme.h" #include "window/themes/window_theme_warning.h" @@ -465,13 +466,21 @@ MainWidget *MainWindow::sessionContent() const { return _main.data(); } -void MainWindow::ui_showBox( - object_ptr box, +void MainWindow::showBoxOrLayer( + std::variant< + v::null_t, + object_ptr, + std::unique_ptr> &&layer, Ui::LayerOptions options, anim::type animated) { - if (box) { + using UniqueLayer = std::unique_ptr; + using ObjectBox = object_ptr; + if (auto layerWidget = std::get_if(&layer)) { ensureLayerCreated(); - _layer->showBox(std::move(box), options, animated); + _layer->showLayer(std::move(*layerWidget), options, animated); + } else if (auto box = std::get_if(&layer); *box != nullptr) { + ensureLayerCreated(); + _layer->showBox(std::move(*box), options, animated); } else { if (_layer) { _layer->hideTopLayer(animated); @@ -485,6 +494,20 @@ void MainWindow::ui_showBox( } } +void MainWindow::ui_showBox( + object_ptr box, + Ui::LayerOptions options, + anim::type animated) { + showBoxOrLayer(std::move(box), options, animated); +} + +void MainWindow::showLayer( + std::unique_ptr &&layer, + Ui::LayerOptions options, + anim::type animated) { + showBoxOrLayer(std::move(layer), options, animated); +} + bool MainWindow::ui_isLayerShown() { return _layer != nullptr; } diff --git a/Telegram/SourceFiles/mainwindow.h b/Telegram/SourceFiles/mainwindow.h index d5f90b5788..11112e16bb 100644 --- a/Telegram/SourceFiles/mainwindow.h +++ b/Telegram/SourceFiles/mainwindow.h @@ -86,6 +86,10 @@ public: void updateTrayMenu() override; void fixOrder() override; + void showLayer( + std::unique_ptr &&layer, + Ui::LayerOptions options, + anim::type animated); void showSpecialLayer( object_ptr layer, anim::type animated); @@ -128,6 +132,14 @@ private: void ensureLayerCreated(); void destroyLayer(); + void showBoxOrLayer( + std::variant< + v::null_t, + object_ptr, + std::unique_ptr> &&layer, + Ui::LayerOptions options, + anim::type animated); + void themeUpdated(const Window::Theme::BackgroundUpdate &data); void toggleDisplayNotifyFromTray(); diff --git a/Telegram/SourceFiles/settings/settings_intro.cpp b/Telegram/SourceFiles/settings/settings_intro.cpp index 0dba3c7770..b7dda3132b 100644 --- a/Telegram/SourceFiles/settings/settings_intro.cpp +++ b/Telegram/SourceFiles/settings/settings_intro.cpp @@ -547,4 +547,4 @@ void LayerWidget::paintEvent(QPaintEvent *e) { } } -} // namespace Info +} // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_intro.h b/Telegram/SourceFiles/settings/settings_intro.h index ec14f520dd..3d2db92a1f 100644 --- a/Telegram/SourceFiles/settings/settings_intro.h +++ b/Telegram/SourceFiles/settings/settings_intro.h @@ -52,4 +52,4 @@ private: }; -} // namespace Info +} // namespace Settings diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 8889e2a57c..8a24b2ce74 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -1202,6 +1202,13 @@ void SessionController::showSpecialLayer( widget()->showSpecialLayer(std::move(layer), animated); } +void SessionController::showLayer( + std::unique_ptr &&layer, + Ui::LayerOptions options, + anim::type animated) { + widget()->showLayer(std::move(layer), options, animated); +} + void SessionController::removeLayerBlackout() { widget()->ui_removeLayerBlackout(); } diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 9bb5ed0e77..a187c0c9ff 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -330,6 +330,11 @@ public: void showPeerHistoryAtItem(not_null item); void cancelUploadLayer(not_null item); + void showLayer( + std::unique_ptr &&layer, + Ui::LayerOptions options, + anim::type animated = anim::type::normal); + void showSpecialLayer( object_ptr &&layer, anim::type animated = anim::type::normal); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index baf4d80867..3b4dfc26f9 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit baf4d80867e719a6fc0ae0cefd192ce061c3b879 +Subproject commit 3b4dfc26f9850b3ecc7c90ed8f7eb6e4e49c0981