summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-03-05 01:21:58 +0100
committerAndrea Diamantini <adjam7@gmail.com>2010-03-05 01:21:58 +0100
commit984526692fa8d8b77f4cc026a2f527a974e403c0 (patch)
tree6f9c51459adacebda29bb82597cbba5effabe4d8 /src
parentFixing recover on crash (diff)
downloadrekonq-984526692fa8d8b77f4cc026a2f527a974e403c0.tar.xz
Cleaning websnaps code..
Diffstat (limited to 'src')
-rw-r--r--src/rekonqpage/newtabpage.cpp2
-rw-r--r--src/websnap.cpp26
-rw-r--r--src/websnap.h4
3 files changed, 12 insertions, 20 deletions
diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp
index cc8aa1fb..3cd79326 100644
--- a/src/rekonqpage/newtabpage.cpp
+++ b/src/rekonqpage/newtabpage.cpp
@@ -183,7 +183,7 @@ QWebElement NewTabPage::loadingPreview(int index, KUrl url)
setupPreview(prev, index);
showControls(prev);
- new WebSnap(url, m_root.webFrame()->page(), index);
+ new WebSnap(url, m_root.webFrame(), index);
return prev;
}
diff --git a/src/websnap.cpp b/src/websnap.cpp
index 6310c868..2916418b 100644
--- a/src/websnap.cpp
+++ b/src/websnap.cpp
@@ -46,13 +46,12 @@
#include <QFile>
-WebSnap::WebSnap(const QUrl& url, QWebPage* originatingPage, int previewIndex)
+WebSnap::WebSnap(const QUrl& url, QWebFrame *frame, int index)
: QObject()
+ , m_url(url)
+ , m_frame(frame)
+ , m_previewIndex(index)
{
- m_url = url;
- m_originatingPage = originatingPage;
- m_previewIndex = previewIndex;
-
// this to not register websnap history
m_page.settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
@@ -76,14 +75,12 @@ void WebSnap::load()
}
-QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h)
+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?
- page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); // bug in qtwebkit ?
- page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
+ page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
-
+
// find the best size
QSize size;
int width = page.mainFrame()->contentsSize().width();
@@ -102,8 +99,6 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h)
// restore page settings
page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded);
- page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded);
- page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded);
page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded);
return QPixmap::fromImage(pageImage);
@@ -120,8 +115,7 @@ void WebSnap::savePreview(QPixmap pm, KUrl url)
KUrl WebSnap::fileForUrl(KUrl url)
{
- QString filePath =
- KStandardDirs::locateLocal("cache", QString("thumbs/") + WebSnap::guessNameFromUrl(url) + ".png", true);
+ QString filePath = KStandardDirs::locateLocal("cache", QString("thumbs/") + WebSnap::guessNameFromUrl(url) + ".png", true);
return KUrl(filePath);
}
@@ -162,15 +156,13 @@ void WebSnap::saveResult(bool ok)
QFile::remove(fileForUrl(m_url).toLocalFile());
m_image.save(fileForUrl(m_url).toLocalFile());
- //m_originatingPage->mainFrame()->load(KUrl("about:preview/replace/" + QVariant(m_previewIndex).toString()));
- NewTabPage p(m_originatingPage->mainFrame());
+ NewTabPage p( m_frame );
p.snapFinished(m_previewIndex, m_url, m_snapTitle);
deleteLater();
}
-
QString WebSnap::snapTitle()
{
return m_page.mainFrame()->title();
diff --git a/src/websnap.h b/src/websnap.h
index 54f63503..49b60769 100644
--- a/src/websnap.h
+++ b/src/websnap.h
@@ -55,7 +55,7 @@ class REKONQ_TESTS_EXPORT WebSnap : public QObject
Q_OBJECT
public:
- WebSnap(const QUrl &url, QWebPage *originatingPage, int previewIndex);
+ WebSnap(const QUrl &url, QWebFrame *frame, int index);
~WebSnap();
QPixmap previewImage(); // TODO : remove
@@ -82,7 +82,7 @@ private:
QUrl m_url;
QString m_snapTitle;
- QWebPage *m_originatingPage;
+ QWebFrame *m_frame;
int m_previewIndex;
};