Allow tracking isLayerShown in LayerManager.

This commit is contained in:
John Preston 2023-05-30 17:36:11 +04:00
parent bf4cb33fab
commit ff1d5fce29
2 changed files with 9 additions and 0 deletions

View file

@ -168,6 +168,8 @@ void LayerManager::ensureLayerCreated() {
) | rpl::start_with_next([=](QSize size) {
_layer->resize(size);
}, _layer->lifetime());
_layerShown = true;
}
void LayerManager::destroyLayer() {
@ -176,6 +178,8 @@ void LayerManager::destroyLayer() {
}
auto layer = base::take(_layer);
_layerShown = false;
const auto resetFocus = Ui::InFocusChain(layer);
if (resetFocus) {
_widget->setFocus();

View file

@ -42,6 +42,10 @@ public:
void raise();
bool setFocus();
[[nodiscard]] rpl::producer<bool> layerShownValue() const {
return _layerShown.value();
}
[[nodiscard]] not_null<Ui::RpWidget*> toastParent() const {
return _widget;
}
@ -58,6 +62,7 @@ private:
const not_null<RpWidget*> _widget;
base::unique_qptr<LayerStackWidget> _layer;
std::shared_ptr<ManagerShow> _cachedShow;
rpl::variable<bool> _layerShown;
const style::Box *_boxSt = nullptr;
const style::Box *_layerSt = nullptr;