mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Parse video cover photos.
This commit is contained in:
parent
eda749d7cb
commit
23ae638512
7 changed files with 29 additions and 2 deletions
|
@ -553,6 +553,10 @@ DocumentData *Media::document() const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PhotoData *Media::videoCover() const {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool Media::hasQualitiesList() const {
|
bool Media::hasQualitiesList() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -969,12 +973,14 @@ std::unique_ptr<HistoryView::Media> MediaPhoto::createView(
|
||||||
MediaFile::MediaFile(
|
MediaFile::MediaFile(
|
||||||
not_null<HistoryItem*> parent,
|
not_null<HistoryItem*> parent,
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
|
PhotoData *videoCover,
|
||||||
bool skipPremiumEffect,
|
bool skipPremiumEffect,
|
||||||
bool hasQualitiesList,
|
bool hasQualitiesList,
|
||||||
bool spoiler,
|
bool spoiler,
|
||||||
crl::time ttlSeconds)
|
crl::time ttlSeconds)
|
||||||
: Media(parent)
|
: Media(parent)
|
||||||
, _document(document)
|
, _document(document)
|
||||||
|
, _videoCover(videoCover)
|
||||||
, _emoji(document->sticker() ? document->sticker()->alt : QString())
|
, _emoji(document->sticker() ? document->sticker()->alt : QString())
|
||||||
, _skipPremiumEffect(skipPremiumEffect)
|
, _skipPremiumEffect(skipPremiumEffect)
|
||||||
, _hasQualitiesList(hasQualitiesList)
|
, _hasQualitiesList(hasQualitiesList)
|
||||||
|
@ -1006,6 +1012,7 @@ std::unique_ptr<Media> MediaFile::clone(not_null<HistoryItem*> parent) {
|
||||||
return std::make_unique<MediaFile>(
|
return std::make_unique<MediaFile>(
|
||||||
parent,
|
parent,
|
||||||
_document,
|
_document,
|
||||||
|
_videoCover,
|
||||||
!_document->session().premium(),
|
!_document->session().premium(),
|
||||||
_hasQualitiesList,
|
_hasQualitiesList,
|
||||||
_spoiler,
|
_spoiler,
|
||||||
|
@ -1016,6 +1023,10 @@ DocumentData *MediaFile::document() const {
|
||||||
return _document;
|
return _document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PhotoData *MediaFile::videoCover() const {
|
||||||
|
return _videoCover;
|
||||||
|
}
|
||||||
|
|
||||||
bool MediaFile::hasQualitiesList() const {
|
bool MediaFile::hasQualitiesList() const {
|
||||||
return _hasQualitiesList;
|
return _hasQualitiesList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,6 +179,7 @@ public:
|
||||||
virtual std::unique_ptr<Media> clone(not_null<HistoryItem*> parent) = 0;
|
virtual std::unique_ptr<Media> clone(not_null<HistoryItem*> parent) = 0;
|
||||||
|
|
||||||
virtual DocumentData *document() const;
|
virtual DocumentData *document() const;
|
||||||
|
virtual PhotoData *videoCover() const;
|
||||||
virtual bool hasQualitiesList() const;
|
virtual bool hasQualitiesList() const;
|
||||||
virtual PhotoData *photo() const;
|
virtual PhotoData *photo() const;
|
||||||
virtual WebPageData *webpage() const;
|
virtual WebPageData *webpage() const;
|
||||||
|
@ -301,6 +302,7 @@ public:
|
||||||
MediaFile(
|
MediaFile(
|
||||||
not_null<HistoryItem*> parent,
|
not_null<HistoryItem*> parent,
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
|
PhotoData *videoCover,
|
||||||
bool skipPremiumEffect,
|
bool skipPremiumEffect,
|
||||||
bool hasQualitiesList,
|
bool hasQualitiesList,
|
||||||
bool spoiler,
|
bool spoiler,
|
||||||
|
@ -310,6 +312,7 @@ public:
|
||||||
std::unique_ptr<Media> clone(not_null<HistoryItem*> parent) override;
|
std::unique_ptr<Media> clone(not_null<HistoryItem*> parent) override;
|
||||||
|
|
||||||
DocumentData *document() const override;
|
DocumentData *document() const override;
|
||||||
|
PhotoData *videoCover() const override;
|
||||||
bool hasQualitiesList() const override;
|
bool hasQualitiesList() const override;
|
||||||
|
|
||||||
bool uploading() const override;
|
bool uploading() const override;
|
||||||
|
@ -339,6 +342,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
not_null<DocumentData*> _document;
|
not_null<DocumentData*> _document;
|
||||||
|
PhotoData *_videoCover = nullptr;
|
||||||
QString _emoji;
|
QString _emoji;
|
||||||
bool _skipPremiumEffect = false;
|
bool _skipPremiumEffect = false;
|
||||||
bool _hasQualitiesList = false;
|
bool _hasQualitiesList = false;
|
||||||
|
|
|
@ -303,9 +303,13 @@ std::unique_ptr<Data::Media> HistoryItem::CreateMedia(
|
||||||
}
|
}
|
||||||
return document->match([&](const MTPDdocument &document) -> Result {
|
return document->match([&](const MTPDdocument &document) -> Result {
|
||||||
const auto list = media.valt_documents();
|
const auto list = media.valt_documents();
|
||||||
|
const auto owner = &item->history()->owner();
|
||||||
return std::make_unique<Data::MediaFile>(
|
return std::make_unique<Data::MediaFile>(
|
||||||
item,
|
item,
|
||||||
item->history()->owner().processDocument(document, list),
|
owner->processDocument(document, list),
|
||||||
|
(media.vvideo_cover()
|
||||||
|
? owner->processPhoto(*media.vvideo_cover()).get()
|
||||||
|
: nullptr),
|
||||||
media.is_nopremium(),
|
media.is_nopremium(),
|
||||||
list && !list->v.isEmpty(),
|
list && !list->v.isEmpty(),
|
||||||
media.is_spoiler(),
|
media.is_spoiler(),
|
||||||
|
@ -659,6 +663,7 @@ HistoryItem::HistoryItem(
|
||||||
_media = std::make_unique<Data::MediaFile>(
|
_media = std::make_unique<Data::MediaFile>(
|
||||||
this,
|
this,
|
||||||
document,
|
document,
|
||||||
|
/*videoCover=*/nullptr,
|
||||||
skipPremiumEffect,
|
skipPremiumEffect,
|
||||||
video && !video->qualities.empty(),
|
video && !video->qualities.empty(),
|
||||||
spoiler,
|
spoiler,
|
||||||
|
@ -1855,6 +1860,7 @@ void HistoryItem::setStoryFields(not_null<Data::Story*> story) {
|
||||||
_media = std::make_unique<Data::MediaFile>(
|
_media = std::make_unique<Data::MediaFile>(
|
||||||
this,
|
this,
|
||||||
document,
|
document,
|
||||||
|
/*videoCover=*/nullptr,
|
||||||
/*skipPremiumEffect=*/false,
|
/*skipPremiumEffect=*/false,
|
||||||
/*hasQualitiesList=*/false,
|
/*hasQualitiesList=*/false,
|
||||||
spoiler,
|
spoiler,
|
||||||
|
|
|
@ -150,7 +150,8 @@ Gif::Gif(
|
||||||
? std::make_unique<MediaSpoiler>()
|
? std::make_unique<MediaSpoiler>()
|
||||||
: nullptr)
|
: nullptr)
|
||||||
, _downloadSize(Ui::FormatSizeText(_data->size))
|
, _downloadSize(Ui::FormatSizeText(_data->size))
|
||||||
, _sensitiveSpoiler(realParent->isMediaSensitive()) {
|
, _sensitiveSpoiler(realParent->isMediaSensitive())
|
||||||
|
, _hasVideoCover(realParent->media() && realParent->media()->videoCover()) {
|
||||||
if (_data->isVideoMessage() && _parent->data()->media()->ttlSeconds()) {
|
if (_data->isVideoMessage() && _parent->data()->media()->ttlSeconds()) {
|
||||||
if (_spoiler) {
|
if (_spoiler) {
|
||||||
_drawTtl = CreateTtlPaintCallback([=] { repaint(); });
|
_drawTtl = CreateTtlPaintCallback([=] { repaint(); });
|
||||||
|
@ -395,6 +396,8 @@ bool Gif::downloadInCorner() const {
|
||||||
bool Gif::autoplayEnabled() const {
|
bool Gif::autoplayEnabled() const {
|
||||||
if (_realParent->isSponsored()) {
|
if (_realParent->isSponsored()) {
|
||||||
return true;
|
return true;
|
||||||
|
} else if (_hasVideoCover) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return Data::AutoDownload::ShouldAutoPlay(
|
return Data::AutoDownload::ShouldAutoPlay(
|
||||||
_data->session().settings().autoDownload(),
|
_data->session().settings().autoDownload(),
|
||||||
|
|
|
@ -224,6 +224,7 @@ private:
|
||||||
mutable bool _pollingStory : 1 = false;
|
mutable bool _pollingStory : 1 = false;
|
||||||
mutable bool _purchasedPriceTag : 1 = false;
|
mutable bool _purchasedPriceTag : 1 = false;
|
||||||
const bool _sensitiveSpoiler : 1 = false;
|
const bool _sensitiveSpoiler : 1 = false;
|
||||||
|
const bool _hasVideoCover : 1 = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ constexpr auto kSponsoredUserpicLines = 2;
|
||||||
result.push_back(std::make_unique<Data::MediaFile>(
|
result.push_back(std::make_unique<Data::MediaFile>(
|
||||||
parent,
|
parent,
|
||||||
*document,
|
*document,
|
||||||
|
/*videoCover=*/nullptr,
|
||||||
skipPremiumEffect,
|
skipPremiumEffect,
|
||||||
hasQualitiesList,
|
hasQualitiesList,
|
||||||
spoiler,
|
spoiler,
|
||||||
|
|
|
@ -313,6 +313,7 @@ void AddViewMediaHandler(
|
||||||
fake.push_back(std::make_unique<Data::MediaFile>(
|
fake.push_back(std::make_unique<Data::MediaFile>(
|
||||||
state->item,
|
state->item,
|
||||||
owner->document(item.id),
|
owner->document(item.id),
|
||||||
|
nullptr, // videoCover
|
||||||
true, // skipPremiumEffect
|
true, // skipPremiumEffect
|
||||||
false, // hasQualitiesList
|
false, // hasQualitiesList
|
||||||
false, // spoiler
|
false, // spoiler
|
||||||
|
|
Loading…
Add table
Reference in a new issue