From 7800e131b954ef646fb4db073eb9d09a677b09b9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 18 Jun 2010 17:22:04 +0200 Subject: No more save tab previews as they are everytime computed again.. --- src/tabbar.cpp | 2 +- src/websnap.cpp | 19 +++++++++++-------- src/websnap.h | 3 ++- 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 -- cgit v1.2.1