AWebView::AWebView(DownLoad *download, QWidget *parent) : m_downLoad(download) , QWebView(parent) { //Network proxy settings, enabled flash plugins QNetworkProxyFactory::setUseSystemConfiguration(true); QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true); //Add Cache m_ndCache = new QNetworkDiskCache(this); cacheLocation = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); m_ndCache->setCacheDirectory(cacheLocation); page()->networkAccessManager()->setCache(m_ndCache); //WebView signal and slot connect(this, SIGNAL(loadProgress(int)), SLOT(viewProgress(int))); connect(this, SIGNAL(loadFinished(bool)), SLOT(viewFinished(bool))); //The local slot function signal associated with webkit connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptObject())); //Related downloads, here set aside connect(m_downLoad, SIGNAL(on_clicked(QString)), this, SLOT(on_linkClicked(QString))); //The two link opens the page page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); connect(page(), SIGNAL(linkClicked(QUrl)), this, SLOT(on_linkPage(QUrl))); load(QUrl("http://api.83133.com/")); //load(QUrl("http://www.999.com/tool")); }
int GoogleMap::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWebView::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: mapItemClicked((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break; case 1: notifyMapTilesLoaded(); break; case 2: processMapAlert((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break; case 3: mapTilesLoaded(); break; case 4: setCenter((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2]))); break; case 5: addJavaScriptObject(); break; default: ; } _id -= 6; } return _id; }
WebPage::WebPage(QupZilla* mainClass) : QWebPage() , p_QupZilla(mainClass) , m_view(0) , m_speedDial(mApp->plugins()->speedDial()) , m_fileWatcher(0) , m_runningLoop(0) , m_blockAlerts(false) , m_secureStatus(false) , m_isClosing(false) { m_networkProxy = new NetworkManagerProxy(this); m_networkProxy->setPrimaryNetworkAccessManager(mApp->networkManager()); m_networkProxy->setPage(this); setNetworkAccessManager(m_networkProxy); setForwardUnsupportedContent(true); setPluginFactory(new WebPluginFactory(this)); history()->setMaximumItemCount(20); connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(handleUnsupportedContent(QNetworkReply*))); connect(this, SIGNAL(loadProgress(int)), this, SLOT(progress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(finished())); connect(this, SIGNAL(printRequested(QWebFrame*)), this, SLOT(printFrame(QWebFrame*))); connect(this, SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest))); connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptObject())); }
void MainWindow::preHtml() { ui->webView_Main->setHtml("<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />" "<center><img src=qrc:/toolButton/images/loading.gif /></center>"); QObject::disconnect(ui->webView_Main->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptObject())); }
WebPage::WebPage(QObject* parent) : QWebPage(parent) , m_view(0) , m_fileWatcher(0) , m_runningLoop(0) , m_loadProgress(-1) , m_blockAlerts(false) , m_secureStatus(false) , m_adjustingScheduled(false) { m_javaScriptEnabled = QWebSettings::globalSettings()->testAttribute(QWebSettings::JavascriptEnabled); m_networkProxy = new NetworkManagerProxy(this); m_networkProxy->setPrimaryNetworkAccessManager(mApp->networkManager()); m_networkProxy->setPage(this); setNetworkAccessManager(m_networkProxy); setForwardUnsupportedContent(true); setPluginFactory(new WebPluginFactory(this)); history()->setMaximumItemCount(20); connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(handleUnsupportedContent(QNetworkReply*))); connect(this, SIGNAL(loadProgress(int)), this, SLOT(progress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(finished())); connect(this, SIGNAL(printRequested(QWebFrame*)), this, SLOT(printFrame(QWebFrame*))); connect(this, SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest))); connect(this, SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); frameCreated(mainFrame()); connect(this, SIGNAL(frameCreated(QWebFrame*)), this, SLOT(frameCreated(QWebFrame*))); connect(this, SIGNAL(databaseQuotaExceeded(QWebFrame*,QString)), this, SLOT(dbQuotaExceeded(QWebFrame*))); connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptObject())); #if QTWEBKIT_FROM_2_2 connect(this, SIGNAL(featurePermissionRequested(QWebFrame*,QWebPage::Feature)), this, SLOT(featurePermissionRequested(QWebFrame*,QWebPage::Feature))); #endif #if QTWEBKIT_FROM_2_3 connect(this, SIGNAL(applicationCacheQuotaExceeded(QWebSecurityOrigin*,quint64,quint64)), this, SLOT(appCacheQuotaExceeded(QWebSecurityOrigin*,quint64))); #elif QTWEBKIT_FROM_2_2 connect(this, SIGNAL(applicationCacheQuotaExceeded(QWebSecurityOrigin*,quint64)), this, SLOT(appCacheQuotaExceeded(QWebSecurityOrigin*,quint64))); #endif s_livingPages.append(this); }
RssReader::RssReader(QWidget *parent) : QWidget(parent), ui(new Ui::RssReader) { ui->setupUi(this); QTreeWidgetItem *root1 = new QTreeWidgetItem(this->ui->treeWidget_Rsslist,QStringList(QString(QObject::tr("科技")))); QTreeWidgetItem *root2 = new QTreeWidgetItem(this->ui->treeWidget_Rsslist,QStringList(QString(QObject::tr("社会")))); QTreeWidgetItem *root3 = new QTreeWidgetItem(this->ui->treeWidget_Rsslist,QStringList(QString(QObject::tr("生活")))); QTreeWidgetItem *leaf1 = new QTreeWidgetItem(root1,QStringList(QString("cnBeta"))); QTreeWidgetItem *leaf2 = new QTreeWidgetItem(root1,QStringList(QString("新浪焦点新闻"))); QTreeWidgetItem *leaf3 = new QTreeWidgetItem(root3,QStringList(QString("糗事百科"))); ui->webView_Rss->setHtml("<body style=\"background-color:rgb(222,222,222);font-family:微软雅黑\"></body>"); //ui->webView_Passage->setHtml("<body style=\"background-color:rgb(222,222,222);font-family:微软雅黑\"></body>"); pRssObject = new RssObject(this); pGetRss = new QNetworkAccessManager(this); pGetPassage = new QNetworkAccessManager(this); connect(pGetRss,SIGNAL(finished(QNetworkReply*)),this,SLOT(RssFinished(QNetworkReply*))); connect(pGetPassage,SIGNAL(finished(QNetworkReply*)),this,SLOT(PassageFinished(QNetworkReply*))); connect(ui->webView_Rss->page()->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(addJavaScriptObject())); connect(pRssObject,SIGNAL(sendHTML(QString)),this,SLOT(readUrl(QString))); connect(ui->treeWidget_Rsslist,SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(ChoseRss(QTreeWidgetItem*))); ui->webView_Passage->hide(); }
void TopologyDialog::initMap() { ui->webView->settings()->setAttribute(QWebSettings::PluginsEnabled, true); ui->webView->settings()->setAttribute(QWebSettings::JavascriptEnabled, true); ui->webView->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); ui->webView->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); ui->webView->settings()->setAttribute(QWebSettings::JavaEnabled, true); connect(ui->webView->page()->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(addJavaScriptObject())); }