mirror of https://github.com/procxx/kepka.git
Fix photos in overview with disabled autodownload.
Fixes #5599, fixes #5747.
This commit is contained in:
parent
5c3f667fc3
commit
ef682e7023
|
@ -1249,9 +1249,7 @@ void OverlayWidget::onCopy() {
|
||||||
} else if (!_current.isNull()) {
|
} else if (!_current.isNull()) {
|
||||||
QApplication::clipboard()->setPixmap(_current);
|
QApplication::clipboard()->setPixmap(_current);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (_photo && _photo->loaded()) {
|
||||||
if (!_photo || !_photo->loaded()) return;
|
|
||||||
|
|
||||||
QApplication::clipboard()->setPixmap(_photo->large()->pix(fileOrigin()));
|
QApplication::clipboard()->setPixmap(_photo->large()->pix(fileOrigin()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2385,7 +2383,6 @@ void OverlayWidget::validatePhotoCurrentImage() {
|
||||||
validatePhotoImage(_photo->thumbnailInline(), true);
|
validatePhotoImage(_photo->thumbnailInline(), true);
|
||||||
if (_current.isNull()) {
|
if (_current.isNull()) {
|
||||||
_photo->loadThumbnailSmall(fileOrigin());
|
_photo->loadThumbnailSmall(fileOrigin());
|
||||||
validatePhotoImage(Image::Empty(), true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2426,15 +2423,14 @@ void OverlayWidget::paintEvent(QPaintEvent *e) {
|
||||||
if (rect.intersects(r)) {
|
if (rect.intersects(r)) {
|
||||||
if (videoShown()) {
|
if (videoShown()) {
|
||||||
paintTransformedVideoFrame(p);
|
paintTransformedVideoFrame(p);
|
||||||
} else if (!_current.isNull()) {
|
} else {
|
||||||
if ((!_doc || !_doc->getStickerLarge()) && _current.hasAlpha()) {
|
if ((!_doc || !_doc->getStickerLarge())
|
||||||
|
&& (_current.isNull() || _current.hasAlpha())) {
|
||||||
p.fillRect(rect, _transparentBrush);
|
p.fillRect(rect, _transparentBrush);
|
||||||
}
|
}
|
||||||
if (_current.width() != _w * cIntRetinaFactor()) {
|
if (!_current.isNull()) {
|
||||||
PainterHighQualityEnabler hq(p);
|
PainterHighQualityEnabler hq(p);
|
||||||
p.drawPixmap(rect, _current);
|
p.drawPixmap(rect, _current);
|
||||||
} else {
|
|
||||||
p.drawPixmap(rect.topLeft(), _current);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2670,7 +2666,6 @@ void OverlayWidget::paintTransformedVideoFrame(Painter &p) {
|
||||||
// const auto fill = rect.intersected(this->rect());
|
// const auto fill = rect.intersected(this->rect());
|
||||||
// PaintImageProfile(p, image, rect, fill);
|
// PaintImageProfile(p, image, rect, fill);
|
||||||
//} else {
|
//} else {
|
||||||
PainterHighQualityEnabler hq(p);
|
|
||||||
const auto rotation = _streamed->info.video.rotation;
|
const auto rotation = _streamed->info.video.rotation;
|
||||||
const auto rotated = [](QRect rect, int rotation) {
|
const auto rotated = [](QRect rect, int rotation) {
|
||||||
switch (rotation) {
|
switch (rotation) {
|
||||||
|
@ -2693,6 +2688,8 @@ void OverlayWidget::paintTransformedVideoFrame(Painter &p) {
|
||||||
}
|
}
|
||||||
Unexpected("Rotation in OverlayWidget::paintTransformedVideoFrame");
|
Unexpected("Rotation in OverlayWidget::paintTransformedVideoFrame");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PainterHighQualityEnabler hq(p);
|
||||||
if (rotation) {
|
if (rotation) {
|
||||||
p.save();
|
p.save();
|
||||||
p.rotate(rotation);
|
p.rotate(rotation);
|
||||||
|
@ -2947,7 +2944,7 @@ void OverlayWidget::setZoomLevel(int newZoom) {
|
||||||
float64 nx, ny, z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom;
|
float64 nx, ny, z = (_zoom == ZoomToScreenLevel) ? _zoomToScreen : _zoom;
|
||||||
const auto contentSize = videoShown()
|
const auto contentSize = videoShown()
|
||||||
? ConvertScale(videoSize())
|
? ConvertScale(videoSize())
|
||||||
: ConvertScale(_current.size() / cIntRetinaFactor());
|
: QSize(_width, _height);
|
||||||
_w = contentSize.width();
|
_w = contentSize.width();
|
||||||
_h = contentSize.height();
|
_h = contentSize.height();
|
||||||
if (z >= 0) {
|
if (z >= 0) {
|
||||||
|
|
|
@ -292,6 +292,9 @@ Photo::Photo(
|
||||||
: ItemBase(parent)
|
: ItemBase(parent)
|
||||||
, _data(photo)
|
, _data(photo)
|
||||||
, _link(std::make_shared<PhotoOpenClickHandler>(photo, parent->fullId())) {
|
, _link(std::make_shared<PhotoOpenClickHandler>(photo, parent->fullId())) {
|
||||||
|
if (!_data->thumbnailInline()) {
|
||||||
|
_data->loadThumbnailSmall(parent->fullId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Photo::initDimensions() {
|
void Photo::initDimensions() {
|
||||||
|
@ -328,6 +331,8 @@ void Photo::paint(Painter &p, const QRect &clip, TextSelection selection, const
|
||||||
if (blurred->loaded()) {
|
if (blurred->loaded()) {
|
||||||
setPixFrom(blurred);
|
setPixFrom(blurred);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_data->loadThumbnailSmall(parent()->fullId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,7 +369,12 @@ void Photo::setPixFrom(not_null<Image*> image) {
|
||||||
img = img.copy(0, (img.height() - img.width()) / 2, img.width(), img.width()).scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
img = img.copy(0, (img.height() - img.width()) / 2, img.width(), img.width()).scaled(size, size, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
img.setDevicePixelRatio(cRetinaFactor());
|
img.setDevicePixelRatio(cRetinaFactor());
|
||||||
|
|
||||||
|
// In case we have inline thumbnail we can unload all images and we still
|
||||||
|
// won't get a blank image in the media viewer when the photo is opened.
|
||||||
|
if (_data->thumbnailInline() != nullptr) {
|
||||||
_data->unload();
|
_data->unload();
|
||||||
|
}
|
||||||
|
|
||||||
_pix = App::pixmapFromImageInPlace(std::move(img));
|
_pix = App::pixmapFromImageInPlace(std::move(img));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue