summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tabbar.cpp2
-rw-r--r--src/webpage.cpp9
-rw-r--r--src/websnap.cpp29
-rw-r--r--src/websnap.h3
4 files changed, 18 insertions, 25 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/webpage.cpp b/src/webpage.cpp
index 94a4bb48..32b785b4 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -46,7 +46,6 @@
#include "networkaccessmanager.h"
#include "adblockmanager.h"
#include "urlbar.h"
-#include "websnap.h"
#include "sslinfodialog_p.h"
@@ -408,6 +407,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
if (!isLocal)
{
+
KParts::BrowserOpenOrSaveQuestion dlg(Application::instance()->mainWindow(), replyUrl, mimeType);
if(!suggestedFileName.isEmpty())
dlg.setSuggestedFileName(suggestedFileName);
@@ -466,6 +466,8 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
void WebPage::loadFinished(bool ok)
{
+ Q_UNUSED(ok);
+
Application::adblockManager()->applyHidingRules(this);
QStringList list = ReKonfig::walletBlackList();
@@ -477,11 +479,6 @@ void WebPage::loadFinished(bool ok)
{
wallet()->fillFormData(mainFrame());
}
-
- if(ok)
- {
- WebSnap::renderPreview(*this);
- }
}
diff --git a/src/websnap.cpp b/src/websnap.cpp
index 0f2dc7b9..03bdb544 100644
--- a/src/websnap.cpp
+++ b/src/websnap.cpp
@@ -81,16 +81,10 @@ 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
- // and this is affecting tabbed browsing
-
// prepare page
QSize oldSize = page.viewportSize();
-// page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
-// page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
// find the best size
QSize size;
@@ -108,23 +102,24 @@ QPixmap WebSnap::renderPreview(const QWebPage &page, int w, int h)
// render it
QPainter p(&pageImage);
- page.mainFrame()->render(&p);
+ page.mainFrame()->render(&p, QWebFrame::ContentsLayer);
p.end();
pageImage = pageImage.scaled(w, h, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
// restore page settings
-// page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded);
-// page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded);
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