aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKarol Kosek <krkk@krkk.ct8.pl>2021-04-10 20:16:00 +0200
committerFelix Queißner <felix@ib-queissner.de>2021-04-10 22:58:25 +0200
commitbbc7308f4c60bce8144edae618f36a2b8da72417 (patch)
treeee89ced3db83d3c676ce86ea8db79c65c6c21f6b /src
parentc6b7ef61af9f4c7e141c1960dff085e9948d8637 (diff)
BrowserTab: scale images only when they are bigger than the window
Closes: #213
Diffstat (limited to 'src')
-rw-r--r--src/browsertab.cpp8
1 files changed, 6 insertions, 2 deletions
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;