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