Skip to content
Browse files

Extract method

  • Loading branch information...
1 parent 612028d commit d3b9b304f3b29c4f31a2eac47ec97f6ce180e9b8 @jferris jferris committed
Showing with 14 additions and 8 deletions.
  1. +13 −8 src/WebPage.cpp
  2. +1 −0 src/WebPage.h
View
21 src/WebPage.cpp
@@ -5,6 +5,19 @@
#include <iostream>
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 {
View
1 src/WebPage.h
@@ -33,5 +33,6 @@ class WebPage : public QWebPage {
QString m_userAgent;
bool m_loading;
QString getLastAttachedFileName();
+ void loadJavascript();
};

0 comments on commit d3b9b30

Please sign in to comment.
Something went wrong with that request. Please try again.