ImageView LOD patch

This commit is contained in:
2021-06-23 23:02:53 +03:00
parent d175e05e16
commit 3f7306cea6

View File

@@ -126,18 +126,22 @@ bool ImageView::eventFilter(QObject * o, QEvent * e) {
void ImageView::adjustView() {
int nw = map.size().boundedTo(size()).width();
item.setScale(1.);
if (nw > 0) {
qreal mp = map.width() / nw;
if (mp > 1.)
if (mp > 1.) {
QSize ss = map.size();
item.setPixmap(map.scaled(map.size() / mp, Qt::KeepAspectRatio, Qt::SmoothTransformation));
else
item.setScale(double(ss.width()) / item.pixmap().width());
} else
item.setPixmap(map);
} else
item.setPixmap(map);
if (!autofit_) return;
setSceneRect(item.boundingRect());
fitInView(&item, Qt::KeepAspectRatio);
centerOn(&item);
QRectF r = item.mapRectToScene(item.boundingRect());
setSceneRect(r);
fitInView(r, Qt::KeepAspectRatio);
centerOn(r.center());
}