mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-13 04:37:11 +02:00
Make emoji status in chat bubbles clickable.
This commit is contained in:
parent
f9abef9e05
commit
15dc7c74d7
3 changed files with 39 additions and 2 deletions
|
@ -38,6 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "lang/lang_keys.h"
|
||||
#include "mainwidget.h"
|
||||
#include "main/main_session.h"
|
||||
#include "settings/settings_premium.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/painter.h"
|
||||
#include "window/themes/window_theme.h" // IsNightMode.
|
||||
|
@ -373,6 +374,7 @@ struct Message::CommentsButton {
|
|||
struct Message::FromNameStatus {
|
||||
EmojiStatusId id;
|
||||
std::unique_ptr<Ui::Text::CustomEmoji> custom;
|
||||
ClickHandlerPtr link;
|
||||
int skip = 0;
|
||||
};
|
||||
|
||||
|
@ -2770,6 +2772,25 @@ bool Message::getStateFromName(
|
|||
Unexpected("Corrupt forwarded information in message.");
|
||||
}
|
||||
}();
|
||||
|
||||
const auto statusWidth = (from && _fromNameStatus)
|
||||
? st::dialogsPremiumIcon.icon.width()
|
||||
: 0;
|
||||
if (statusWidth && availableWidth > statusWidth) {
|
||||
const auto x = availableLeft + std::min(
|
||||
availableWidth - statusWidth,
|
||||
nameText->maxWidth()
|
||||
) - (_fromNameStatus->custom ? (2 * _fromNameStatus->skip) : 0);
|
||||
const auto checkWidth = _fromNameStatus->custom
|
||||
? (st::emojiSize - 2 * _fromNameStatus->skip)
|
||||
: statusWidth;
|
||||
if (point.x() >= x && point.x() < x + checkWidth) {
|
||||
ensureFromNameStatusLink(from);
|
||||
outResult->link = _fromNameStatus->link;
|
||||
return true;
|
||||
}
|
||||
availableWidth -= statusWidth;
|
||||
}
|
||||
if (point.x() >= availableLeft
|
||||
&& point.x() < availableLeft + availableWidth
|
||||
&& point.x() < availableLeft + nameText->maxWidth()) {
|
||||
|
@ -2790,6 +2811,21 @@ bool Message::getStateFromName(
|
|||
return false;
|
||||
}
|
||||
|
||||
void Message::ensureFromNameStatusLink(not_null<PeerData*> peer) const {
|
||||
Expects(_fromNameStatus != nullptr);
|
||||
|
||||
if (_fromNameStatus->link) {
|
||||
return;
|
||||
}
|
||||
_fromNameStatus->link = std::make_shared<LambdaClickHandler>([=](
|
||||
ClickContext context) {
|
||||
const auto controller = ExtractController(context);
|
||||
if (controller) {
|
||||
Settings::ShowEmojiStatusPremium(controller, peer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool Message::getStateTopicButton(
|
||||
QPoint point,
|
||||
QRect &trect,
|
||||
|
|
|
@ -300,6 +300,7 @@ private:
|
|||
|
||||
void refreshRightBadge();
|
||||
void validateFromNameText(PeerData *from) const;
|
||||
void ensureFromNameStatusLink(not_null<PeerData*> peer) const;
|
||||
|
||||
mutable std::unique_ptr<RightAction> _rightAction;
|
||||
mutable ClickHandlerPtr _fastReplyLink;
|
||||
|
|
|
@ -124,8 +124,8 @@ struct Labeled {
|
|||
}
|
||||
|
||||
[[nodiscard]] Fn<void()> SetupShortcutsContent(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> content) {
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> content) {
|
||||
const auto &defaults = S::KeysDefaults();
|
||||
const auto ¤ts = S::KeysCurrents();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue