From d3b9b304f3b29c4f31a2eac47ec97f6ce180e9b8 Mon Sep 17 00:00:00 2001 From: Joe Ferris Date: Fri, 12 Aug 2011 15:49:40 -0400 Subject: [PATCH] Extract method --- src/WebPage.cpp | 21 +++++++++++++-------- src/WebPage.h | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/WebPage.cpp b/src/WebPage.cpp index 7dae7d6..e14d3b4 100644 --- a/src/WebPage.cpp +++ b/src/WebPage.cpp @@ -5,6 +5,19 @@ #include WebPage::WebPage(QObject *parent) : QWebPage(parent) { + loadJavascript(); + + m_loading = false; + + this->setNetworkAccessManager(new NetworkAccessManager()); + + connect(this, SIGNAL(loadStarted()), this, SLOT(loadStarted())); + connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); + connect(this, SIGNAL(frameCreated(QWebFrame *)), + this, SLOT(frameCreated(QWebFrame *))); +} + +void WebPage::loadJavascript() { QResource javascript(":/capybara.js"); if (javascript.isCompressed()) { QByteArray uncompressedBytes(qUncompress(javascript.data(), javascript.size())); @@ -15,14 +28,6 @@ WebPage::WebPage(QObject *parent) : QWebPage(parent) { javascriptString[javascript.size()] = 0; m_capybaraJavascript = javascriptString; } - m_loading = false; - - this->setNetworkAccessManager(new NetworkAccessManager()); - - connect(this, SIGNAL(loadStarted()), this, SLOT(loadStarted())); - connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); - connect(this, SIGNAL(frameCreated(QWebFrame *)), - this, SLOT(frameCreated(QWebFrame *))); } QString WebPage::userAgentForUrl(const QUrl &url ) const { diff --git a/src/WebPage.h b/src/WebPage.h index 565f2f9..ff3b775 100644 --- a/src/WebPage.h +++ b/src/WebPage.h @@ -33,5 +33,6 @@ class WebPage : public QWebPage { QString m_userAgent; bool m_loading; QString getLastAttachedFileName(); + void loadJavascript(); };