mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improve premium preview from emoji panel.
This commit is contained in:
parent
19f89b1d87
commit
bb8f8131e4
3 changed files with 22 additions and 6 deletions
|
@ -65,6 +65,7 @@ struct Descriptor {
|
||||||
base::flat_map<QString, ReactionDisableType> disabled;
|
base::flat_map<QString, ReactionDisableType> disabled;
|
||||||
bool fromSettings = false;
|
bool fromSettings = false;
|
||||||
Fn<void()> hiddenCallback;
|
Fn<void()> hiddenCallback;
|
||||||
|
Fn<void(not_null<Ui::BoxContent*>)> shownCallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(const Descriptor &a, const Descriptor &b) {
|
bool operator==(const Descriptor &a, const Descriptor &b) {
|
||||||
|
@ -1516,7 +1517,11 @@ void Show(
|
||||||
const Descriptor &descriptor,
|
const Descriptor &descriptor,
|
||||||
const std::shared_ptr<Data::DocumentMedia> &media,
|
const std::shared_ptr<Data::DocumentMedia> &media,
|
||||||
QImage back) {
|
QImage back) {
|
||||||
controller->show(Box(PreviewBox, controller, descriptor, media, back));
|
const auto box = controller->show(
|
||||||
|
Box(PreviewBox, controller, descriptor, media, back));
|
||||||
|
if (descriptor.shownCallback) {
|
||||||
|
descriptor.shownCallback(box);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Show(not_null<Window::SessionController*> controller, QImage back) {
|
void Show(not_null<Window::SessionController*> controller, QImage back) {
|
||||||
|
@ -1539,7 +1544,10 @@ void Show(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
Descriptor &&descriptor) {
|
Descriptor &&descriptor) {
|
||||||
if (!controller->session().premiumPossible()) {
|
if (!controller->session().premiumPossible()) {
|
||||||
controller->show(Box(PremiumUnavailableBox));
|
const auto box = controller->show(Box(PremiumUnavailableBox));
|
||||||
|
if (descriptor.shownCallback) {
|
||||||
|
descriptor.shownCallback(box);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto &list = Preloads();
|
auto &list = Preloads();
|
||||||
|
@ -1616,10 +1624,12 @@ void ShowStickerPreviewBox(
|
||||||
void ShowPremiumPreviewBox(
|
void ShowPremiumPreviewBox(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
PremiumPreview section,
|
PremiumPreview section,
|
||||||
const base::flat_map<QString, ReactionDisableType> &disabled) {
|
const base::flat_map<QString, ReactionDisableType> &disabled,
|
||||||
|
Fn<void(not_null<Ui::BoxContent*>)> shown) {
|
||||||
Show(controller, Descriptor{
|
Show(controller, Descriptor{
|
||||||
.section = section,
|
.section = section,
|
||||||
.disabled = disabled,
|
.disabled = disabled,
|
||||||
|
.shownCallback = std::move(shown),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
class DocumentData;
|
class DocumentData;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
class BoxContent;
|
||||||
class GenericBox;
|
class GenericBox;
|
||||||
class GradientButton;
|
class GradientButton;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
@ -55,7 +56,8 @@ enum class ReactionDisableType {
|
||||||
void ShowPremiumPreviewBox(
|
void ShowPremiumPreviewBox(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
PremiumPreview section,
|
PremiumPreview section,
|
||||||
const base::flat_map<QString, ReactionDisableType> &disabled = {});
|
const base::flat_map<QString, ReactionDisableType> &disabled = {},
|
||||||
|
Fn<void(not_null<Ui::BoxContent*>)> shown = nullptr);
|
||||||
|
|
||||||
void ShowPremiumPreviewToBuy(
|
void ShowPremiumPreviewToBuy(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
|
|
|
@ -1093,7 +1093,11 @@ void EmojiListWidget::selectCustom(not_null<DocumentData*> document) {
|
||||||
if (document->isPremiumEmoji() && !document->session().premium()) {
|
if (document->isPremiumEmoji() && !document->session().premium()) {
|
||||||
ShowPremiumPreviewBox(
|
ShowPremiumPreviewBox(
|
||||||
controller(),
|
controller(),
|
||||||
PremiumPreview::AnimatedEmoji);
|
PremiumPreview::AnimatedEmoji,
|
||||||
|
{},
|
||||||
|
crl::guard(this, [=](not_null<Ui::BoxContent*> box) {
|
||||||
|
checkHideWithBox(box.get());
|
||||||
|
}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Core::App().settings().incrementRecentEmoji({ RecentEmojiDocument{
|
Core::App().settings().incrementRecentEmoji({ RecentEmojiDocument{
|
||||||
|
@ -1755,7 +1759,7 @@ void EmojiListWidget::initButton(
|
||||||
button.back = prepare(Qt::transparent, [&]() -> QBrush {
|
button.back = prepare(Qt::transparent, [&]() -> QBrush {
|
||||||
if (gradient) {
|
if (gradient) {
|
||||||
auto result = QLinearGradient(QPointF(0, 0), QPointF(width, 0));
|
auto result = QLinearGradient(QPointF(0, 0), QPointF(width, 0));
|
||||||
result.setStops(Ui::Premium::ButtonGradientStops());
|
result.setStops(Ui::Premium::GiftGradientStops());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return st::emojiPanButton.textBg;
|
return st::emojiPanButton.textBg;
|
||||||
|
|
Loading…
Add table
Reference in a new issue