mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to hide sticker toast with right click.
This commit is contained in:
parent
31a683ab3d
commit
2055fbc164
1 changed files with 20 additions and 4 deletions
|
@ -150,6 +150,23 @@ void StickerToast::showWithTitle(const QString &title) {
|
||||||
}
|
}
|
||||||
strong->setInputUsed(true);
|
strong->setInputUsed(true);
|
||||||
const auto widget = strong->widget();
|
const auto widget = strong->widget();
|
||||||
|
const auto hideToast = [weak = _weak] {
|
||||||
|
if (const auto strong = weak.get()) {
|
||||||
|
strong->hideAnimated();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto clickableBackground = Ui::CreateChild<Ui::AbstractButton>(
|
||||||
|
widget.get());
|
||||||
|
clickableBackground->setPointerCursor(false);
|
||||||
|
clickableBackground->setAcceptBoth();
|
||||||
|
clickableBackground->show();
|
||||||
|
clickableBackground->addClickHandler([=](Qt::MouseButton button) {
|
||||||
|
if (button == Qt::RightButton) {
|
||||||
|
hideToast();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const auto button = Ui::CreateChild<Ui::RoundButton>(
|
const auto button = Ui::CreateChild<Ui::RoundButton>(
|
||||||
widget.get(),
|
widget.get(),
|
||||||
rpl::single(view),
|
rpl::single(view),
|
||||||
|
@ -164,6 +181,7 @@ void StickerToast::showWithTitle(const QString &title) {
|
||||||
0,
|
0,
|
||||||
(outer.height() - inner.height()) / 2,
|
(outer.height() - inner.height()) / 2,
|
||||||
outer.width());
|
outer.width());
|
||||||
|
clickableBackground->resize(outer);
|
||||||
}, widget->lifetime());
|
}, widget->lifetime());
|
||||||
const auto preview = Ui::CreateChild<Ui::RpWidget>(widget.get());
|
const auto preview = Ui::CreateChild<Ui::RpWidget>(widget.get());
|
||||||
preview->moveToLeft(skip, skip);
|
preview->moveToLeft(skip, skip);
|
||||||
|
@ -175,13 +193,11 @@ void StickerToast::showWithTitle(const QString &title) {
|
||||||
} else {
|
} else {
|
||||||
setupLottiePreview(preview, size);
|
setupLottiePreview(preview, size);
|
||||||
}
|
}
|
||||||
button->setClickedCallback([=, weak = _weak] {
|
button->setClickedCallback([=] {
|
||||||
_controller->show(
|
_controller->show(
|
||||||
Box<StickerSetBox>(_controller, _for->sticker()->set),
|
Box<StickerSetBox>(_controller, _for->sticker()->set),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
if (const auto strong = weak.get()) {
|
hideToast();
|
||||||
strong->hideAnimated();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue