Added Ui::Show implementation for Ui::BoxContent.
This commit is contained in:
parent
f0b800cdfb
commit
d2e482dac3
2 changed files with 54 additions and 0 deletions
|
|
@ -271,4 +271,41 @@ void BoxContent::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
}
|
||||
|
||||
BoxShow::BoxShow(not_null<Ui::BoxContent*> box)
|
||||
: Show()
|
||||
, _weak(Ui::MakeWeak(box.get())) {
|
||||
}
|
||||
|
||||
BoxShow::~BoxShow() = default;
|
||||
|
||||
void BoxShow::showBox(
|
||||
object_ptr<BoxContent> content,
|
||||
LayerOptions options) const {
|
||||
if (_weak && _weak->isBoxShown()) {
|
||||
_weak->getDelegate()->show(std::move(content), options);
|
||||
}
|
||||
}
|
||||
|
||||
void BoxShow::hideLayer() const {
|
||||
if (_weak && _weak->isBoxShown()) {
|
||||
_weak->getDelegate()->hideLayer();
|
||||
}
|
||||
}
|
||||
|
||||
not_null<QWidget*> BoxShow::toastParent() const {
|
||||
if (!_toastParent) {
|
||||
Assert(_weak != nullptr);
|
||||
_toastParent = Ui::MakeWeak(_weak->window()); // =(
|
||||
}
|
||||
return _toastParent.data();
|
||||
}
|
||||
|
||||
bool BoxShow::valid() const {
|
||||
return _weak;
|
||||
}
|
||||
|
||||
BoxShow::operator bool() const {
|
||||
return valid();
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/layers/layer_widget.h"
|
||||
#include "ui/layers/show.h"
|
||||
#include "ui/effects/animation_value.h"
|
||||
#include "ui/text/text_entity.h"
|
||||
#include "ui/rp_widget.h"
|
||||
|
|
@ -363,4 +364,20 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class BoxShow : public Show {
|
||||
public:
|
||||
explicit BoxShow(not_null<Ui::BoxContent*> box);
|
||||
~BoxShow();
|
||||
void showBox(
|
||||
object_ptr<BoxContent> content,
|
||||
LayerOptions options = LayerOption::KeepOther) const override;
|
||||
void hideLayer() const override;
|
||||
[[nodiscard]] not_null<QWidget*> toastParent() const override;
|
||||
[[nodiscard]] bool valid() const override;
|
||||
operator bool() const override;
|
||||
private:
|
||||
mutable QPointer<QWidget> _toastParent;
|
||||
const QPointer<Ui::BoxContent> _weak;
|
||||
};
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue