mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow sending the sticker from the intro.
This commit is contained in:
parent
85554d19e4
commit
d1a995a863
3 changed files with 46 additions and 2 deletions
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/view/history_view_about_view.h"
|
#include "history/view/history_view_about_view.h"
|
||||||
|
|
||||||
#include "api/api_premium.h"
|
#include "api/api_premium.h"
|
||||||
|
#include "api/api_sending.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
#include "chat_helpers/stickers_lottie.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{
|
return StickerInBubblePart::Data{
|
||||||
.sticker = sticker,
|
.sticker = sticker,
|
||||||
.size = st::chatIntroStickerSize,
|
.size = st::chatIntroStickerSize,
|
||||||
.cacheTag = Tag::ChatIntroHelloSticker,
|
.cacheTag = Tag::ChatIntroHelloSticker,
|
||||||
|
.link = std::make_shared<LambdaClickHandler>(send),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
push(std::make_unique<StickerInBubblePart>(
|
push(std::make_unique<StickerInBubblePart>(
|
||||||
|
|
|
@ -124,7 +124,7 @@ void MediaInBubble::draw(Painter &p, const PaintContext &context) const {
|
||||||
const auto outer = width();
|
const auto outer = width();
|
||||||
if (outer < st::msgPadding.left() + st::msgPadding.right() + 1) {
|
if (outer < st::msgPadding.left() + st::msgPadding.right() + 1) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else if (_service) {
|
||||||
PainterHighQualityEnabler hq(p);
|
PainterHighQualityEnabler hq(p);
|
||||||
const auto radius = st::msgServiceGiftBoxRadius;
|
const auto radius = st::msgServiceGiftBoxRadius;
|
||||||
p.setPen(Qt::NoPen);
|
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() {
|
bool StickerInBubblePart::hasHeavyPart() {
|
||||||
return _sticker && _sticker->hasHeavyPart();
|
return _sticker && _sticker->hasHeavyPart();
|
||||||
}
|
}
|
||||||
|
@ -408,6 +427,7 @@ void StickerInBubblePart::ensureCreated(Element *replacing) const {
|
||||||
const auto sticker = data.sticker;
|
const auto sticker = data.sticker;
|
||||||
if (const auto info = sticker->sticker()) {
|
if (const auto info = sticker->sticker()) {
|
||||||
const auto skipPremiumEffect = true;
|
const auto skipPremiumEffect = true;
|
||||||
|
_link = data.link;
|
||||||
_skipTop = data.skipTop;
|
_skipTop = data.skipTop;
|
||||||
_sticker.emplace(_parent, sticker, skipPremiumEffect, replacing);
|
_sticker.emplace(_parent, sticker, skipPremiumEffect, replacing);
|
||||||
if (data.singleTimePlayback) {
|
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() {
|
bool StickerWithBadgePart::hasHeavyPart() {
|
||||||
return _sticker.hasHeavyPart();
|
return _sticker.hasHeavyPart();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
bool pressed) override;
|
bool pressed) override;
|
||||||
|
|
||||||
bool needsBubble() const override {
|
bool needsBubble() const override {
|
||||||
return !_service;;
|
return !_service;
|
||||||
}
|
}
|
||||||
bool customInfoLayout() const override {
|
bool customInfoLayout() const override {
|
||||||
return false;
|
return false;
|
||||||
|
@ -169,6 +169,7 @@ public:
|
||||||
int size = 0;
|
int size = 0;
|
||||||
ChatHelpers::StickerLottieSize cacheTag = {};
|
ChatHelpers::StickerLottieSize cacheTag = {};
|
||||||
bool singleTimePlayback = false;
|
bool singleTimePlayback = false;
|
||||||
|
ClickHandlerPtr link;
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return sticker != nullptr;
|
return sticker != nullptr;
|
||||||
|
@ -192,6 +193,10 @@ public:
|
||||||
not_null<const MediaInBubble*> owner,
|
not_null<const MediaInBubble*> owner,
|
||||||
const PaintContext &context,
|
const PaintContext &context,
|
||||||
int outerWidth) const override;
|
int outerWidth) const override;
|
||||||
|
TextState textState(
|
||||||
|
QPoint point,
|
||||||
|
StateRequest request,
|
||||||
|
int outerWidth) const override;
|
||||||
bool hasHeavyPart() override;
|
bool hasHeavyPart() override;
|
||||||
void unloadHeavyPart() override;
|
void unloadHeavyPart() override;
|
||||||
|
|
||||||
|
@ -210,6 +215,7 @@ private:
|
||||||
mutable int _skipTop = 0;
|
mutable int _skipTop = 0;
|
||||||
mutable QMargins _padding;
|
mutable QMargins _padding;
|
||||||
mutable std::optional<Sticker> _sticker;
|
mutable std::optional<Sticker> _sticker;
|
||||||
|
mutable ClickHandlerPtr _link;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -228,6 +234,10 @@ public:
|
||||||
not_null<const MediaInBubble*> owner,
|
not_null<const MediaInBubble*> owner,
|
||||||
const PaintContext &context,
|
const PaintContext &context,
|
||||||
int outerWidth) const override;
|
int outerWidth) const override;
|
||||||
|
TextState textState(
|
||||||
|
QPoint point,
|
||||||
|
StateRequest request,
|
||||||
|
int outerWidth) const override;
|
||||||
bool hasHeavyPart() override;
|
bool hasHeavyPart() override;
|
||||||
void unloadHeavyPart() override;
|
void unloadHeavyPart() override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue