mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Fix jumping to premium promo from reactions panel.
This commit is contained in:
parent
610c46e26f
commit
73d8530c13
4 changed files with 31 additions and 3 deletions
|
@ -490,6 +490,10 @@ auto EmojiListWidget::premiumChosen() const
|
|||
return _premiumChosen.events();
|
||||
}
|
||||
|
||||
rpl::producer<> EmojiListWidget::jumpedToPremium() const {
|
||||
return _jumpedToPremium.events();
|
||||
}
|
||||
|
||||
void EmojiListWidget::paintExpanding(
|
||||
QPainter &p,
|
||||
QRect clip,
|
||||
|
@ -1134,6 +1138,7 @@ void EmojiListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
|||
} else if (hasAddButton(button->section)) {
|
||||
_localSetsManager->install(id);
|
||||
} else if (_controller) {
|
||||
_jumpedToPremium.fire({});
|
||||
Settings::ShowPremium(_controller, u"animated_emoji"_q);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,7 @@ public:
|
|||
-> rpl::producer<TabbedSelector::FileChosen>;
|
||||
[[nodiscard]] auto premiumChosen() const
|
||||
-> rpl::producer<not_null<DocumentData*>>;
|
||||
[[nodiscard]] rpl::producer<> jumpedToPremium() const;
|
||||
|
||||
void paintExpanding(
|
||||
QPainter &p,
|
||||
|
@ -356,6 +357,7 @@ private:
|
|||
rpl::event_stream<EmojiPtr> _chosen;
|
||||
rpl::event_stream<TabbedSelector::FileChosen> _customChosen;
|
||||
rpl::event_stream<not_null<DocumentData*>> _premiumChosen;
|
||||
rpl::event_stream<> _jumpedToPremium;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "chat_helpers/emoji_list_widget.h"
|
||||
#include "chat_helpers/stickers_list_footer.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "settings/settings_premium.h"
|
||||
#include "mainwidget.h"
|
||||
#include "base/call_delayed.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_chat.h"
|
||||
|
@ -142,10 +144,12 @@ Selector::Selector(
|
|||
not_null<QWidget*> parent,
|
||||
not_null<Window::SessionController*> parentController,
|
||||
Data::PossibleItemReactions &&reactions,
|
||||
IconFactory iconFactory)
|
||||
IconFactory iconFactory,
|
||||
Fn<void(bool fast)> close)
|
||||
: RpWidget(parent)
|
||||
, _parentController(parentController.get())
|
||||
, _reactions(std::move(reactions))
|
||||
, _jumpedToPremium([=] { close(false); })
|
||||
, _cachedRound(
|
||||
QSize(2 * st::reactStripSkip + st::reactStripSize, st::reactStripHeight),
|
||||
st::reactionCornerShadow,
|
||||
|
@ -160,6 +164,11 @@ Selector::Selector(
|
|||
, _skipy((st::reactStripHeight - st::reactStripSize) / 2)
|
||||
, _skipBottom(st::reactStripHeight - st::reactStripSize - _skipy) {
|
||||
setMouseTracking(true);
|
||||
|
||||
parentController->content()->alive(
|
||||
) | rpl::start_with_done([=] {
|
||||
close(true);
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
int Selector::countSkipLeft() const {
|
||||
|
@ -657,6 +666,15 @@ void Selector::createList(not_null<Window::SessionController*> controller) {
|
|||
}
|
||||
}, _list->lifetime());
|
||||
|
||||
_list->premiumChosen(
|
||||
) | rpl::start_with_next([=] {
|
||||
_jumpedToPremium();
|
||||
Settings::ShowPremium(controller, u"animated_emoji"_q);
|
||||
}, _list->lifetime());
|
||||
|
||||
_list->jumpedToPremium(
|
||||
) | rpl::start_with_next(_jumpedToPremium, _list->lifetime());
|
||||
|
||||
const auto inner = rect().marginsRemoved(extentsForShadow());
|
||||
const auto footer = _reactions.customAllowed
|
||||
? _list->createFooter().data()
|
||||
|
@ -790,7 +808,8 @@ AttachSelectorResult AttachSelectorToMenu(
|
|||
menu.get(),
|
||||
controller,
|
||||
std::move(reactions),
|
||||
std::move(iconFactory));
|
||||
std::move(iconFactory),
|
||||
[=](bool fast) { menu->hideMenu(fast); });
|
||||
if (!AdjustMenuGeometryForSelector(menu, desiredPosition, selector)) {
|
||||
return AttachSelectorResult::Failed;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,8 @@ public:
|
|||
not_null<QWidget*> parent,
|
||||
not_null<Window::SessionController*> parentController,
|
||||
Data::PossibleItemReactions &&reactions,
|
||||
IconFactory iconFactory);
|
||||
IconFactory iconFactory,
|
||||
Fn<void(bool fast)> close);
|
||||
|
||||
int countWidth(int desiredWidth, int maxWidth);
|
||||
[[nodiscard]] QMargins extentsForShadow() const;
|
||||
|
@ -99,6 +100,7 @@ private:
|
|||
|
||||
const base::weak_ptr<Window::SessionController> _parentController;
|
||||
const Data::PossibleItemReactions _reactions;
|
||||
Fn<void()> _jumpedToPremium;
|
||||
base::flat_map<DocumentId, int> _defaultReactionInStripMap;
|
||||
Ui::RoundAreaWithShadow _cachedRound;
|
||||
QPoint _defaultReactionShift;
|
||||
|
|
Loading…
Add table
Reference in a new issue