aboutsummaryrefslogtreecommitdiff
path: root/src/browsertab.cpp
diff options
context:
space:
mode:
authorKarol Kosek <krkk@krkk.ct8.pl>2021-04-10 20:00:45 +0200
committerFelix Queißner <felix@ib-queissner.de>2021-04-10 22:58:25 +0200
commitc6b7ef61af9f4c7e141c1960dff085e9948d8637 (patch)
treee3c241fb2e407297c61c805fe8792f2c3c523fb3 /src/browsertab.cpp
parent7074170f69fdf8b4d41954ab42d48fea971293b3 (diff)
downloadkristall-c6b7ef61af9f4c7e141c1960dff085e9948d8637.tar.gz
BrowserTab: simplify image loading
Diffstat (limited to 'src/browsertab.cpp')
-rw-r--r--src/browsertab.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp
index 368a179..8541730 100644
--- a/src/browsertab.cpp
+++ b/src/browsertab.cpp
@@ -707,10 +707,9 @@ void BrowserTab::renderPage(const QByteArray &data, const MimeType &mime)
reader.setAutoTransform(true);
reader.setAutoDetectImageFormat(true);
- QImage img;
- if (reader.read(&img))
+ auto pixmap = QPixmap::fromImageReader(&reader);
+ if (!pixmap.isNull())
{
- auto pixmap = QPixmap::fromImage(img);
this->graphics_scene.addPixmap(pixmap);
this->graphics_scene.setSceneRect(pixmap.rect());
}
@@ -721,13 +720,9 @@ void BrowserTab::renderPage(const QByteArray &data, const MimeType &mime)
this->ui->graphics_browser->setScene(&graphics_scene);
- auto *invoker = new QObject();
- connect(invoker, &QObject::destroyed, [this]() {
+ connect(&graphics_scene, &QGraphicsScene::changed, this, [this]() {
this->ui->graphics_browser->fitInView(graphics_scene.sceneRect(), Qt::KeepAspectRatio);
});
- invoker->deleteLater();
-
- this->ui->graphics_browser->fitInView(graphics_scene.sceneRect(), Qt::KeepAspectRatio);
will_cache = false;
}