From bbc7308f4c60bce8144edae618f36a2b8da72417 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sat, 10 Apr 2021 20:16:00 +0200 Subject: BrowserTab: scale images only when they are bigger than the window Closes: #213 --- src/browsertab.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/browsertab.cpp b/src/browsertab.cpp index 8541730..88ccc91 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -720,8 +720,12 @@ void BrowserTab::renderPage(const QByteArray &data, const MimeType &mime) this->ui->graphics_browser->setScene(&graphics_scene); - connect(&graphics_scene, &QGraphicsScene::changed, this, [this]() { - this->ui->graphics_browser->fitInView(graphics_scene.sceneRect(), Qt::KeepAspectRatio); + connect(&graphics_scene, &QGraphicsScene::changed, this, [=]() { + QSize imageSize = pixmap.size(); + QSize browserSize = this->ui->graphics_browser->sizeHint(); + + if (imageSize.width() > browserSize.width() || imageSize.height() > browserSize.height()) + this->ui->graphics_browser->fitInView(graphics_scene.sceneRect(), Qt::KeepAspectRatio); }); will_cache = false; -- cgit v1.2.3