mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Force non-transparency for WebDocuments in PhotoData.
This commit is contained in:
parent
b0f54822e0
commit
09e014cc14
2 changed files with 22 additions and 4 deletions
|
@ -29,6 +29,15 @@ using Data::PhotoSize;
|
|||
using Data::PhotoSizeIndex;
|
||||
using Data::kPhotoSizeCount;
|
||||
|
||||
[[nodiscard]] QImage ValidatePhotoImage(
|
||||
QImage image,
|
||||
const Data::CloudFile &file) {
|
||||
return (v::is<WebFileLocation>(file.location.file().data)
|
||||
&& image.format() == QImage::Format_ARGB32)
|
||||
? Images::prepareOpaque(std::move(image))
|
||||
: image;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
PhotoData::PhotoData(not_null<Data::Session*> owner, PhotoId id)
|
||||
|
@ -296,7 +305,10 @@ void PhotoData::load(
|
|||
}
|
||||
}
|
||||
if (const auto active = activeMediaView()) {
|
||||
active->set(validSize, goodFor, std::move(result));
|
||||
active->set(
|
||||
validSize,
|
||||
goodFor,
|
||||
ValidatePhotoImage(std::move(result), _images[valid]));
|
||||
}
|
||||
if (validSize == PhotoSize::Large && goodFor == validSize) {
|
||||
_owner->photoLoadDone(this);
|
||||
|
@ -355,15 +367,21 @@ void PhotoData::updateImages(
|
|||
_inlineThumbnailBytes = inlineThumbnailBytes;
|
||||
}
|
||||
const auto update = [&](PhotoSize size, const ImageWithLocation &data) {
|
||||
const auto index = PhotoSizeIndex(size);
|
||||
Data::UpdateCloudFile(
|
||||
_images[PhotoSizeIndex(size)],
|
||||
_images[index],
|
||||
data,
|
||||
owner().cache(),
|
||||
Data::kImageCacheTag,
|
||||
[=](Data::FileOrigin origin) { load(size, origin); },
|
||||
[=](QImage preloaded) {
|
||||
if (const auto media = activeMediaView()) {
|
||||
media->set(size, size, data.preloaded);
|
||||
media->set(
|
||||
size,
|
||||
size,
|
||||
ValidatePhotoImage(
|
||||
std::move(preloaded),
|
||||
_images[index]));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -129,7 +129,7 @@ std::unique_ptr<Result> Result::Create(
|
|||
if (!result->_photo && !result->_document && imageThumb) {
|
||||
result->_thumbnail.update(result->_session, ImageWithLocation{
|
||||
.location = Images::FromWebDocument(*data.vthumb())
|
||||
});
|
||||
});
|
||||
}
|
||||
return &data.vsend_message();
|
||||
}, [&](const MTPDbotInlineMediaResult &data) {
|
||||
|
|
Loading…
Add table
Reference in a new issue