Exemple #1
0
void QtMainWindow::on_webView_linkClicked(const QUrl& url)
{
    QString sUrl = url.toString();
    if (sUrl.contains("rho_open_target=_blank")) {
        if (cb) cb->logEvent("WebView: open external browser");
        ExternalWebView* externalWebView = new ExternalWebView();
        externalWebView->navigate(QUrl(sUrl.remove("rho_open_target=_blank")));
        externalWebView->show();
        externalWebView->activateWindow();
    } else if (ui->webView) {
        if (!internalUrlProcessing(url)) {
            sUrl.remove(QRegExp("#+$"));
            if (sUrl.compare(ui->webView->url().toString())!=0) {
#ifdef OS_MACOSX
                if (cb && !sUrl.startsWith("javascript:", Qt::CaseInsensitive))
                    cb->onWebViewUrlChanged(sUrl.toStdString());
#endif
                ui->webView->load(QUrl(sUrl));
            }
        }
    }
}
Exemple #2
0
void QtMainWindow::on_webView_linkClicked(const QUrl& url)
{
    QString sUrl = url.toString();
    if (sUrl.contains("rho_open_target=_blank")) {
        LOG(INFO) + "WebView: open external browser";
        ExternalWebView* externalWebView = new ExternalWebView();
        externalWebView->navigate(QUrl(sUrl.remove("rho_open_target=_blank")));
        externalWebView->show();
        externalWebView->activateWindow();
    } else if (ui->webView) {
        if (!internalUrlProcessing(url)) {
            sUrl.remove(QRegExp("#+$"));
            if (sUrl.compare(ui->webView->url().toString())!=0) {
                if (mainWindowCallback && !sUrl.startsWith("javascript:", Qt::CaseInsensitive)) {
                    const QByteArray asc_url = sUrl.toLatin1();
                    mainWindowCallback->onWebViewUrlChanged(::std::string(asc_url.constData(), asc_url.length()));
                }
                ui->webView->load(QUrl(sUrl));
            }
        }
    }
}