diff options
Diffstat (limited to 'src/websnap.cpp')
-rw-r--r-- | src/websnap.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
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; } |