void MyTextBrowser::htmlOrSvgDump(const char *filename) { #ifdef NO_WEBKIT FILE *fout = fopen(filename,"w"); if(fout == NULL) { printf("could not write %s\n", filename); return; } QString xml = toHtml(); fputs(xml.toUtf8(), fout); fclose(fout); #else QWebPage *p = page(); if(p == NULL) return; QWebFrame *f = p->currentFrame(); if(f == NULL) return; FILE *fout = fopen(filename,"w"); if(fout == NULL) { printf("could not write %s\n", filename); return; } QString xml = f->toHtml(); fputs(xml.toUtf8(), fout); fclose(fout); #endif }
QWebFrame* QWebPageProto::currentFrame() const { QWebPage *item = qscriptvalue_cast<QWebPage*>(thisObject()); if (item) return item->currentFrame(); return 0; }
void MainWindow::_loadFinished(bool ok) { if (ok) { QString indexUrl = _appSettings.host(); indexUrl += "index.php"; QString pageUrl = ui->webView->url().toString(); QWebPage* page = ui->webView->page(); QWebFrame* frame = page->currentFrame(); QWebElement root = frame->documentElement(); if (!root.findFirst("#loginForm").isNull()) { QWebElementCollection allInputs = root.findAll("input"); foreach (QWebElement inputElement, allInputs) { if (inputElement.hasAttribute("name")) { QString name = inputElement.attribute("name"); if (name == "username") { inputElement.setAttribute("value", _appSettings.user()); } else if (name == "password") { inputElement.setAttribute("value", _appSettings.password()); } } } root.findFirst("input[type=submit]").evaluateJavaScript("this.click()"); } else if (pageUrl == indexUrl)
void MyTextBrowser::tbScrollToAnchor(QString &text) { #ifdef NO_WEBKIT scrollToAnchor(text); #else QWebPage *pageptr = page(); if(pageptr != NULL) { pageptr->currentFrame()->scrollToAnchor(text); } #endif }
void Viewer::renderPageTo(QImage* image) { QWebPage *page = webView->page(); QWebFrame *frame = page->currentFrame(); QSize origSize = page->viewportSize(); page->setViewportSize(frame->contentsSize()); QPainter painter(image); frame->render(&painter); painter.end(); page->setViewportSize(origSize); }
void dlgMyBrowser::slotLoadFinished(bool ok) { if(opt.arg_debug) printf("dlgMyBrowser:slotLoadFinished(%d)\n", (int) ok); if(ok == false) return; #ifdef USE_WEBKIT if(opt.arg_debug) printf("dlgMyBrowser::slotLoadFinshed anchor=%s\n", (const char *) anchor.toUtf8()); #if QT_VERSION >= 0x040700 if(anchor.length() > 0) { QWebPage *page = form->browser->page(); if(page != NULL) { if(opt.arg_debug) printf("dlgMyBrowser::slotLoadFinshed scrollToAnchor\n"); page->currentFrame()->scrollToAnchor(anchor); } } #endif #endif }