mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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;
|
int32 tw = 0, th = 0;
|
||||||
if (_page && _page->photo) {
|
if (_page && _page->photo) {
|
||||||
const auto photo = _page->photo;
|
const auto photo = _page->photo;
|
||||||
if (photo->inlineThumbnailBytes().isEmpty()
|
if (photo->hasExact(Data::PhotoSize::Small)
|
||||||
&& (photo->hasExact(Data::PhotoSize::Small)
|
|| photo->hasExact(Data::PhotoSize::Thumbnail)) {
|
||||||
|| photo->hasExact(Data::PhotoSize::Thumbnail))) {
|
|
||||||
photo->load(Data::PhotoSize::Small, parent->fullId());
|
photo->load(Data::PhotoSize::Small, parent->fullId());
|
||||||
}
|
}
|
||||||
tw = style::ConvertScale(photo->width());
|
tw = style::ConvertScale(photo->width());
|
||||||
|
@ -1623,7 +1622,7 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P
|
||||||
}
|
}
|
||||||
|
|
||||||
void Link::validateThumbnail() {
|
void Link::validateThumbnail() {
|
||||||
if (!_thumbnail.isNull()) {
|
if (!_thumbnail.isNull() && !_thumbnailBlurred) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_page && _page->photo) {
|
if (_page && _page->photo) {
|
||||||
|
@ -1631,12 +1630,16 @@ void Link::validateThumbnail() {
|
||||||
ensurePhotoMediaCreated();
|
ensurePhotoMediaCreated();
|
||||||
if (const auto thumbnail = _photoMedia->image(PhotoSize::Thumbnail)) {
|
if (const auto thumbnail = _photoMedia->image(PhotoSize::Thumbnail)) {
|
||||||
_thumbnail = thumbnail->pixSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, ImageRoundRadius::Small);
|
_thumbnail = thumbnail->pixSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, ImageRoundRadius::Small);
|
||||||
|
_thumbnailBlurred = false;
|
||||||
} else if (const auto large = _photoMedia->image(PhotoSize::Large)) {
|
} else if (const auto large = _photoMedia->image(PhotoSize::Large)) {
|
||||||
_thumbnail = large->pixSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, ImageRoundRadius::Small);
|
_thumbnail = large->pixSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, ImageRoundRadius::Small);
|
||||||
|
_thumbnailBlurred = false;
|
||||||
} else if (const auto small = _photoMedia->image(PhotoSize::Small)) {
|
} else if (const auto small = _photoMedia->image(PhotoSize::Small)) {
|
||||||
_thumbnail = small->pixSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, ImageRoundRadius::Small);
|
_thumbnail = small->pixSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, ImageRoundRadius::Small);
|
||||||
|
_thumbnailBlurred = false;
|
||||||
} else if (const auto blurred = _photoMedia->thumbnailInline()) {
|
} else if (const auto blurred = _photoMedia->thumbnailInline()) {
|
||||||
_thumbnail = blurred->pixBlurredSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, ImageRoundRadius::Small);
|
_thumbnail = blurred->pixBlurredSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, ImageRoundRadius::Small);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1644,14 +1647,20 @@ void Link::validateThumbnail() {
|
||||||
delegate()->unregisterHeavyItem(this);
|
delegate()->unregisterHeavyItem(this);
|
||||||
} else if (_page && _page->document && _page->document->hasThumbnail()) {
|
} else if (_page && _page->document && _page->document->hasThumbnail()) {
|
||||||
ensureDocumentMediaCreated();
|
ensureDocumentMediaCreated();
|
||||||
|
const auto roundRadius = _page->document->isVideoMessage()
|
||||||
|
? ImageRoundRadius::Ellipse
|
||||||
|
: ImageRoundRadius::Small;
|
||||||
if (const auto thumbnail = _documentMedia->thumbnail()) {
|
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);
|
_thumbnail = thumbnail->pixSingle(_pixw, _pixh, st::linksPhotoSize, st::linksPhotoSize, roundRadius);
|
||||||
_documentMedia = nullptr;
|
_thumbnailBlurred = false;
|
||||||
delegate()->unregisterHeavyItem(this);
|
} 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 {
|
} else {
|
||||||
const auto size = QSize(st::linksPhotoSize, st::linksPhotoSize);
|
const auto size = QSize(st::linksPhotoSize, st::linksPhotoSize);
|
||||||
_thumbnail = QPixmap(size * cIntRetinaFactor());
|
_thumbnail = QPixmap(size * cIntRetinaFactor());
|
||||||
|
@ -1683,6 +1692,7 @@ void Link::validateThumbnail() {
|
||||||
_letter,
|
_letter,
|
||||||
style::al_center);
|
style::al_center);
|
||||||
}
|
}
|
||||||
|
_thumbnailBlurred = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -368,6 +368,7 @@ private:
|
||||||
int _pixh = 0;
|
int _pixh = 0;
|
||||||
Ui::Text::String _text = { st::msgMinWidth };
|
Ui::Text::String _text = { st::msgMinWidth };
|
||||||
QPixmap _thumbnail;
|
QPixmap _thumbnail;
|
||||||
|
bool _thumbnailBlurred = true;
|
||||||
|
|
||||||
struct LinkEntry {
|
struct LinkEntry {
|
||||||
LinkEntry() : width(0) {
|
LinkEntry() : width(0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue