Skip to content

Commit

Permalink
Merge upstream changes that extract a method and disable custom fonts…
Browse files Browse the repository at this point in the history
… to avoid crashes on OS X.
  • Loading branch information
tristandunn committed Aug 16, 2011
1 parent c64385a commit 641297d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/WebPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
#include <iostream>

WebPage::WebPage(QObject *parent) : QWebPage(parent) {
loadJavascript();
setUserStylesheet();

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()));
Expand All @@ -15,14 +29,12 @@ 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 *)));
void WebPage::setUserStylesheet() {
QString data = QString("* { font-family: 'Arial' ! important; }").toUtf8().toBase64();
QUrl url = QUrl(QString("data:text/css;charset=utf-8;base64,") + data);
settings()->setUserStyleSheetUrl(url);
}

QString WebPage::userAgentForUrl(const QUrl &url ) const {
Expand Down
2 changes: 2 additions & 0 deletions src/WebPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ class WebPage : public QWebPage {
QString m_userAgent;
bool m_loading;
QString getLastAttachedFileName();
void loadJavascript();
void setUserStylesheet();
};

0 comments on commit 641297d

Please sign in to comment.