void BrowerEditAreaWidget::initSignalsAndSlots() { connect(brower, SIGNAL(linkClicked(QUrl)), this, SLOT(openLinkOutside(QUrl))); connect(brower->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavascriptObject())); }
void QDeclarativeWebView::setPage(QWebPage* page) { if (d->view->page() == page) return; d->view->setPage(page); updateContentsSize(); page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); connect(page->mainFrame(), SIGNAL(urlChanged(QUrl)), this, SLOT(pageUrlChanged())); connect(page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); connect(page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(iconChanged())); connect(page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged())); connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout())); connect(page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SIGNAL(contentsSizeChanged(QSize))); connect(page, SIGNAL(loadStarted()), this, SLOT(doLoadStarted())); connect(page, SIGNAL(loadProgress(int)), this, SLOT(doLoadProgress(int))); connect(page, SIGNAL(loadFinished(bool)), this, SLOT(doLoadFinished(bool))); connect(page, SIGNAL(statusBarMessage(QString)), this, SLOT(setStatusText(QString))); connect(page->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(windowObjectCleared())); page->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true); }
UtmpWebView::UtmpWebView():QWebView() { QWebSettings* default_settings = QWebSettings::globalSettings(); default_settings->setAttribute(QWebSettings::JavascriptEnabled,true); default_settings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled,true); default_settings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled,true); default_settings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls,true); default_settings->setAttribute(QWebSettings::LocalStorageEnabled,true); default_settings->setAttribute(QWebSettings::JavascriptCanAccessClipboard,true); default_settings->setAttribute(QWebSettings::DeveloperExtrasEnabled,true); default_settings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); default_settings->setAttribute(QWebSettings::PluginsEnabled,true); default_settings->setAttribute(QWebSettings::JavascriptCanOpenWindows,true); //setContextMenuPolicy(Qt::NoContextMenu); //如何防止框架页面不被业务页面刷掉: //一般业务页面都是套在iframe中的,主要考虑防止target=_top的链接和window.top=''的js事件 //1:如下,可以截获所有链接的点击事件,但信号当中并不能确定这个链接是不是target = _top的 //this->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); //connect(this,SIGNAL(linkClicked(QUrl)),SLOT(openUrl(QUrl))); //2:可以重写QWebPage类的acceptNavigationRequest方法,但只能截获前进、后退、表单提交、刷新等操作,也不行 //3:可以考虑在框架页面中写JS,修改业务页面中的代码(下策) connect(this->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject())); connect(this->page(), SIGNAL(printRequested(QWebFrame*)),this,SLOT(customPrintRequested(QWebFrame*))); this->page()->setForwardUnsupportedContent(true); //这个槽没什么用 connect(this->page(),SIGNAL(downloadRequested(QNetworkRequest)),this,SLOT(download(QNetworkRequest))); connect(this->page(),SIGNAL(unsupportedContent(QNetworkReply*)),this,SLOT(unsupportedContent(QNetworkReply*))); }
ForgotPasswordUI::ForgotPasswordUI() : HtmlPage("forget_password") { connect(webFrame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject())); ui->forgot_password->setEnabled(false); }
ChatView::ChatView(const QByteArray &id, const QString &url, QWidget *parent) : WebView(parent) , m_loaded(false) , m_id(id) , m_lastMessage(0) { setPage(new WebPage(this)); page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); setUrl(QUrl(url)); connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), SLOT(populateJavaScriptWindowObject())); setFocusPolicy(Qt::NoFocus); connect(ChatCore::settings(), SIGNAL(changed(QString,QVariant)), SLOT(settingsChanged(QString,QVariant))); connect(this, SIGNAL(linkClicked(QUrl)), SLOT(openUrl(QUrl))); connect(ChatNotify::i(), SIGNAL(notify(Notify)), SLOT(notify(Notify))); setAcceptDrops(true); setIcons(); createActions(); retranslateUi(); QTimer::singleShot(0, this, SLOT(start())); }
void MyWebView::initEvents() { // 委托页面所有连接在当前视图中打开 myPage->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); connect(myPage, SIGNAL(linkClicked(QUrl)), this, SLOT(onOpenUrl(QUrl))); // 对所有事件添加信号槽 connect(myFrame, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); connect(myFrame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(onJavaScriptWindowObjectCleared())); connect(myFrame, SIGNAL(initialLayoutCompleted()), this, SLOT(onInitialLayoutCompleted())); connect(myFrame, SIGNAL(pageChanged()), this, SLOT(onPageChanged())); connect(myFrame, SIGNAL(contentsSizeChanged(const QSize)), this, SLOT(onContentsSizeChanged(const QSize))); connect(myFrame, SIGNAL(iconChanged()), this, SLOT(onIconChanged())); connect(myFrame, SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); connect(myFrame, SIGNAL(titleChanged(const QString)), this, SLOT(onTitleChanged(const QString))); connect(myFrame, SIGNAL(urlChanged(const QUrl)), this, SLOT(onUrlChanged(const QUrl))); connect(myPage, SIGNAL(loadProgress(int)), this, SLOT(onLoadProgress(int))); connect(myPage, SIGNAL(repaintRequested(const QRect)), this, SLOT(onRepaintRequested(const QRect))); connect(myPage, SIGNAL(geometryChangeRequested(const QRect)), this, SLOT(onGeometryChangeRequested(const QRect))); connect(newManager, SIGNAL(requestFinished(QString)), this, SLOT(onRequestFinished(QString))); connect(newManager, SIGNAL(requestStart(QString)), this, SLOT(onRequestStart(QString))); };
void ScriptApi::setWebView( View *view ) { m_view = view; attachObject(); connect( m_view->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(attachObject()) ); installGlobals(); }
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())); }
//-------------------------------------------------------- CController::CController(QWebView* view, QObject* parent): QObject(parent), m_view(view) { connect(m_view->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject())); }
MapPlanning::MapPlanning(QWidget *parent) : QDialog(parent), ui(new Ui::MapPlanning) { ui->setupUi(this); buttonGroup = new QButtonGroup(); /** * Recreates the C++/JS bridge when the JavaScript window is refreshed */ connect(ui->webView->page()->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(addClickListener()), Qt::UniqueConnection); ui->webView->load(QUrl("qrc:/res/html/mapsPlanning.html")); model = new TableModel(); ui->tableView->setModel(model); ui->tableView->setItemDelegate(new QComboBoxDelegate()); ui->tableView->setColumnHidden(0, true); ui->tableView->setColumnHidden(5, true); ui->tableView->setColumnWidth(2, 42); ui->tableView->setColumnWidth(4, 42); //connect(ui->addButton, SIGNAL(clicked()), this, SLOT(on_addButton_clicked()), Qt::UniqueConnection); connect(ui->backButton, SIGNAL(clicked()), this, SLOT(on_backButton_clicked()), Qt::UniqueConnection); //connect(ui->clearMapButton, SIGNAL(clicked()), this, SLOT(on_clearMapButton_clicked()), Qt::UniqueConnection); connect(ui->clearTableButton, SIGNAL(clicked()), this, SLOT(on_clearTableButton_clicked()), Qt::UniqueConnection); //connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(on_deleteButton_clicked()), Qt::UniqueConnection); connect(ui->executeButton, SIGNAL(clicked()), this, SLOT(on_executeButton_clicked()), Qt::UniqueConnection); //connect(ui->updateTableButton, SIGNAL(clicked()), this, SLOT(on_updateTableButton_clicked()), Qt::UniqueConnection); }
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")); }
MainWindow::MainWindow() { setupUi(this); webView->page()->networkAccessManager()->setCookieJar(new CookieJar); // Enable the web inspector and local storage webView->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); webView->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true); connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished())); connect(webView, SIGNAL(loadFinished(bool)), progressBar, SLOT(hide())); connect(webView, SIGNAL(loadProgress(int)), progressBar, SLOT(setValue(int))); connect(webView, SIGNAL(loadStarted()), progressBar, SLOT(show())); connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(onUrlChanged(QUrl))); connect(webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(onJavaScriptWindowObjectCleared())); connect(urlEdit, SIGNAL(returnPressed()), this, SLOT(loadUrl())); connect(goButton, SIGNAL(clicked()), this, SLOT(loadUrl())); // Load the JavaScript from the resource file QFile file(":/bridge.js"); file.open(QIODevice::ReadOnly); mJavaScript = file.readAll(); }
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())); }
Kludget::Kludget(KClient *parent) : QObject(parent), client(parent), window(new KWindow), settings(new KSettings(this)), system(new KSystem(this)), prefWindow(0), aboutWindow(0), firstShow(true) { setObjectName("Kludget"); settings->setRootKey("kludget"); connect(system, SIGNAL(execUpdate(long)), this, SLOT(onSystemExecUpdate(long))); connect(system, SIGNAL(execFinish(long)), this, SLOT(onSystemExecFinish(long))); connect(window, SIGNAL(destroyed()), this, SLOT(onWindowDestroyed())); connect(window, SIGNAL(onShow()), this, SLOT(onShow())); connect(window, SIGNAL(onHide()), this, SLOT(onHide())); connect(window, SIGNAL(onStartDrag()), this, SLOT(onStartDrag())); connect(window, SIGNAL(onEndDrag()), this, SLOT(onEndDrag())); connect(window, SIGNAL(onSettingsChanged()), this, SLOT(onSettingsChanged())); connect(window->view(), SIGNAL(contextMenuRequested()), this, SLOT(onContextMenu())); connect(window->view(), SIGNAL(urlReceived(const QUrl*)), this, SLOT(onUrlReceived(const QUrl*))); connect(window->view()->page(), SIGNAL(loadFinished(bool)), this, SLOT(show())); connect(window->view()->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(onJavaScriptWindowObjectCleared())); connect(window->view()->page(), SIGNAL(frameCreated(QWebFrame*)), this, SLOT(onFrameCreated(QWebFrame*))); connect(this, SIGNAL(evaluate(const QString &)), this, SLOT(onEvaluate(const QString &))); connect(&customMenuMapper, SIGNAL(mapped(const QString &)), this, SIGNAL(evaluate(const QString &))); connect(&ipcClient, SIGNAL(messageReceived(QString,QString,QString)), this, SLOT(messageReceived(QString,QString,QString))); KLog::log("Kludget::created"); }
Player::Player(QWidget *parent) :Html5ApplicationViewer(parent) { QObject::connect(webView()->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), SLOT(addToJavaScript())); api.sync(); playStatus = false; if (HIWORD(BASS_GetVersion())!=BASSVERSION) { return; } if (!BASS_Init(-1,44100,0,NULL,NULL)) { return; } BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST,1); // enable playlist processing BASS_SetConfig(BASS_CONFIG_NET_PREBUF,0); // minimize automatic pre-buffering, so we can do it (and display it) instead playList.insert("1", "http://mp3.polskieradio.pl:8900/;stream"); playList.insert("2", "http://stream3.polskieradio.pl:8902/;stream"); playList.insert("3", "http://stream3.polskieradio.pl:8904/;stream"); playList.insert("4", "http://mp3.polskieradio.pl:8906/;stream"); playList.insert("antyradio", "http://ant-waw.cdn.eurozet.pl:8602/;stream"); acr.loadSettings(); QObject::connect(&acr, SIGNAL(songFound(QJsonObject)), this, SLOT(songFound(QJsonObject))); QObject::connect(&api, SIGNAL(updateReady(QList<Radiostation>)), this, SLOT(songFound(QList<Radiostation>))); }
void QHFWebView::load(const QUrl &url) { QWebView::load(url); QWebSettings *sets = this->page()->settings(); sets->setAttribute(QWebSettings::JavascriptEnabled,true); sets->setAttribute(QWebSettings::LocalContentCanAccessFileUrls,true); connect(page()->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(registerObject())); }
QtVoxBrowser::QtVoxBrowser(QWidget * parent): QWebView(parent) { SAFE_CONNECT (this->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), SLOT(initJavascript() )); _jsHandler = NULL; }
SimpleBrowser::SimpleBrowser(const QUrl& url, QNetworkAccessManager *am, const char *title) { uisb = new Ui::simpleBrowser(); uisb->setupUi(this); this->show(); setWindowTitle(title); progress = 0; webPage = new QWebPage(); uisb->webView->setPage(webPage); webPage->setNetworkAccessManager(am); uisb->webView->load(url); connect(uisb->webView, SIGNAL(loadProgress(int)), this, SLOT(set_progress(int))); connect(uisb->webView, SIGNAL(loadFinished(bool)), this, SLOT(finished_loading(bool))); connect(webPage->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared())); setUnifiedTitleAndToolBarOnMac(true); this->hide(); }
void MainWindow::on_webView_loadFinished(){ // get Webkit main frame frame = ui->webView->page()->mainFrame(); // add js event connect(frame,SIGNAL(javaScriptWindowObjectCleared()),this, SLOT(addJS())); }
void WebAPI::setWebView( WebView *view ) { WebPage *page = view->page(); frame = page->mainFrame(); attachObject(); connect( frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(attachObject()) ); }
void BrowserApi::setWebView(QWebView *view) { QWebPage *page = view->page(); m_frame = page->mainFrame(); attachObject(); connect(m_frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(attachObject())); }
FormExtractor::FormExtractor(QWidget *parent, Qt::WFlags flags) : QWidget(parent, flags) { ui.setupUi(this); ui.webView->setUrl(QUrl("qrc:/form.html")); connect(ui.webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject())); resize(300, 300); }
ChannelsView::ChannelsView(QWidget *parent) : WebView(parent) { connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), SLOT(populateJavaScriptWindowObject())); connect(ChatNotify::i(), SIGNAL(notify(Notify)), SLOT(notify(Notify))); connect(ChatClient::channels(), SIGNAL(channel(QByteArray)), SLOT(channel(QByteArray))); retranslateUi(); }
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())); }
QWebKitTest::QWebKitTest(QWidget *parent) : QDialog(parent) { m_webObj = new MyWebKit(this); ui->setupUi(this); ui->webView->setUrl((QUrl("qrc:/test.html"))); connect(ui->webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject())); }
void UBToolWidget::initialize() { if (!sClosePixmap) sClosePixmap = new QPixmap(":/images/close.svg"); if(!sUnpinPixmap) sUnpinPixmap = new QPixmap(":/images/unpin.svg"); UBGraphicsScene *wscene = dynamic_cast<UBGraphicsScene *>(mToolWidget->scene()); if (wscene) { wscene->removeItemFromDeletion(mToolWidget); wscene->removeItem(mToolWidget); } mWebView = new QWebView(this); QPalette palette = mWebView->page()->palette(); palette.setBrush(QPalette::Base, QBrush(Qt::transparent)); mWebView->page()->setPalette(palette); mWebView->installEventFilter(this); mFrameWidth = UBSettings::settings()->objectFrameWidth; mContentMargin = sClosePixmap->width() / 2 + mFrameWidth; setLayout(new QVBoxLayout()); layout()->setContentsMargins(mContentMargin, mContentMargin, mContentMargin, mContentMargin); layout()->addWidget(mWebView); setFixedSize(mToolWidget->boundingRect().width() + mContentMargin * 2, mToolWidget->boundingRect().height() + mContentMargin * 2); connect(mWebView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared())); mWebView->load(mToolWidget->mainHtml()); mWebView->setAcceptDrops(false); mWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true); mWebView->setAttribute(Qt::WA_OpaquePaintEvent, false); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(javaScriptWindowObjectCleared())); }
PluginsView::PluginsView(QWidget *parent) : WebView(parent) { page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); setFocusPolicy(Qt::NoFocus); connect(page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), SLOT(populateJavaScriptWindowObject())); QTimer::singleShot(0, this, SLOT(boot())); }
WebPage::WebPage(QWidget *parent) : QWebPage(parent) { b = (Browser *)parent; connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(populateJavaScriptWindowObject()) ); useragent = "FlatTurtle InfoScreenBrowser/" + QCoreApplication::applicationVersion() + " QtWebKit/" + QTWEBKIT_VERSION_STR; }
Window::Window( QWidget *parent) : QObject(parent) { m_view = new QWebView(); m_page = new WebPage(m_view); m_view->setPage(m_page); m_window = new CustomWindow(m_view); connect(m_page, SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(onInitialized())); connect(m_window,SIGNAL(myCloseEvent()),SIGNAL(_onClose())); }
GSuperWebPage::GSuperWebPage(WebPageWrapper *page, ChromeWidget *chromeWidget) : GWebPage(page), m_chromeWidget(chromeWidget) { if (!m_page) { m_page = new WebPageWrapper(this, "Superpage javascript error"); } //qDebug() << "GSuperWebPage::GSuperWebPage: page=" << GWebPage::page(); connect(GWebPage::page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(onJavaScriptWindowObjectCleared())); }