summaryrefslogtreecommitdiff
path: root/src/websnap.cpp
diff options
context:
space:
mode:
authormegabigbug <megabigbug@arrakis.(none)>2009-10-25 14:49:13 +0100
committermegabigbug <megabigbug@arrakis.(none)>2009-10-25 14:49:13 +0100
commitee95b665f335c966c80335c94a934d7a69b02be0 (patch)
treead49963121a49e2da900a28fc47a3a2390508899 /src/websnap.cpp
parentFixing "Global" vs "standard" shortcuts. (diff)
downloadrekonq-ee95b665f335c966c80335c94a934d7a69b02be0.tar.xz
A better preview implementation:
WebSnap doesn't render borders/background => borders/background not cached => style can be actualized easily. PreviewImage uses a label for display the background and an other label inside for display preview or animation.
Diffstat (limited to 'src/websnap.cpp')
-rw-r--r--src/websnap.cpp30
1 files changed, 3 insertions, 27 deletions
diff --git a/src/websnap.cpp b/src/websnap.cpp
index bb2baf49..7dcbb836 100644
--- a/src/websnap.cpp
+++ b/src/websnap.cpp
@@ -74,7 +74,7 @@ void WebSnap::load()
}
-QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h, bool border)
+QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h)
{
// prepare page
page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); // Why it doesn't work with one setScrollBarPolicy?
@@ -111,31 +111,7 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h, bool border)
page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded);
page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded);
- if(!border)
- return QPixmap::fromImage(pageImage);
-
- // background image
- QSize fixedSize(w + 30, h + 26);
- QImage backImage = QImage(fixedSize, QImage::Format_ARGB32_Premultiplied);
- QString backImagePath = KStandardDirs::locate("appdata", "pics/bg.png");
- backImage.load( backImagePath );
-
- // create target
- QImage resultImage = QImage(fixedSize, QImage::Format_ARGB32_Premultiplied);
- resultImage.fill(Qt::transparent);
-
- QPainter pt(&resultImage);
- pt.setCompositionMode(QPainter::CompositionMode_Source);
- pt.fillRect(resultImage.rect(), Qt::transparent);
- pt.setCompositionMode(QPainter::CompositionMode_SourceOver);
- pt.drawImage(0, 0, backImage);
- pt.setCompositionMode(QPainter::CompositionMode_SourceOver);
- pt.drawImage(15, 13, pageImage);
- pt.setCompositionMode(QPainter::CompositionMode_DestinationOver);
- pt.fillRect(resultImage.rect(), Qt::transparent);
- pt.end();
-
- return QPixmap::fromImage(resultImage);
+ return QPixmap::fromImage(pageImage);
}
@@ -148,7 +124,7 @@ void WebSnap::saveResult(bool ok)
return;
}
- m_image = renderPreview(m_page, WIDTH, HEIGHT, true);
+ m_image = renderPreview(m_page, WIDTH, HEIGHT);
emit finished();
}