diff options
author | ninerider <qt-info@nokia.com> | 2009-11-23 12:28:19 (GMT) |
---|---|---|
committer | ninerider <qt-info@nokia.com> | 2009-11-23 12:28:19 (GMT) |
commit | 4cfc3a884835667fe8c3a6aa745dc4ace34794e4 (patch) | |
tree | 553a33b8112750d1d2dd7dc503c9c70391538b07 /examples | |
parent | cda63c368dbb5acd040e2190db8f25de69462d8e (diff) | |
parent | 4112771f56e827d1d8fbde0995ebf5b0242c01a8 (diff) | |
download | Qt-4cfc3a884835667fe8c3a6aa745dc4ace34794e4.zip Qt-4cfc3a884835667fe8c3a6aa745dc4ace34794e4.tar.gz Qt-4cfc3a884835667fe8c3a6aa745dc4ace34794e4.tar.bz2 |
Merge remote branch 'origin/4.6' into 4.6-ce
Diffstat (limited to 'examples')
-rw-r--r-- | examples/webkit/framecapture/framecapture.cpp | 40 | ||||
-rw-r--r-- | examples/webkit/framecapture/framecapture.h | 2 | ||||
-rw-r--r-- | examples/webkit/framecapture/main.cpp | 2 |
3 files changed, 20 insertions, 24 deletions
diff --git a/examples/webkit/framecapture/framecapture.cpp b/examples/webkit/framecapture/framecapture.cpp index 2c2e11b..ef49e93 100644 --- a/examples/webkit/framecapture/framecapture.cpp +++ b/examples/webkit/framecapture/framecapture.cpp @@ -59,6 +59,7 @@ void FrameCapture::load(const QUrl &url, const QString &outputFileName) m_page.mainFrame()->load(url); m_page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); m_page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + m_page.setViewportSize(QSize(1024, 768)); } void FrameCapture::printProgress(int percent) @@ -81,41 +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()); - frame->setClipRenderToViewport(false); + emit finished(); +} - QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied); - image.fill(Qt::transparent); +void FrameCapture::saveFrame(QWebFrame *frame) +{ + static int frameCounter = 0; - saveFrame(frame, image, fileName); + 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->render(&painter); - + 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 diff --git a/examples/webkit/framecapture/main.cpp b/examples/webkit/framecapture/main.cpp index 050947a..65c0026 100644 --- a/examples/webkit/framecapture/main.cpp +++ b/examples/webkit/framecapture/main.cpp @@ -63,7 +63,7 @@ int main(int argc, char * argv[]) return 0; } - QUrl url = QWebView::guessUrlFromString(QString::fromLatin1(argv[1])); + QUrl url = QUrl::fromUserInput(QString::fromLatin1(argv[1])); QString fileName = QString::fromLatin1(argv[2]); QApplication a(argc, argv); |