diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index e323f3553..ce8bdb90a 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -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 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 peer) const { + Expects(_fromNameStatus != nullptr); + + if (_fromNameStatus->link) { + return; + } + _fromNameStatus->link = std::make_shared([=]( + ClickContext context) { + const auto controller = ExtractController(context); + if (controller) { + Settings::ShowEmojiStatusPremium(controller, peer); + } + }); +} + bool Message::getStateTopicButton( QPoint point, QRect &trect, diff --git a/Telegram/SourceFiles/history/view/history_view_message.h b/Telegram/SourceFiles/history/view/history_view_message.h index 2cda78939..735126d30 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.h +++ b/Telegram/SourceFiles/history/view/history_view_message.h @@ -300,6 +300,7 @@ private: void refreshRightBadge(); void validateFromNameText(PeerData *from) const; + void ensureFromNameStatusLink(not_null peer) const; mutable std::unique_ptr _rightAction; mutable ClickHandlerPtr _fastReplyLink; diff --git a/Telegram/SourceFiles/settings/settings_shortcuts.cpp b/Telegram/SourceFiles/settings/settings_shortcuts.cpp index f5c0aa161..a28d22af7 100644 --- a/Telegram/SourceFiles/settings/settings_shortcuts.cpp +++ b/Telegram/SourceFiles/settings/settings_shortcuts.cpp @@ -124,8 +124,8 @@ struct Labeled { } [[nodiscard]] Fn SetupShortcutsContent( - not_null controller, - not_null content) { + not_null controller, + not_null content) { const auto &defaults = S::KeysDefaults(); const auto ¤ts = S::KeysCurrents();