summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLionel Chauvin <megabigbug@yahoo.fr>2011-01-19 22:25:03 +0100
committerAndrea Diamantini <adjam7@gmail.com>2011-01-19 22:25:03 +0100
commit966f6f99a3a2e89f6974bfee05886b8499385992 (patch)
treefe419a5a321a812aeac51630da6381a7d7c363f4 /src
parentUpdating AUTHORS list. (diff)
downloadrekonq-966f6f99a3a2e89f6974bfee05886b8499385992.tar.xz
Save downloaded images of opensearch suggestions like websnaps
RB:100397 Reviewed by me ;)
Diffstat (limited to 'src')
-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: