mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Added ability to pass custom layer widgets to stack.
This commit is contained in:
parent
e322733e20
commit
4909ba5a1e
@ -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<Ui::BoxContent> box,
|
||||
void MainWindow::showBoxOrLayer(
|
||||
std::variant<
|
||||
v::null_t,
|
||||
object_ptr<Ui::BoxContent>,
|
||||
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
||||
Ui::LayerOptions options,
|
||||
anim::type animated) {
|
||||
if (box) {
|
||||
using UniqueLayer = std::unique_ptr<Ui::LayerWidget>;
|
||||
using ObjectBox = object_ptr<Ui::BoxContent>;
|
||||
if (auto layerWidget = std::get_if<UniqueLayer>(&layer)) {
|
||||
ensureLayerCreated();
|
||||
_layer->showBox(std::move(box), options, animated);
|
||||
_layer->showLayer(std::move(*layerWidget), options, animated);
|
||||
} else if (auto box = std::get_if<ObjectBox>(&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<Ui::BoxContent> box,
|
||||
Ui::LayerOptions options,
|
||||
anim::type animated) {
|
||||
showBoxOrLayer(std::move(box), options, animated);
|
||||
}
|
||||
|
||||
void MainWindow::showLayer(
|
||||
std::unique_ptr<Ui::LayerWidget> &&layer,
|
||||
Ui::LayerOptions options,
|
||||
anim::type animated) {
|
||||
showBoxOrLayer(std::move(layer), options, animated);
|
||||
}
|
||||
|
||||
bool MainWindow::ui_isLayerShown() {
|
||||
return _layer != nullptr;
|
||||
}
|
||||
|
@ -86,6 +86,10 @@ public:
|
||||
void updateTrayMenu() override;
|
||||
void fixOrder() override;
|
||||
|
||||
void showLayer(
|
||||
std::unique_ptr<Ui::LayerWidget> &&layer,
|
||||
Ui::LayerOptions options,
|
||||
anim::type animated);
|
||||
void showSpecialLayer(
|
||||
object_ptr<Ui::LayerWidget> layer,
|
||||
anim::type animated);
|
||||
@ -128,6 +132,14 @@ private:
|
||||
void ensureLayerCreated();
|
||||
void destroyLayer();
|
||||
|
||||
void showBoxOrLayer(
|
||||
std::variant<
|
||||
v::null_t,
|
||||
object_ptr<Ui::BoxContent>,
|
||||
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
||||
Ui::LayerOptions options,
|
||||
anim::type animated);
|
||||
|
||||
void themeUpdated(const Window::Theme::BackgroundUpdate &data);
|
||||
|
||||
void toggleDisplayNotifyFromTray();
|
||||
|
@ -547,4 +547,4 @@ void LayerWidget::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Info
|
||||
} // namespace Settings
|
||||
|
@ -52,4 +52,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace Info
|
||||
} // namespace Settings
|
||||
|
@ -1202,6 +1202,13 @@ void SessionController::showSpecialLayer(
|
||||
widget()->showSpecialLayer(std::move(layer), animated);
|
||||
}
|
||||
|
||||
void SessionController::showLayer(
|
||||
std::unique_ptr<Ui::LayerWidget> &&layer,
|
||||
Ui::LayerOptions options,
|
||||
anim::type animated) {
|
||||
widget()->showLayer(std::move(layer), options, animated);
|
||||
}
|
||||
|
||||
void SessionController::removeLayerBlackout() {
|
||||
widget()->ui_removeLayerBlackout();
|
||||
}
|
||||
|
@ -330,6 +330,11 @@ public:
|
||||
void showPeerHistoryAtItem(not_null<const HistoryItem*> item);
|
||||
void cancelUploadLayer(not_null<HistoryItem*> item);
|
||||
|
||||
void showLayer(
|
||||
std::unique_ptr<Ui::LayerWidget> &&layer,
|
||||
Ui::LayerOptions options,
|
||||
anim::type animated = anim::type::normal);
|
||||
|
||||
void showSpecialLayer(
|
||||
object_ptr<Ui::LayerWidget> &&layer,
|
||||
anim::type animated = anim::type::normal);
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit baf4d80867e719a6fc0ae0cefd192ce061c3b879
|
||||
Subproject commit 3b4dfc26f9850b3ecc7c90ed8f7eb6e4e49c0981
|
Loading…
Reference in New Issue
Block a user