Show premium tooltip on custom topic icon selection.
This commit is contained in:
parent
c6bc7c3de1
commit
ec0380b250
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/view/history_view_replies_section.h"
|
#include "history/view/history_view_replies_section.h"
|
||||||
|
#include "history/view/history_view_sticker_toast.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "info/profile/info_profile_emoji_status_panel.h"
|
#include "info/profile/info_profile_emoji_status_panel.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
@ -210,6 +211,7 @@ struct IconSelector {
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
std::unique_ptr<Ui::EmojiFlyAnimation> animation;
|
std::unique_ptr<Ui::EmojiFlyAnimation> animation;
|
||||||
|
std::unique_ptr<HistoryView::StickerToast> toast;
|
||||||
rpl::variable<DocumentId> iconId;
|
rpl::variable<DocumentId> iconId;
|
||||||
QPointer<QWidget> button;
|
QPointer<QWidget> button;
|
||||||
};
|
};
|
||||||
|
@ -242,7 +244,7 @@ struct IconSelector {
|
||||||
const auto selector = body->add(
|
const auto selector = body->add(
|
||||||
object_ptr<EmojiListWidget>(body, EmojiListDescriptor{
|
object_ptr<EmojiListWidget>(body, EmojiListDescriptor{
|
||||||
.session = &controller->session(),
|
.session = &controller->session(),
|
||||||
.mode = EmojiListWidget::Mode::EmojiStatus,
|
.mode = EmojiListWidget::Mode::TopicIcon,
|
||||||
.controller = controller,
|
.controller = controller,
|
||||||
.paused = Window::PausedIn(
|
.paused = Window::PausedIn(
|
||||||
controller,
|
controller,
|
||||||
|
@ -289,6 +291,18 @@ struct IconSelector {
|
||||||
selector->setMinimalHeight(selector->width(), height);
|
selector->setMinimalHeight(selector->width(), height);
|
||||||
}, body->lifetime());
|
}, body->lifetime());
|
||||||
|
|
||||||
|
const auto showToast = [=](not_null<DocumentData*> document) {
|
||||||
|
if (!state->toast) {
|
||||||
|
state->toast = std::make_unique<HistoryView::StickerToast>(
|
||||||
|
controller,
|
||||||
|
controller->widget()->bodyWidget(),
|
||||||
|
[=] { state->toast = nullptr; });
|
||||||
|
}
|
||||||
|
state->toast->showFor(
|
||||||
|
document,
|
||||||
|
HistoryView::StickerToast::Section::TopicIcon);
|
||||||
|
};
|
||||||
|
|
||||||
selector->customChosen(
|
selector->customChosen(
|
||||||
) | rpl::start_with_next([=](ChatHelpers::FileChosen data) {
|
) | rpl::start_with_next([=](ChatHelpers::FileChosen data) {
|
||||||
const auto owner = &controller->session().data();
|
const auto owner = &controller->session().data();
|
||||||
|
@ -298,8 +312,7 @@ struct IconSelector {
|
||||||
const auto premium = custom
|
const auto premium = custom
|
||||||
&& !ranges::contains(document->owner().forumIcons().list(), id);
|
&& !ranges::contains(document->owner().forumIcons().list(), id);
|
||||||
if (premium && !controller->session().premium()) {
|
if (premium && !controller->session().premium()) {
|
||||||
// #TODO forum premium promo
|
showToast(document);
|
||||||
ShowPremiumPreviewBox(controller, PremiumPreview::EmojiStatus);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto body = controller->window().widget()->bodyWidget();
|
const auto body = controller->window().widget()->bodyWidget();
|
||||||
|
|
|
@ -1254,6 +1254,9 @@ void EmojiListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
case Mode::EmojiStatus:
|
case Mode::EmojiStatus:
|
||||||
Settings::ShowPremium(_controller, u"emoji_status"_q);
|
Settings::ShowPremium(_controller, u"emoji_status"_q);
|
||||||
break;
|
break;
|
||||||
|
case Mode::TopicIcon:
|
||||||
|
Settings::ShowPremium(_controller, u"forum_topic_icon"_q);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ class LocalStickersManager;
|
||||||
|
|
||||||
enum class EmojiListMode {
|
enum class EmojiListMode {
|
||||||
Full,
|
Full,
|
||||||
|
TopicIcon,
|
||||||
EmojiStatus,
|
EmojiStatus,
|
||||||
FullReactions,
|
FullReactions,
|
||||||
RecentReactions,
|
RecentReactions,
|
||||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/premium_preview_box.h"
|
#include "boxes/premium_preview_box.h"
|
||||||
#include "lottie/lottie_single_player.h"
|
#include "lottie/lottie_single_player.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
#include "settings/settings_premium.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
|
@ -50,7 +51,9 @@ StickerToast::~StickerToast() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickerToast::showFor(not_null<DocumentData*> document) {
|
void StickerToast::showFor(
|
||||||
|
not_null<DocumentData*> document,
|
||||||
|
Section section) {
|
||||||
const auto sticker = document->sticker();
|
const auto sticker = document->sticker();
|
||||||
if (!sticker || !document->session().premiumPossible()) {
|
if (!sticker || !document->session().premiumPossible()) {
|
||||||
return;
|
return;
|
||||||
|
@ -66,6 +69,7 @@ void StickerToast::showFor(not_null<DocumentData*> document) {
|
||||||
cancelRequest();
|
cancelRequest();
|
||||||
}
|
}
|
||||||
_for = document;
|
_for = document;
|
||||||
|
_section = section;
|
||||||
|
|
||||||
const auto title = lookupTitle();
|
const auto title = lookupTitle();
|
||||||
if (!title.isEmpty()) {
|
if (!title.isEmpty()) {
|
||||||
|
@ -129,8 +133,11 @@ void StickerToast::showWithTitle(const QString &title) {
|
||||||
|
|
||||||
static auto counter = 0;
|
static auto counter = 0;
|
||||||
const auto setType = _for->sticker()->setType;
|
const auto setType = _for->sticker()->setType;
|
||||||
const auto isEmoji = (setType == Data::StickersType::Emoji);
|
const auto isEmoji = (_section == Section::TopicIcon)
|
||||||
const auto toSaved = isEmoji && !(++counter % 2);
|
|| (setType == Data::StickersType::Emoji);
|
||||||
|
const auto toSaved = isEmoji
|
||||||
|
&& (_section == Section::Message)
|
||||||
|
&& !(++counter % 2);
|
||||||
const auto text = Ui::Text::Bold(
|
const auto text = Ui::Text::Bold(
|
||||||
title
|
title
|
||||||
).append('\n').append(
|
).append('\n').append(
|
||||||
|
@ -219,6 +226,9 @@ void StickerToast::showWithTitle(const QString &title) {
|
||||||
Window::SectionShow::Way::Forward);
|
Window::SectionShow::Way::Forward);
|
||||||
hideToast();
|
hideToast();
|
||||||
return;
|
return;
|
||||||
|
} else if (_section == Section::TopicIcon) {
|
||||||
|
Settings::ShowPremium(_controller, u"forum_topic_icon"_q);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const auto id = _for->sticker()->set.id;
|
const auto id = _for->sticker()->set.id;
|
||||||
const auto &sets = _for->owner().stickers().sets();
|
const auto &sets = _for->owner().stickers().sets();
|
||||||
|
|
|
@ -32,7 +32,13 @@ public:
|
||||||
Fn<void()> destroy);
|
Fn<void()> destroy);
|
||||||
~StickerToast();
|
~StickerToast();
|
||||||
|
|
||||||
void showFor(not_null<DocumentData*> document);
|
enum class Section {
|
||||||
|
Message,
|
||||||
|
TopicIcon,
|
||||||
|
};
|
||||||
|
void showFor(
|
||||||
|
not_null<DocumentData*> document,
|
||||||
|
Section section = Section::Message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void requestSet();
|
void requestSet();
|
||||||
|
@ -46,6 +52,7 @@ private:
|
||||||
|
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
const not_null<QWidget*> _parent;
|
const not_null<QWidget*> _parent;
|
||||||
|
Section _section = {};
|
||||||
style::Toast _st;
|
style::Toast _st;
|
||||||
base::weak_ptr<Ui::Toast::Instance> _weak;
|
base::weak_ptr<Ui::Toast::Instance> _weak;
|
||||||
std::vector<base::weak_ptr<Ui::Toast::Instance>> _hiding;
|
std::vector<base::weak_ptr<Ui::Toast::Instance>> _hiding;
|
||||||
|
|
Loading…
Reference in New Issue