diff --git a/Telegram/SourceFiles/history/view/history_view_about_view.cpp b/Telegram/SourceFiles/history/view/history_view_about_view.cpp index 461dfd49a1..e2f5083fcb 100644 --- a/Telegram/SourceFiles/history/view/history_view_about_view.cpp +++ b/Telegram/SourceFiles/history/view/history_view_about_view.cpp @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_about_view.h" #include "api/api_premium.h" +#include "api/api_sending.h" #include "apiwrap.h" #include "base/random.h" #include "chat_helpers/stickers_lottie.h" @@ -115,10 +116,16 @@ auto GenerateChatIntro( } } } + const auto send = [=] { + Api::SendExistingDocument(Api::MessageToSend( + Api::SendAction(parent->history()) + ), sticker); + }; return StickerInBubblePart::Data{ .sticker = sticker, .size = st::chatIntroStickerSize, .cacheTag = Tag::ChatIntroHelloSticker, + .link = std::make_shared(send), }; }; push(std::make_unique( diff --git a/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp b/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp index 38a04b6ee8..5942f3d69f 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp @@ -124,7 +124,7 @@ void MediaInBubble::draw(Painter &p, const PaintContext &context) const { const auto outer = width(); if (outer < st::msgPadding.left() + st::msgPadding.right() + 1) { return; - } else { + } else if (_service) { PainterHighQualityEnabler hq(p); const auto radius = st::msgServiceGiftBoxRadius; p.setPen(Qt::NoPen); @@ -367,6 +367,25 @@ void StickerInBubblePart::draw( } } +TextState StickerInBubblePart::textState( + QPoint point, + StateRequest request, + int outerWidth) const { + auto result = TextState(_parent); + if (_sticker) { + const auto stickerSize = _sticker->countOptimalSize(); + const auto sticker = QRect( + (outerWidth - stickerSize.width()) / 2, + _padding.top() + _skipTop, + stickerSize.width(), + stickerSize.height()); + if (sticker.contains(point)) { + result.link = _link; + } + } + return result; +} + bool StickerInBubblePart::hasHeavyPart() { return _sticker && _sticker->hasHeavyPart(); } @@ -408,6 +427,7 @@ void StickerInBubblePart::ensureCreated(Element *replacing) const { const auto sticker = data.sticker; if (const auto info = sticker->sticker()) { const auto skipPremiumEffect = true; + _link = data.link; _skipTop = data.skipTop; _sticker.emplace(_parent, sticker, skipPremiumEffect, replacing); if (data.singleTimePlayback) { @@ -440,6 +460,13 @@ void StickerWithBadgePart::draw( } } +TextState StickerWithBadgePart::textState( + QPoint point, + StateRequest request, + int outerWidth) const { + return _sticker.textState(point, request, outerWidth); +} + bool StickerWithBadgePart::hasHeavyPart() { return _sticker.hasHeavyPart(); } diff --git a/Telegram/SourceFiles/history/view/media/history_view_giveaway.h b/Telegram/SourceFiles/history/view/media/history_view_giveaway.h index 54db41cc8f..2efe86d59c 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_giveaway.h +++ b/Telegram/SourceFiles/history/view/media/history_view_giveaway.h @@ -75,7 +75,7 @@ public: bool pressed) override; bool needsBubble() const override { - return !_service;; + return !_service; } bool customInfoLayout() const override { return false; @@ -169,6 +169,7 @@ public: int size = 0; ChatHelpers::StickerLottieSize cacheTag = {}; bool singleTimePlayback = false; + ClickHandlerPtr link; explicit operator bool() const { return sticker != nullptr; @@ -192,6 +193,10 @@ public: not_null owner, const PaintContext &context, int outerWidth) const override; + TextState textState( + QPoint point, + StateRequest request, + int outerWidth) const override; bool hasHeavyPart() override; void unloadHeavyPart() override; @@ -210,6 +215,7 @@ private: mutable int _skipTop = 0; mutable QMargins _padding; mutable std::optional _sticker; + mutable ClickHandlerPtr _link; }; @@ -228,6 +234,10 @@ public: not_null owner, const PaintContext &context, int outerWidth) const override; + TextState textState( + QPoint point, + StateRequest request, + int outerWidth) const override; bool hasHeavyPart() override; void unloadHeavyPart() override;