mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Fix blurred thumbnails in Shared Links section.
This commit is contained in:
parent
1d7fb6c4ce
commit
a6eb241ec1
2 changed files with 20 additions and 9 deletions
|
@ -1479,9 +1479,8 @@ Link::Link(
|
|||
int32 tw = 0, th = 0;
|
||||
if (_page && _page->photo) {
|
||||
const auto photo = _page->photo;
|
||||
if (photo->inlineThumbnailBytes().isEmpty()
|
||||
&& (photo->hasExact(Data::PhotoSize::Small)
|
||||
|| photo->hasExact(Data::PhotoSize::Thumbnail))) {
|
||||
if (photo->hasExact(Data::PhotoSize::Small)
|
||||
|| photo->hasExact(Data::PhotoSize::Thumbnail)) {
|
||||
photo->load(Data::PhotoSize::Small, parent->fullId());
|
||||
}
|
||||
tw = style::ConvertScale(photo->width());
|
||||
|
@ -1623,7 +1622,7 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P
|
|||
}
|
||||
|
||||
void Link::validateThumbnail() {
|
||||
if (!_thumbnail.isNull()) {
|
||||
if (!_thumbnail.isNull() && !_thumbnailBlurred) {
|
||||
return;
|
||||
}
|
||||
if (_page && _page->photo) {
|
||||
|
@ -1631,12 +1630,16 @@ void Link::validateThumbnail() {
|
|||
ensurePhotoMediaCreated();
|
||||
if (const auto thumbnail = _photoMedia->image(PhotoSize::Thumbnail)) {
|
||||
_thumbnail = thumbnail->pixSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, ImageRoundRadius::Small);
|
||||
_thumbnailBlurred = false;
|
||||
} else if (const auto large = _photoMedia->image(PhotoSize::Large)) {
|
||||
_thumbnail = large->pixSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, ImageRoundRadius::Small);
|
||||
_thumbnailBlurred = false;
|
||||
} else if (const auto small = _photoMedia->image(PhotoSize::Small)) {
|
||||
_thumbnail = small->pixSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, ImageRoundRadius::Small);
|
||||
_thumbnailBlurred = false;
|
||||
} else if (const auto blurred = _photoMedia->thumbnailInline()) {
|
||||
_thumbnail = blurred->pixBlurredSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, ImageRoundRadius::Small);
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -1644,14 +1647,20 @@ void Link::validateThumbnail() {
|
|||
delegate()->unregisterHeavyItem(this);
|
||||
} else if (_page && _page->document && _page->document->hasThumbnail()) {
|
||||
ensureDocumentMediaCreated();
|
||||
const auto roundRadius = _page->document->isVideoMessage()
|
||||
? ImageRoundRadius::Ellipse
|
||||
: ImageRoundRadius::Small;
|
||||
if (const auto thumbnail = _documentMedia->thumbnail()) {
|
||||
auto roundRadius = _page->document->isVideoMessage()
|
||||
? ImageRoundRadius::Ellipse
|
||||
: ImageRoundRadius::Small;
|
||||
_thumbnail = thumbnail->pixSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, roundRadius);
|
||||
_documentMedia = nullptr;
|
||||
delegate()->unregisterHeavyItem(this);
|
||||
_thumbnailBlurred = false;
|
||||
} else if (const auto blurred = _documentMedia->thumbnailInline()) {
|
||||
_thumbnail = blurred->pixBlurredSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, roundRadius);
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
_documentMedia = nullptr;
|
||||
delegate()->unregisterHeavyItem(this);
|
||||
} else {
|
||||
const auto size = QSize(st::linksPhotoSize, st::linksPhotoSize);
|
||||
_thumbnail = QPixmap(size * cIntRetinaFactor());
|
||||
|
@ -1683,6 +1692,7 @@ void Link::validateThumbnail() {
|
|||
_letter,
|
||||
style::al_center);
|
||||
}
|
||||
_thumbnailBlurred = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -368,6 +368,7 @@ private:
|
|||
int _pixh = 0;
|
||||
Ui::Text::String _text = { st::msgMinWidth };
|
||||
QPixmap _thumbnail;
|
||||
bool _thumbnailBlurred = true;
|
||||
|
||||
struct LinkEntry {
|
||||
LinkEntry() : width(0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue