summaryrefslogtreecommitdiffstats
path: root/examples/webkit
diff options
context:
space:
mode:
authorAndre Pedralho <andre.pedralho@openbossa.org>2009-11-19 16:15:39 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-11-19 16:15:39 (GMT)
commit45e49fc7a325855c6eafa83b85f5ddfdf793c118 (patch)
treec6fa331dd3990529264a7cd294408dc5a1d86c41 /examples/webkit
parent34dbd7b720875e4e266beee66f6f41e624ea5aad (diff)
downloadQt-45e49fc7a325855c6eafa83b85f5ddfdf793c118.zip
Qt-45e49fc7a325855c6eafa83b85f5ddfdf793c118.tar.gz
Qt-45e49fc7a325855c6eafa83b85f5ddfdf793c118.tar.bz2
Fixing the frame hierarchy traversing in framecapture WebKit example.
Merge-request: 2142 Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
Diffstat (limited to 'examples/webkit')
-rw-r--r--examples/webkit/framecapture/framecapture.cpp37
-rw-r--r--examples/webkit/framecapture/framecapture.h2
2 files changed, 18 insertions, 21 deletions
diff --git a/examples/webkit/framecapture/framecapture.cpp b/examples/webkit/framecapture/framecapture.cpp
index 4636b8d..ef49e93 100644
--- a/examples/webkit/framecapture/framecapture.cpp
+++ b/examples/webkit/framecapture/framecapture.cpp
@@ -82,39 +82,36 @@ void FrameCapture::saveResult(bool ok)
return;
}
- // save each internal frame in different image files
- int frameCounter = 0;
- foreach(QWebFrame *frame, m_page.mainFrame()->childFrames()) {
- QString fileName(m_fileName);
- int index = m_fileName.lastIndexOf('.');
- fileName = fileName.insert(index, "_frame" + QString::number(++frameCounter));
+ // save each frame in different image files
+ saveFrame(m_page.mainFrame());
- QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied);
- image.fill(Qt::transparent);
+ emit finished();
+}
- saveFrame(frame, image, fileName);
+void FrameCapture::saveFrame(QWebFrame *frame)
+{
+ static int frameCounter = 0;
+
+ QString fileName(m_fileName);
+ if (frameCounter) {
+ int index = m_fileName.lastIndexOf('.');
+ fileName = fileName.insert(index, "_frame" + QString::number(frameCounter));
}
- // save the main frame
- m_page.setViewportSize(m_page.mainFrame()->contentsSize());
- QImage image(m_page.mainFrame()->contentsSize(), QImage::Format_ARGB32_Premultiplied);
+ QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::transparent);
- saveFrame(m_page.mainFrame(), image, m_fileName);
- emit finished();
-}
-
-void FrameCapture::saveFrame(QWebFrame *frame, QImage image, QString fileName)
-{
QPainter painter(&image);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setRenderHint(QPainter::TextAntialiasing, true);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
-
frame->documentElement().render(&painter);
-
painter.end();
image.save(fileName);
+
+ ++frameCounter;
+ foreach(QWebFrame *childFrame, frame->childFrames())
+ saveFrame(childFrame);
}
diff --git a/examples/webkit/framecapture/framecapture.h b/examples/webkit/framecapture/framecapture.h
index 9de9c43..7a6d5f3 100644
--- a/examples/webkit/framecapture/framecapture.h
+++ b/examples/webkit/framecapture/framecapture.h
@@ -64,7 +64,7 @@ private:
QString m_fileName;
int m_percent;
- void saveFrame(QWebFrame *frame, QImage image, QString fileName);
+ void saveFrame(QWebFrame *frame);
};
#endif