summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/urlbar/listitem.cpp23
-rw-r--r--src/urlbar/listitem.h3
2 files changed, 17 insertions, 9 deletions
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index f7514f2a..1794233e 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -365,15 +365,23 @@ PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *p
ImageLabel::ImageLabel(const QString &url, int width, int height, QWidget *parent)
: QLabel(parent),
- m_width(width),
- m_height(height)
+ m_url(url)
{
setFixedSize(width, height);
- KIO::TransferJob *job = KIO::get(KUrl(url), KIO::NoReload, KIO::HideProgressInfo);
- connect(job, SIGNAL(data(KIO::Job *, const QByteArray &)),
- this, SLOT(slotData(KIO::Job*, const QByteArray&)));
- connect(job, SIGNAL(result(KJob *)),
- this, SLOT(slotResult(KJob *)));
+ if (WebSnap::existsImage(KUrl(url)))
+ {
+ QPixmap pix;
+ pix.load(WebSnap::imagePathFromUrl(url));
+ setPixmap(pix);
+ }
+ else
+ {
+ KIO::TransferJob *job = KIO::get(KUrl(url), KIO::NoReload, KIO::HideProgressInfo);
+ connect(job, SIGNAL(data(KIO::Job *, const QByteArray &)),
+ this, SLOT(slotData(KIO::Job*, const QByteArray&)));
+ connect(job, SIGNAL(result(KJob *)),
+ this, SLOT(slotResult(KJob *)));
+ }
}
@@ -390,6 +398,7 @@ void ImageLabel::slotResult(KJob *)
if (!pix.loadFromData(m_data))
kDebug() << "error while loading image: ";
setPixmap(pix);
+ pix.save(WebSnap::imagePathFromUrl(m_url), "PNG");
}
diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h
index 30089ce9..0ad5ab38 100644
--- a/src/urlbar/listitem.h
+++ b/src/urlbar/listitem.h
@@ -254,8 +254,7 @@ public:
ImageLabel(const QString &url, int width, int height, QWidget *parent);
private:
- int m_width;
- int m_height;
+ QString m_url;
QByteArray m_data;
private slots: