mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add unique gifts link preview.
This commit is contained in:
parent
017535cf7b
commit
428e90a844
18 changed files with 189 additions and 48 deletions
|
@ -5520,6 +5520,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_view_button_iv" = "Instant View";
|
"lng_view_button_iv" = "Instant View";
|
||||||
"lng_view_button_stickerset" = "View stickers";
|
"lng_view_button_stickerset" = "View stickers";
|
||||||
"lng_view_button_emojipack" = "View emoji";
|
"lng_view_button_emojipack" = "View emoji";
|
||||||
|
"lng_view_button_collectible" = "View collectible";
|
||||||
|
|
||||||
"lng_sponsored_hide_ads" = "Hide";
|
"lng_sponsored_hide_ads" = "Hide";
|
||||||
"lng_sponsored_title" = "What are sponsored messages?";
|
"lng_sponsored_title" = "What are sponsored messages?";
|
||||||
|
|
|
@ -313,6 +313,7 @@ PreviewWrap::PreviewWrap(
|
||||||
WebPageCollage(),
|
WebPageCollage(),
|
||||||
nullptr, // iv
|
nullptr, // iv
|
||||||
nullptr, // stickerSet
|
nullptr, // stickerSet
|
||||||
|
nullptr, // uniqueGift
|
||||||
0, // duration
|
0, // duration
|
||||||
QString(), // author
|
QString(), // author
|
||||||
false, // hasLargeMedia
|
false, // hasLargeMedia
|
||||||
|
|
|
@ -208,8 +208,12 @@ auto GenerateGiftMedia(
|
||||||
Element *replacing,
|
Element *replacing,
|
||||||
not_null<PeerData*> recipient,
|
not_null<PeerData*> recipient,
|
||||||
const GiftDetails &data)
|
const GiftDetails &data)
|
||||||
-> Fn<void(Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
|
-> Fn<void(
|
||||||
return [=](Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
|
not_null<MediaGeneric*>,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
|
||||||
|
return [=](
|
||||||
|
not_null<MediaGeneric*> media,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
|
||||||
const auto &descriptor = data.descriptor;
|
const auto &descriptor = data.descriptor;
|
||||||
auto pushText = [&](
|
auto pushText = [&](
|
||||||
TextWithEntities text,
|
TextWithEntities text,
|
||||||
|
|
|
@ -2375,13 +2375,13 @@ std::unique_ptr<HistoryView::Media> MediaGiftBox::createView(
|
||||||
not_null<HistoryView::Element*> message,
|
not_null<HistoryView::Element*> message,
|
||||||
not_null<HistoryItem*> realParent,
|
not_null<HistoryItem*> realParent,
|
||||||
HistoryView::Element *replacing) {
|
HistoryView::Element *replacing) {
|
||||||
if (const auto raw = _data.unique.get()) {
|
if (const auto &unique = _data.unique) {
|
||||||
return std::make_unique<HistoryView::MediaGeneric>(
|
return std::make_unique<HistoryView::MediaGeneric>(
|
||||||
message,
|
message,
|
||||||
HistoryView::GenerateUniqueGiftMedia(message, replacing, raw),
|
HistoryView::GenerateUniqueGiftMedia(message, replacing, unique),
|
||||||
HistoryView::MediaGenericDescriptor{
|
HistoryView::MediaGenericDescriptor{
|
||||||
.maxWidth = st::msgServiceGiftBoxSize.width(),
|
.maxWidth = st::msgServiceGiftBoxSize.width(),
|
||||||
.paintBg = HistoryView::UniqueGiftBg(message, raw),
|
.paintBg = HistoryView::UniqueGiftBg(message, unique),
|
||||||
.service = true,
|
.service = true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "api/api_bot.h"
|
#include "api/api_bot.h"
|
||||||
|
#include "api/api_premium.h"
|
||||||
#include "api/api_text_entities.h"
|
#include "api/api_text_entities.h"
|
||||||
#include "api/api_user_names.h"
|
#include "api/api_user_names.h"
|
||||||
#include "chat_helpers/stickers_lottie.h"
|
#include "chat_helpers/stickers_lottie.h"
|
||||||
|
@ -3464,6 +3465,7 @@ not_null<WebPageData*> Session::processWebpage(
|
||||||
WebPageCollage(),
|
WebPageCollage(),
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
nullptr,
|
||||||
0,
|
0,
|
||||||
QString(),
|
QString(),
|
||||||
false,
|
false,
|
||||||
|
@ -3490,6 +3492,7 @@ not_null<WebPageData*> Session::webpage(
|
||||||
WebPageCollage(),
|
WebPageCollage(),
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
nullptr,
|
||||||
0,
|
0,
|
||||||
QString(),
|
QString(),
|
||||||
false,
|
false,
|
||||||
|
@ -3509,6 +3512,7 @@ not_null<WebPageData*> Session::webpage(
|
||||||
WebPageCollage &&collage,
|
WebPageCollage &&collage,
|
||||||
std::unique_ptr<Iv::Data> iv,
|
std::unique_ptr<Iv::Data> iv,
|
||||||
std::unique_ptr<WebPageStickerSet> stickerSet,
|
std::unique_ptr<WebPageStickerSet> stickerSet,
|
||||||
|
std::shared_ptr<UniqueGift> uniqueGift,
|
||||||
int duration,
|
int duration,
|
||||||
const QString &author,
|
const QString &author,
|
||||||
bool hasLargeMedia,
|
bool hasLargeMedia,
|
||||||
|
@ -3528,6 +3532,7 @@ not_null<WebPageData*> Session::webpage(
|
||||||
std::move(collage),
|
std::move(collage),
|
||||||
std::move(iv),
|
std::move(iv),
|
||||||
std::move(stickerSet),
|
std::move(stickerSet),
|
||||||
|
std::move(uniqueGift),
|
||||||
duration,
|
duration,
|
||||||
author,
|
author,
|
||||||
hasLargeMedia,
|
hasLargeMedia,
|
||||||
|
@ -3562,6 +3567,7 @@ void Session::webpageApplyFields(
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto lookupThemeDocument = [&]() -> DocumentData* {
|
const auto lookupThemeDocument = [&]() -> DocumentData* {
|
||||||
if (const auto attributes = data.vattributes()) {
|
if (const auto attributes = data.vattributes()) {
|
||||||
for (const auto &attribute : attributes->v) {
|
for (const auto &attribute : attributes->v) {
|
||||||
|
@ -3582,6 +3588,7 @@ void Session::webpageApplyFields(
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
using WebPageStickerSetPtr = std::unique_ptr<WebPageStickerSet>;
|
using WebPageStickerSetPtr = std::unique_ptr<WebPageStickerSet>;
|
||||||
const auto lookupStickerSet = [&]() -> WebPageStickerSetPtr {
|
const auto lookupStickerSet = [&]() -> WebPageStickerSetPtr {
|
||||||
if (const auto attributes = data.vattributes()) {
|
if (const auto attributes = data.vattributes()) {
|
||||||
|
@ -3605,6 +3612,21 @@ void Session::webpageApplyFields(
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using UniqueGiftPtr = std::shared_ptr<UniqueGift>;
|
||||||
|
const auto lookupUniqueGift = [&]() -> UniqueGiftPtr {
|
||||||
|
if (const auto attributes = data.vattributes()) {
|
||||||
|
for (const auto &attribute : attributes->v) {
|
||||||
|
return attribute.match([&](
|
||||||
|
const MTPDwebPageAttributeUniqueStarGift &data) {
|
||||||
|
const auto gift = Api::FromTL(_session, data.vgift());
|
||||||
|
return gift ? gift->unique : nullptr;
|
||||||
|
}, [](const auto &) -> UniqueGiftPtr { return nullptr; });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
auto story = (Data::Story*)nullptr;
|
auto story = (Data::Story*)nullptr;
|
||||||
auto storyId = FullStoryId();
|
auto storyId = FullStoryId();
|
||||||
if (const auto attributes = data.vattributes()) {
|
if (const auto attributes = data.vattributes()) {
|
||||||
|
@ -3697,6 +3719,7 @@ void Session::webpageApplyFields(
|
||||||
WebPageCollage(this, data),
|
WebPageCollage(this, data),
|
||||||
std::move(iv),
|
std::move(iv),
|
||||||
lookupStickerSet(),
|
lookupStickerSet(),
|
||||||
|
lookupUniqueGift(),
|
||||||
data.vduration().value_or_empty(),
|
data.vduration().value_or_empty(),
|
||||||
qs(data.vauthor().value_or_empty()),
|
qs(data.vauthor().value_or_empty()),
|
||||||
data.is_has_large_media(),
|
data.is_has_large_media(),
|
||||||
|
@ -3717,6 +3740,7 @@ void Session::webpageApplyFields(
|
||||||
WebPageCollage &&collage,
|
WebPageCollage &&collage,
|
||||||
std::unique_ptr<Iv::Data> iv,
|
std::unique_ptr<Iv::Data> iv,
|
||||||
std::unique_ptr<WebPageStickerSet> stickerSet,
|
std::unique_ptr<WebPageStickerSet> stickerSet,
|
||||||
|
std::shared_ptr<UniqueGift> uniqueGift,
|
||||||
int duration,
|
int duration,
|
||||||
const QString &author,
|
const QString &author,
|
||||||
bool hasLargeMedia,
|
bool hasLargeMedia,
|
||||||
|
@ -3735,6 +3759,7 @@ void Session::webpageApplyFields(
|
||||||
std::move(collage),
|
std::move(collage),
|
||||||
std::move(iv),
|
std::move(iv),
|
||||||
std::move(stickerSet),
|
std::move(stickerSet),
|
||||||
|
std::move(uniqueGift),
|
||||||
duration,
|
duration,
|
||||||
author,
|
author,
|
||||||
hasLargeMedia,
|
hasLargeMedia,
|
||||||
|
|
|
@ -71,6 +71,7 @@ class BusinessInfo;
|
||||||
struct ReactionId;
|
struct ReactionId;
|
||||||
struct UnavailableReason;
|
struct UnavailableReason;
|
||||||
struct CreditsStatusSlice;
|
struct CreditsStatusSlice;
|
||||||
|
struct UniqueGift;
|
||||||
|
|
||||||
struct RepliesReadTillUpdate {
|
struct RepliesReadTillUpdate {
|
||||||
FullMsgId id;
|
FullMsgId id;
|
||||||
|
@ -336,7 +337,7 @@ public:
|
||||||
void notifyPinnedDialogsOrderUpdated();
|
void notifyPinnedDialogsOrderUpdated();
|
||||||
[[nodiscard]] rpl::producer<> pinnedDialogsOrderUpdated() const;
|
[[nodiscard]] rpl::producer<> pinnedDialogsOrderUpdated() const;
|
||||||
|
|
||||||
using CreditsSubsRebuilder = rpl::event_stream<Data::CreditsStatusSlice>;
|
using CreditsSubsRebuilder = rpl::event_stream<CreditsStatusSlice>;
|
||||||
using CreditsSubsRebuilderPtr = std::shared_ptr<CreditsSubsRebuilder>;
|
using CreditsSubsRebuilderPtr = std::shared_ptr<CreditsSubsRebuilder>;
|
||||||
[[nodiscard]] CreditsSubsRebuilderPtr createCreditsSubsRebuilder();
|
[[nodiscard]] CreditsSubsRebuilderPtr createCreditsSubsRebuilder();
|
||||||
[[nodiscard]] CreditsSubsRebuilderPtr activeCreditsSubsRebuilder() const;
|
[[nodiscard]] CreditsSubsRebuilderPtr activeCreditsSubsRebuilder() const;
|
||||||
|
@ -422,7 +423,7 @@ public:
|
||||||
[[nodiscard]] const std::vector<Dialogs::Key> &pinnedChatsOrder(
|
[[nodiscard]] const std::vector<Dialogs::Key> &pinnedChatsOrder(
|
||||||
FilterId filterId) const;
|
FilterId filterId) const;
|
||||||
[[nodiscard]] const std::vector<Dialogs::Key> &pinnedChatsOrder(
|
[[nodiscard]] const std::vector<Dialogs::Key> &pinnedChatsOrder(
|
||||||
not_null<Data::SavedMessages*> saved) const;
|
not_null<SavedMessages*> saved) const;
|
||||||
void setChatPinned(Dialogs::Key key, FilterId filterId, bool pinned);
|
void setChatPinned(Dialogs::Key key, FilterId filterId, bool pinned);
|
||||||
void setPinnedFromEntryList(Dialogs::Key key, bool pinned);
|
void setPinnedFromEntryList(Dialogs::Key key, bool pinned);
|
||||||
void clearPinnedChats(Folder *folder);
|
void clearPinnedChats(Folder *folder);
|
||||||
|
@ -430,7 +431,7 @@ public:
|
||||||
Folder *folder,
|
Folder *folder,
|
||||||
const QVector<MTPDialogPeer> &list);
|
const QVector<MTPDialogPeer> &list);
|
||||||
void applyPinnedTopics(
|
void applyPinnedTopics(
|
||||||
not_null<Data::Forum*> forum,
|
not_null<Forum*> forum,
|
||||||
const QVector<MTPint> &list);
|
const QVector<MTPint> &list);
|
||||||
void reorderTwoPinnedChats(
|
void reorderTwoPinnedChats(
|
||||||
FilterId filterId,
|
FilterId filterId,
|
||||||
|
@ -624,6 +625,7 @@ public:
|
||||||
WebPageCollage &&collage,
|
WebPageCollage &&collage,
|
||||||
std::unique_ptr<Iv::Data> iv,
|
std::unique_ptr<Iv::Data> iv,
|
||||||
std::unique_ptr<WebPageStickerSet> stickerSet,
|
std::unique_ptr<WebPageStickerSet> stickerSet,
|
||||||
|
std::shared_ptr<UniqueGift> uniqueGift,
|
||||||
int duration,
|
int duration,
|
||||||
const QString &author,
|
const QString &author,
|
||||||
bool hasLargeMedia,
|
bool hasLargeMedia,
|
||||||
|
@ -908,6 +910,7 @@ private:
|
||||||
WebPageCollage &&collage,
|
WebPageCollage &&collage,
|
||||||
std::unique_ptr<Iv::Data> iv,
|
std::unique_ptr<Iv::Data> iv,
|
||||||
std::unique_ptr<WebPageStickerSet> stickerSet,
|
std::unique_ptr<WebPageStickerSet> stickerSet,
|
||||||
|
std::shared_ptr<UniqueGift> uniqueGift,
|
||||||
int duration,
|
int duration,
|
||||||
const QString &author,
|
const QString &author,
|
||||||
bool hasLargeMedia,
|
bool hasLargeMedia,
|
||||||
|
|
|
@ -224,6 +224,7 @@ bool WebPageData::applyChanges(
|
||||||
WebPageCollage &&newCollage,
|
WebPageCollage &&newCollage,
|
||||||
std::unique_ptr<Iv::Data> newIv,
|
std::unique_ptr<Iv::Data> newIv,
|
||||||
std::unique_ptr<WebPageStickerSet> newStickerSet,
|
std::unique_ptr<WebPageStickerSet> newStickerSet,
|
||||||
|
std::shared_ptr<Data::UniqueGift> newUniqueGift,
|
||||||
int newDuration,
|
int newDuration,
|
||||||
const QString &newAuthor,
|
const QString &newAuthor,
|
||||||
bool newHasLargeMedia,
|
bool newHasLargeMedia,
|
||||||
|
@ -278,6 +279,7 @@ bool WebPageData::applyChanges(
|
||||||
&& (!iv == !newIv)
|
&& (!iv == !newIv)
|
||||||
&& (!iv || iv->partial() == newIv->partial())
|
&& (!iv || iv->partial() == newIv->partial())
|
||||||
&& (!stickerSet == !newStickerSet)
|
&& (!stickerSet == !newStickerSet)
|
||||||
|
&& (!uniqueGift == !newUniqueGift)
|
||||||
&& duration == newDuration
|
&& duration == newDuration
|
||||||
&& author == resultAuthor
|
&& author == resultAuthor
|
||||||
&& hasLargeMedia == (newHasLargeMedia ? 1 : 0)
|
&& hasLargeMedia == (newHasLargeMedia ? 1 : 0)
|
||||||
|
@ -300,6 +302,7 @@ bool WebPageData::applyChanges(
|
||||||
collage = std::move(newCollage);
|
collage = std::move(newCollage);
|
||||||
iv = std::move(newIv);
|
iv = std::move(newIv);
|
||||||
stickerSet = std::move(newStickerSet);
|
stickerSet = std::move(newStickerSet);
|
||||||
|
uniqueGift = std::move(newUniqueGift);
|
||||||
duration = newDuration;
|
duration = newDuration;
|
||||||
author = resultAuthor;
|
author = resultAuthor;
|
||||||
pendingTill = newPendingTill;
|
pendingTill = newPendingTill;
|
||||||
|
|
|
@ -15,6 +15,7 @@ class ChannelData;
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
class Session;
|
class Session;
|
||||||
|
struct UniqueGift;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
namespace Iv {
|
namespace Iv {
|
||||||
|
@ -101,6 +102,7 @@ struct WebPageData {
|
||||||
WebPageCollage &&newCollage,
|
WebPageCollage &&newCollage,
|
||||||
std::unique_ptr<Iv::Data> newIv,
|
std::unique_ptr<Iv::Data> newIv,
|
||||||
std::unique_ptr<WebPageStickerSet> newStickerSet,
|
std::unique_ptr<WebPageStickerSet> newStickerSet,
|
||||||
|
std::shared_ptr<Data::UniqueGift> newUniqueGift,
|
||||||
int newDuration,
|
int newDuration,
|
||||||
const QString &newAuthor,
|
const QString &newAuthor,
|
||||||
bool newHasLargeMedia,
|
bool newHasLargeMedia,
|
||||||
|
@ -129,6 +131,7 @@ struct WebPageData {
|
||||||
WebPageCollage collage;
|
WebPageCollage collage;
|
||||||
std::unique_ptr<Iv::Data> iv;
|
std::unique_ptr<Iv::Data> iv;
|
||||||
std::unique_ptr<WebPageStickerSet> stickerSet;
|
std::unique_ptr<WebPageStickerSet> stickerSet;
|
||||||
|
std::shared_ptr<Data::UniqueGift> uniqueGift;
|
||||||
int duration = 0;
|
int duration = 0;
|
||||||
TimeId pendingTill = 0;
|
TimeId pendingTill = 0;
|
||||||
uint32 version : 30 = 0;
|
uint32 version : 30 = 0;
|
||||||
|
|
|
@ -720,6 +720,7 @@ HistoryItem::HistoryItem(
|
||||||
WebPageCollage(),
|
WebPageCollage(),
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
nullptr,
|
||||||
0,
|
0,
|
||||||
QString(),
|
QString(),
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -82,8 +82,12 @@ auto GenerateChatIntro(
|
||||||
Element *replacing,
|
Element *replacing,
|
||||||
const Data::ChatIntro &data,
|
const Data::ChatIntro &data,
|
||||||
Fn<void(not_null<DocumentData*>)> helloChosen)
|
Fn<void(not_null<DocumentData*>)> helloChosen)
|
||||||
-> Fn<void(Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
|
-> Fn<void(
|
||||||
return [=](Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
|
not_null<MediaGeneric*>,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
|
||||||
|
return [=](
|
||||||
|
not_null<MediaGeneric*> media,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
|
||||||
auto pushText = [&](
|
auto pushText = [&](
|
||||||
TextWithEntities text,
|
TextWithEntities text,
|
||||||
QMargins margins = {},
|
QMargins margins = {},
|
||||||
|
|
|
@ -32,8 +32,12 @@ constexpr auto kOutlineRatio = 0.85;
|
||||||
auto GenerateGiveawayStart(
|
auto GenerateGiveawayStart(
|
||||||
not_null<Element*> parent,
|
not_null<Element*> parent,
|
||||||
not_null<Data::GiveawayStart*> data)
|
not_null<Data::GiveawayStart*> data)
|
||||||
-> Fn<void(Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
|
-> Fn<void(
|
||||||
return [=](Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
|
not_null<MediaGeneric*>,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
|
||||||
|
return [=](
|
||||||
|
not_null<MediaGeneric*> media,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
|
||||||
const auto months = data->months;
|
const auto months = data->months;
|
||||||
const auto quantity = data->quantity;
|
const auto quantity = data->quantity;
|
||||||
|
|
||||||
|
@ -201,8 +205,12 @@ auto GenerateGiveawayStart(
|
||||||
auto GenerateGiveawayResults(
|
auto GenerateGiveawayResults(
|
||||||
not_null<Element*> parent,
|
not_null<Element*> parent,
|
||||||
not_null<Data::GiveawayResults*> data)
|
not_null<Data::GiveawayResults*> data)
|
||||||
-> Fn<void(Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
|
-> Fn<void(
|
||||||
return [=](Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
|
not_null<MediaGeneric*>,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
|
||||||
|
return [=](
|
||||||
|
not_null<MediaGeneric*> media,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
|
||||||
const auto quantity = data->winnersCount;
|
const auto quantity = data->winnersCount;
|
||||||
|
|
||||||
using Data = StickerWithBadgePart::Data;
|
using Data = StickerWithBadgePart::Data;
|
||||||
|
|
|
@ -15,16 +15,21 @@ struct GiveawayResults;
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
|
||||||
class Element;
|
class Element;
|
||||||
|
class MediaGeneric;
|
||||||
class MediaGenericPart;
|
class MediaGenericPart;
|
||||||
|
|
||||||
[[nodiscard]] auto GenerateGiveawayStart(
|
[[nodiscard]] auto GenerateGiveawayStart(
|
||||||
not_null<Element*> parent,
|
not_null<Element*> parent,
|
||||||
not_null<Data::GiveawayStart*> data)
|
not_null<Data::GiveawayStart*> data)
|
||||||
-> Fn<void(Fn<void(std::unique_ptr<MediaGenericPart>)>)>;
|
-> Fn<void(
|
||||||
|
not_null<MediaGeneric*>,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)>)>;
|
||||||
|
|
||||||
[[nodiscard]] auto GenerateGiveawayResults(
|
[[nodiscard]] auto GenerateGiveawayResults(
|
||||||
not_null<Element*> parent,
|
not_null<Element*> parent,
|
||||||
not_null<Data::GiveawayResults*> data)
|
not_null<Data::GiveawayResults*> data)
|
||||||
-> Fn<void(Fn<void(std::unique_ptr<MediaGenericPart>)>)>;
|
-> Fn<void(
|
||||||
|
not_null<MediaGeneric*>,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)>)>;
|
||||||
|
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
|
@ -71,14 +71,16 @@ auto MediaGenericPart::stickerTakePlayer(
|
||||||
|
|
||||||
MediaGeneric::MediaGeneric(
|
MediaGeneric::MediaGeneric(
|
||||||
not_null<Element*> parent,
|
not_null<Element*> parent,
|
||||||
Fn<void(Fn<void(std::unique_ptr<Part>)>)> generate,
|
Fn<void(
|
||||||
|
not_null<MediaGeneric*>,
|
||||||
|
Fn<void(std::unique_ptr<Part>)>)> generate,
|
||||||
MediaGenericDescriptor &&descriptor)
|
MediaGenericDescriptor &&descriptor)
|
||||||
: Media(parent)
|
: Media(parent)
|
||||||
, _paintBg(std::move(descriptor.paintBg))
|
, _paintBg(std::move(descriptor.paintBg))
|
||||||
, _maxWidthCap(descriptor.maxWidth)
|
, _maxWidthCap(descriptor.maxWidth)
|
||||||
, _service(descriptor.service)
|
, _service(descriptor.service)
|
||||||
, _hideServiceText(descriptor.hideServiceText) {
|
, _hideServiceText(descriptor.hideServiceText) {
|
||||||
generate([&](std::unique_ptr<Part> part) {
|
generate(this, [&](std::unique_ptr<Part> part) {
|
||||||
_entries.push_back({
|
_entries.push_back({
|
||||||
.object = std::move(part),
|
.object = std::move(part),
|
||||||
});
|
});
|
||||||
|
@ -125,7 +127,7 @@ void MediaGeneric::draw(Painter &p, const PaintContext &context) const {
|
||||||
if (outer < st::msgPadding.left() + st::msgPadding.right() + 1) {
|
if (outer < st::msgPadding.left() + st::msgPadding.right() + 1) {
|
||||||
return;
|
return;
|
||||||
} else if (_paintBg) {
|
} else if (_paintBg) {
|
||||||
_paintBg(p, context);
|
_paintBg(p, context, this);
|
||||||
} else if (_service) {
|
} else if (_service) {
|
||||||
PainterHighQualityEnabler hq(p);
|
PainterHighQualityEnabler hq(p);
|
||||||
const auto radius = st::msgServiceGiftBoxRadius;
|
const auto radius = st::msgServiceGiftBoxRadius;
|
||||||
|
|
|
@ -53,7 +53,10 @@ public:
|
||||||
|
|
||||||
struct MediaGenericDescriptor {
|
struct MediaGenericDescriptor {
|
||||||
int maxWidth = 0;
|
int maxWidth = 0;
|
||||||
Fn<void(Painter&, const PaintContext&)> paintBg;
|
Fn<void(
|
||||||
|
Painter&,
|
||||||
|
const PaintContext&,
|
||||||
|
not_null<const MediaGeneric*>)> paintBg;
|
||||||
ClickHandlerPtr serviceLink;
|
ClickHandlerPtr serviceLink;
|
||||||
bool service = false;
|
bool service = false;
|
||||||
bool hideServiceText = false;
|
bool hideServiceText = false;
|
||||||
|
@ -65,7 +68,9 @@ public:
|
||||||
|
|
||||||
MediaGeneric(
|
MediaGeneric(
|
||||||
not_null<Element*> parent,
|
not_null<Element*> parent,
|
||||||
Fn<void(Fn<void(std::unique_ptr<Part>)>)> generate,
|
Fn<void(
|
||||||
|
not_null<MediaGeneric*>,
|
||||||
|
Fn<void(std::unique_ptr<Part>)>)> generate,
|
||||||
MediaGenericDescriptor &&descriptor = {});
|
MediaGenericDescriptor &&descriptor = {});
|
||||||
~MediaGeneric();
|
~MediaGeneric();
|
||||||
|
|
||||||
|
@ -119,7 +124,10 @@ private:
|
||||||
[[nodiscard]] QMargins inBubblePadding() const;
|
[[nodiscard]] QMargins inBubblePadding() const;
|
||||||
|
|
||||||
std::vector<Entry> _entries;
|
std::vector<Entry> _entries;
|
||||||
Fn<void(Painter&, const PaintContext&)> _paintBg;
|
Fn<void(
|
||||||
|
Painter&,
|
||||||
|
const PaintContext&,
|
||||||
|
not_null<const MediaGeneric*>)> _paintBg;
|
||||||
int _maxWidthCap = 0;
|
int _maxWidthCap = 0;
|
||||||
bool _service : 1 = false;
|
bool _service : 1 = false;
|
||||||
bool _hideServiceText : 1 = false;
|
bool _hideServiceText : 1 = false;
|
||||||
|
@ -150,7 +158,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setupPen(
|
virtual void setupPen(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
not_null<const MediaGeneric*> owner,
|
not_null<const MediaGeneric*> owner,
|
||||||
const PaintContext &context) const;
|
const PaintContext &context) const;
|
||||||
|
|
||||||
|
|
|
@ -383,9 +383,13 @@ QSize AttributeTable::countCurrentSize(int newWidth) {
|
||||||
auto GenerateUniqueGiftMedia(
|
auto GenerateUniqueGiftMedia(
|
||||||
not_null<Element*> parent,
|
not_null<Element*> parent,
|
||||||
Element *replacing,
|
Element *replacing,
|
||||||
not_null<Data::UniqueGift*> gift)
|
std::shared_ptr<Data::UniqueGift> gift)
|
||||||
-> Fn<void(Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
|
-> Fn<void(
|
||||||
return [=](Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
|
not_null<MediaGeneric*>,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
|
||||||
|
return [=](
|
||||||
|
not_null<MediaGeneric*> media,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
|
||||||
auto pushText = [&](
|
auto pushText = [&](
|
||||||
TextWithEntities text,
|
TextWithEntities text,
|
||||||
const style::TextStyle &st,
|
const style::TextStyle &st,
|
||||||
|
@ -402,8 +406,8 @@ auto GenerateUniqueGiftMedia(
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto item = parent->data();
|
const auto item = parent->data();
|
||||||
const auto media = item->media();
|
const auto itemMedia = item->media();
|
||||||
const auto fields = media ? media->gift() : nullptr;
|
const auto fields = itemMedia ? itemMedia->gift() : nullptr;
|
||||||
const auto upgrade = fields && fields->upgrade;
|
const auto upgrade = fields && fields->upgrade;
|
||||||
const auto outgoing = upgrade ? !item->out() : item->out();
|
const auto outgoing = upgrade ? !item->out() : item->out();
|
||||||
|
|
||||||
|
@ -478,9 +482,13 @@ auto GenerateUniqueGiftMedia(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Fn<void(Painter&, const Ui::ChatPaintContext &)> UniqueGiftBg(
|
auto UniqueGiftBg(
|
||||||
not_null<Element*> view,
|
not_null<Element*> view,
|
||||||
not_null<Data::UniqueGift*> gift) {
|
std::shared_ptr<Data::UniqueGift> gift)
|
||||||
|
-> Fn<void(
|
||||||
|
Painter&,
|
||||||
|
const Ui::ChatPaintContext&,
|
||||||
|
not_null<const MediaGeneric*>)> {
|
||||||
struct State {
|
struct State {
|
||||||
QImage bg;
|
QImage bg;
|
||||||
base::flat_map<float64, QImage> cache;
|
base::flat_map<float64, QImage> cache;
|
||||||
|
@ -495,20 +503,25 @@ Fn<void(Painter&, const Ui::ChatPaintContext &)> UniqueGiftBg(
|
||||||
Data::CustomEmojiSizeTag::Large);
|
Data::CustomEmojiSizeTag::Large);
|
||||||
[[maybe_unused]] const auto preload = state->pattern->ready();
|
[[maybe_unused]] const auto preload = state->pattern->ready();
|
||||||
|
|
||||||
return [=](Painter &p, const Ui::ChatPaintContext &context) {
|
return [=](
|
||||||
|
Painter &p,
|
||||||
|
const Ui::ChatPaintContext &context,
|
||||||
|
not_null<const MediaGeneric*> media) {
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
const auto thickness = st::chatUniqueGiftBorder * 2;
|
const auto webpreview = (media.get() != view->media());
|
||||||
auto pen = context.st->msgServiceBg()->p;
|
const auto thickness = webpreview ? 0 : st::chatUniqueGiftBorder * 2;
|
||||||
pen.setWidthF(thickness);
|
|
||||||
p.setPen(pen);
|
|
||||||
p.setBrush(Qt::transparent);
|
|
||||||
const auto radius = st::msgServiceGiftBoxRadius - thickness;
|
const auto radius = st::msgServiceGiftBoxRadius - thickness;
|
||||||
const auto media = view->media();
|
|
||||||
const auto full = QRect(0, 0, media->width(), media->height());
|
const auto full = QRect(0, 0, media->width(), media->height());
|
||||||
const auto inner = full.marginsRemoved(
|
const auto inner = full.marginsRemoved(
|
||||||
{ thickness, thickness, thickness, thickness });
|
{ thickness, thickness, thickness, thickness });
|
||||||
p.drawRoundedRect(inner, radius, radius);
|
if (!webpreview) {
|
||||||
|
auto pen = context.st->msgServiceBg()->p;
|
||||||
|
pen.setWidthF(thickness);
|
||||||
|
p.setPen(pen);
|
||||||
|
p.setBrush(Qt::transparent);
|
||||||
|
p.drawRoundedRect(inner, radius, radius);
|
||||||
|
}
|
||||||
auto gradient = QRadialGradient(
|
auto gradient = QRadialGradient(
|
||||||
inner.center(),
|
inner.center(),
|
||||||
inner.height() / 2);
|
inner.height() / 2);
|
||||||
|
@ -534,7 +547,7 @@ Fn<void(Painter&, const Ui::ChatPaintContext &)> UniqueGiftBg(
|
||||||
outer);
|
outer);
|
||||||
p.setClipping(false);
|
p.setClipping(false);
|
||||||
|
|
||||||
const auto add = style::ConvertScale(2);
|
const auto add = webpreview ? 0 : style::ConvertScale(2);
|
||||||
p.setClipRect(
|
p.setClipRect(
|
||||||
inner.x() - add,
|
inner.x() - add,
|
||||||
inner.y() - add,
|
inner.y() - add,
|
||||||
|
@ -560,6 +573,32 @@ Fn<void(Painter&, const Ui::ChatPaintContext &)> UniqueGiftBg(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto GenerateUniqueGiftPreview(
|
||||||
|
not_null<Element*> parent,
|
||||||
|
Element *replacing,
|
||||||
|
std::shared_ptr<Data::UniqueGift> gift)
|
||||||
|
-> Fn<void(
|
||||||
|
not_null<MediaGeneric*>,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)>)> {
|
||||||
|
return [=](
|
||||||
|
not_null<MediaGeneric*> media,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)> push) {
|
||||||
|
const auto sticker = [=] {
|
||||||
|
using Tag = ChatHelpers::StickerLottieSize;
|
||||||
|
return StickerInBubblePart::Data{
|
||||||
|
.sticker = gift->model.document,
|
||||||
|
.size = st::chatIntroStickerSize,
|
||||||
|
.cacheTag = Tag::ChatIntroHelloSticker,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
push(std::make_unique<StickerInBubblePart>(
|
||||||
|
parent,
|
||||||
|
replacing,
|
||||||
|
sticker,
|
||||||
|
st::chatUniquePreviewPadding));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<MediaGenericPart> MakeGenericButtonPart(
|
std::unique_ptr<MediaGenericPart> MakeGenericButtonPart(
|
||||||
const QString &text,
|
const QString &text,
|
||||||
QMargins margins,
|
QMargins margins,
|
||||||
|
|
|
@ -21,17 +21,32 @@ struct ChatPaintContext;
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
|
||||||
class Element;
|
class Element;
|
||||||
|
class MediaGeneric;
|
||||||
class MediaGenericPart;
|
class MediaGenericPart;
|
||||||
|
|
||||||
auto GenerateUniqueGiftMedia(
|
[[nodiscard]] auto GenerateUniqueGiftMedia(
|
||||||
not_null<Element*> parent,
|
not_null<Element*> parent,
|
||||||
Element *replacing,
|
Element *replacing,
|
||||||
not_null<Data::UniqueGift*> gift)
|
std::shared_ptr<Data::UniqueGift> gift)
|
||||||
-> Fn<void(Fn<void(std::unique_ptr<MediaGenericPart>)>)>;
|
-> Fn<void(
|
||||||
|
not_null<MediaGeneric*>,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)>)>;
|
||||||
|
|
||||||
[[nodiscard]] Fn<void(Painter&, const Ui::ChatPaintContext &)> UniqueGiftBg(
|
[[nodiscard]] auto UniqueGiftBg(
|
||||||
not_null<Element*> view,
|
not_null<Element*> view,
|
||||||
not_null<Data::UniqueGift*> gift);
|
std::shared_ptr<Data::UniqueGift> gift)
|
||||||
|
-> Fn<void(
|
||||||
|
Painter&,
|
||||||
|
const Ui::ChatPaintContext&,
|
||||||
|
not_null<const MediaGeneric*>)>;
|
||||||
|
|
||||||
|
[[nodiscard]] auto GenerateUniqueGiftPreview(
|
||||||
|
not_null<Element*> parent,
|
||||||
|
Element *replacing,
|
||||||
|
std::shared_ptr<Data::UniqueGift> gift)
|
||||||
|
-> Fn<void(
|
||||||
|
not_null<MediaGeneric*>,
|
||||||
|
Fn<void(std::unique_ptr<MediaGenericPart>)>)>;
|
||||||
|
|
||||||
[[nodiscard]] std::unique_ptr<MediaGenericPart> MakeGenericButtonPart(
|
[[nodiscard]] std::unique_ptr<MediaGenericPart> MakeGenericButtonPart(
|
||||||
const QString &text,
|
const QString &text,
|
||||||
|
|
|
@ -21,7 +21,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_web_page.h"
|
#include "data/data_web_page.h"
|
||||||
#include "history/view/media/history_view_media_common.h"
|
#include "history/view/media/history_view_media_common.h"
|
||||||
#include "history/view/media/history_view_sticker.h"
|
#include "history/view/media/history_view_media_generic.h"
|
||||||
|
#include "history/view/media/history_view_unique_gift.h"
|
||||||
#include "history/view/history_view_cursor_state.h"
|
#include "history/view/history_view_cursor_state.h"
|
||||||
#include "history/view/history_view_message.h"
|
#include "history/view/history_view_message.h"
|
||||||
#include "history/view/history_view_reply.h"
|
#include "history/view/history_view_reply.h"
|
||||||
|
@ -196,6 +197,8 @@ constexpr auto kFactcheckAboutDuration = 5 * crl::time(1000);
|
||||||
const auto type = page->type;
|
const auto type = page->type;
|
||||||
const auto text = Ui::Text::Upper(page->iv
|
const auto text = Ui::Text::Upper(page->iv
|
||||||
? tr::lng_view_button_iv(tr::now)
|
? tr::lng_view_button_iv(tr::now)
|
||||||
|
: page->uniqueGift
|
||||||
|
? tr::lng_view_button_collectible(tr::now)
|
||||||
: (type == WebPageType::Theme)
|
: (type == WebPageType::Theme)
|
||||||
? tr::lng_view_button_theme(tr::now)
|
? tr::lng_view_button_theme(tr::now)
|
||||||
: (type == WebPageType::Story)
|
: (type == WebPageType::Story)
|
||||||
|
@ -245,6 +248,7 @@ constexpr auto kFactcheckAboutDuration = 5 * crl::time(1000);
|
||||||
[[nodiscard]] bool HasButton(not_null<WebPageData*> webpage) {
|
[[nodiscard]] bool HasButton(not_null<WebPageData*> webpage) {
|
||||||
const auto type = webpage->type;
|
const auto type = webpage->type;
|
||||||
return webpage->iv
|
return webpage->iv
|
||||||
|
|| webpage->uniqueGift
|
||||||
|| (type == WebPageType::Message)
|
|| (type == WebPageType::Message)
|
||||||
|| (type == WebPageType::Group)
|
|| (type == WebPageType::Group)
|
||||||
|| (type == WebPageType::GroupWithRequest)
|
|| (type == WebPageType::GroupWithRequest)
|
||||||
|
@ -501,7 +505,18 @@ QSize WebPage::countOptimalSize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// init attach
|
// init attach
|
||||||
if (!_attach && !_asArticle) {
|
if (!_attach && _data->uniqueGift) {
|
||||||
|
_attach = std::make_unique<MediaGeneric>(
|
||||||
|
_parent,
|
||||||
|
GenerateUniqueGiftPreview(
|
||||||
|
_parent,
|
||||||
|
nullptr,
|
||||||
|
_data->uniqueGift),
|
||||||
|
MediaGenericDescriptor{
|
||||||
|
.maxWidth = st::msgServiceGiftPreview,
|
||||||
|
.paintBg = UniqueGiftBg(_parent, _data->uniqueGift),
|
||||||
|
});
|
||||||
|
} else if (!_attach && !_asArticle) {
|
||||||
_attach = CreateAttach(
|
_attach = CreateAttach(
|
||||||
_parent,
|
_parent,
|
||||||
_data->document,
|
_data->document,
|
||||||
|
@ -511,7 +526,9 @@ QSize WebPage::countOptimalSize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// init strings
|
// init strings
|
||||||
if (_description.isEmpty() && !_data->description.text.isEmpty()) {
|
if (_description.isEmpty()
|
||||||
|
&& !_data->description.text.isEmpty()
|
||||||
|
&& !_data->uniqueGift) {
|
||||||
const auto &text = _data->description;
|
const auto &text = _data->description;
|
||||||
|
|
||||||
if (isLogEntryOriginal()) {
|
if (isLogEntryOriginal()) {
|
||||||
|
|
|
@ -911,6 +911,7 @@ searchInChatPeerList: PeerList(defaultPeerList) {
|
||||||
}
|
}
|
||||||
searchInChatTagsPadding: margins(6px, 0px, 6px, 0px);
|
searchInChatTagsPadding: margins(6px, 0px, 6px, 0px);
|
||||||
|
|
||||||
|
msgServiceGiftPreview: 172px;
|
||||||
msgServiceGiftBoxSize: size(236px, 231px); // Plus msgServiceGiftBoxTopSkip.
|
msgServiceGiftBoxSize: size(236px, 231px); // Plus msgServiceGiftBoxTopSkip.
|
||||||
msgServiceGiftBoxRadius: 20px;
|
msgServiceGiftBoxRadius: 20px;
|
||||||
msgServiceGiftBoxTopSkip: 4px;
|
msgServiceGiftBoxTopSkip: 4px;
|
||||||
|
@ -1211,6 +1212,7 @@ botDownloadCancel: IconButton {
|
||||||
chatUniqueGiftBorder: 4px;
|
chatUniqueGiftBorder: 4px;
|
||||||
|
|
||||||
chatUniqueStickerPadding: margins(10px, 30px, 10px, 9px);
|
chatUniqueStickerPadding: margins(10px, 30px, 10px, 9px);
|
||||||
|
chatUniquePreviewPadding: margins(10px, 30px, 10px, 32px);
|
||||||
chatUniqueTitle: TextStyle(defaultTextStyle) {
|
chatUniqueTitle: TextStyle(defaultTextStyle) {
|
||||||
font: font(16px semibold);
|
font: font(16px semibold);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue