WebPage::WebPage(WebPageManager *manager, QObject *parent) : QWebPage(parent) { m_loading = false; m_manager = manager; m_uuid = QUuid::createUuid().toString(); m_lastStatus = 0; setForwardUnsupportedContent(true); loadJavascript(); setUserStylesheet(); this->setCustomNetworkAccessManager(); 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 *))); connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(handleUnsupportedContent(QNetworkReply*))); connect(this, SIGNAL(pageFinished(bool)), m_manager, SLOT(emitPageFinished(bool))); connect(this, SIGNAL(loadStarted()), m_manager, SLOT(emitLoadStarted())); resetWindowSize(); settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); }
WebPage *WebPageManager::createPage() { WebPage *page = new WebPage(this); connect(page, SIGNAL(loadStarted()), this, SLOT(emitLoadStarted())); connect(page, SIGNAL(pageFinished(bool)), this, SLOT(setPageStatus(bool))); connect(page, SIGNAL(requestCreated(QByteArray &, QNetworkReply *)), this, SLOT(requestCreated(QByteArray &, QNetworkReply *))); append(page); return page; }