mirror of https://github.com/procxx/kepka.git
Fix photo edit caption box, remove 's' size.
This commit is contained in:
parent
af0eebb6f1
commit
74ef8104a7
|
@ -80,7 +80,17 @@ EditCaptionBox::EditCaptionBox(
|
|||
_photoMedia = photo->createMediaView();
|
||||
_photoMedia->wanted(PhotoSize::Large, _msgId);
|
||||
image = _photoMedia->image(PhotoSize::Large);
|
||||
if (!image) {
|
||||
image = _photoMedia->image(PhotoSize::Thumbnail);
|
||||
if (!image) {
|
||||
image = _photoMedia->image(PhotoSize::Small);
|
||||
if (!image) {
|
||||
image = _photoMedia->thumbnailInline();
|
||||
}
|
||||
}
|
||||
}
|
||||
dimensions = _photoMedia->size(PhotoSize::Large);
|
||||
_photo = true;
|
||||
} else if (const auto document = media->document()) {
|
||||
_documentMedia = document->createMediaView();
|
||||
_documentMedia->thumbnailWanted(_msgId);
|
||||
|
@ -183,14 +193,23 @@ EditCaptionBox::EditCaptionBox(
|
|||
maxH = dimensions.height();
|
||||
_thumbnailImage = image;
|
||||
_refreshThumbnail = [=] {
|
||||
if (!_thumbnailImage) {
|
||||
return;
|
||||
}
|
||||
_thumb = _thumbnailImage->pixNoCache(
|
||||
const auto photo = _photoMedia
|
||||
? _photoMedia->image(Data::PhotoSize::Large)
|
||||
: nullptr;
|
||||
const auto use = photo
|
||||
? photo
|
||||
: _thumbnailImage
|
||||
? _thumbnailImage
|
||||
: Image::BlankMedia().get();
|
||||
const auto options = Images::Option::Smooth
|
||||
| ((_photoMedia && !photo)
|
||||
? Images::Option::Blurred
|
||||
: Images::Option(0));
|
||||
_thumb = use->pixNoCache(
|
||||
_msgId,
|
||||
maxW * cIntRetinaFactor(),
|
||||
maxH * cIntRetinaFactor(),
|
||||
Images::Option::Smooth,
|
||||
options,
|
||||
maxW,
|
||||
maxH);
|
||||
};
|
||||
|
@ -260,10 +279,10 @@ EditCaptionBox::EditCaptionBox(
|
|||
}
|
||||
Assert(_animated || _photo || _doc);
|
||||
|
||||
_thumbnailImageLoaded = _thumbnailImage
|
||||
_thumbnailImageLoaded = _photoMedia
|
||||
? _photoMedia->image(Data::PhotoSize::Large)
|
||||
: _thumbnailImage
|
||||
? _thumbnailImage->loaded()
|
||||
: _photoMedia
|
||||
? false
|
||||
: _documentMedia
|
||||
? !_documentMedia->owner()->hasThumbnail()
|
||||
: true;
|
||||
|
@ -271,7 +290,9 @@ EditCaptionBox::EditCaptionBox(
|
|||
subscribe(_controller->session().downloaderTaskFinished(), [=] {
|
||||
if (_thumbnailImageLoaded) {
|
||||
return;
|
||||
} else if (!_thumbnailImage && _photoMedia) {
|
||||
} else if (!_thumbnailImage
|
||||
&& _photoMedia
|
||||
&& _photoMedia->image(PhotoSize::Large)) {
|
||||
_thumbnailImage = _photoMedia->image(PhotoSize::Large);
|
||||
} else if (!_thumbnailImage
|
||||
&& _documentMedia
|
||||
|
@ -279,9 +300,12 @@ EditCaptionBox::EditCaptionBox(
|
|||
_thumbnailImage = _documentMedia->thumbnail();
|
||||
}
|
||||
if (_thumbnailImage && _thumbnailImage->loaded()) {
|
||||
_thumbnailImageLoaded = true;
|
||||
_refreshThumbnail();
|
||||
update();
|
||||
_thumbnailImageLoaded = !_photoMedia
|
||||
|| _photoMedia->image(PhotoSize::Large);
|
||||
if (_thumbnailImageLoaded) {
|
||||
_refreshThumbnail();
|
||||
update();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1125,7 +1125,6 @@ TextState Contact::getState(
|
|||
}
|
||||
|
||||
void Contact::prepareThumbnail(int width, int height) const {
|
||||
// #TODO optimize use photo / document thumbnail as well
|
||||
const auto thumb = getResultThumb();
|
||||
if (!thumb) {
|
||||
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
|
||||
|
@ -1215,7 +1214,6 @@ void Article::paint(Painter &p, const QRect &clip, const PaintContext *context)
|
|||
prepareThumbnail(st::inlineThumbSize, st::inlineThumbSize);
|
||||
QRect rthumb(style::rtlrect(0, st::inlineRowMargin, st::inlineThumbSize, st::inlineThumbSize, _width));
|
||||
if (_thumb.isNull()) {
|
||||
// #TODO optimize use photo / document thumbnail as well
|
||||
const auto thumb = getResultThumb();
|
||||
if (!thumb && !_thumbLetter.isEmpty()) {
|
||||
int32 index = (_thumbLetter.at(0).unicode() % 4);
|
||||
|
@ -1281,7 +1279,6 @@ TextState Article::getState(
|
|||
}
|
||||
|
||||
void Article::prepareThumbnail(int width, int height) const {
|
||||
// #TODO optimize use photo / document thumbnail as well
|
||||
const auto thumb = getResultThumb();
|
||||
if (!thumb) {
|
||||
if (_thumb.width() != width * cIntRetinaFactor() || _thumb.height() != height * cIntRetinaFactor()) {
|
||||
|
|
|
@ -853,10 +853,6 @@ void FileLoadTask::process() {
|
|||
} else if (isAnimation) {
|
||||
attributes.push_back(MTP_documentAttributeAnimated());
|
||||
} else if (_type != SendMediaType::File) {
|
||||
auto thumb = (w > 100 || h > 100) ? fullimage.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation) : fullimage;
|
||||
photoThumbs.emplace('s', thumb);
|
||||
photoSizes.push_back(MTP_photoSize(MTP_string("s"), MTP_fileLocationToBeDeprecated(MTP_long(0), MTP_int(0)), MTP_int(thumb.width()), MTP_int(thumb.height()), MTP_int(0)));
|
||||
|
||||
auto medium = (w > 320 || h > 320) ? fullimage.scaled(320, 320, Qt::KeepAspectRatio, Qt::SmoothTransformation) : fullimage;
|
||||
photoThumbs.emplace('m', medium);
|
||||
photoSizes.push_back(MTP_photoSize(MTP_string("m"), MTP_fileLocationToBeDeprecated(MTP_long(0), MTP_int(0)), MTP_int(medium.width()), MTP_int(medium.height()), MTP_int(0)));
|
||||
|
|
|
@ -378,6 +378,8 @@ struct PlainUrlLocation {
|
|||
};
|
||||
|
||||
struct InMemoryLocation {
|
||||
~InMemoryLocation() = default;
|
||||
|
||||
QByteArray bytes;
|
||||
|
||||
friend inline bool operator==(
|
||||
|
|
Loading…
Reference in New Issue