summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tabbar.cpp2
-rw-r--r--src/websnap.cpp19
-rw-r--r--src/websnap.h3
3 files changed, 14 insertions, 10 deletions
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
index a1bbf2b8..f3584eed 100644
--- a/src/tabbar.cpp
+++ b/src/tabbar.cpp
@@ -181,7 +181,7 @@ void TabBar::showTabPreview()
m_previewPopup.data()->setFixedSize(w, h);
QLabel *l = new QLabel();
- l->setPixmap(WebSnap::renderPreview(*indexedTab->page(), w, h));
+ l->setPixmap( WebSnap::renderPreview(*indexedTab->page(), w, h, false) );
m_previewPopup.data()->setView(l);
m_previewPopup.data()->layout()->setAlignment(Qt::AlignTop);
diff --git a/src/websnap.cpp b/src/websnap.cpp
index 0f2dc7b9..b85e5da8 100644
--- a/src/websnap.cpp
+++ b/src/websnap.cpp
@@ -81,7 +81,7 @@ void WebSnap::load()
// NOTE please, be careful modifying this.
// You are playing with fire..
-QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h)
+QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h, bool save)
{
// NOTE
// it seems no way to enable/disable scrollbars in new QtWebKit's
@@ -118,13 +118,16 @@ QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h)
page.setViewportSize(oldSize);
QPixmap pm = QPixmap::fromImage(pageImage);
- KUrl url(page.mainFrame()->url());
- kDebug() << "saving preview";
-
- QString path = imagePathFromUrl(url);
- QFile::remove(path);
- pm.save(path);
-
+
+ if(save)
+ {
+ KUrl url(page.mainFrame()->url());
+ kDebug() << "saving preview";
+ QString path = imagePathFromUrl(url);
+ QFile::remove(path);
+ pm.save(path);
+ }
+
return pm;
}
diff --git a/src/websnap.h b/src/websnap.h
index 03d63746..cfc2c83e 100644
--- a/src/websnap.h
+++ b/src/websnap.h
@@ -85,10 +85,11 @@ public:
* @param page the page to snap
* @param w the image width
* @param h the image height
+ * @param save decide to save or not the preview on cache
*
* @return the pixmap snapped from the page
*/
- static QPixmap renderPreview(const QWebPage &page, int w = WIDTH, int h = HEIGHT);
+ static QPixmap renderPreview(const QWebPage &page, int w = WIDTH, int h = HEIGHT, bool save = true);
/**
* Guess the local path where the image for the url provided