mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 07:12:50 +02:00
Merge pull request #5628 from ctrlaltdavid/webwindow-external-links
Make WebWindow hyperlinks with target="_blank" open in user's browser
This commit is contained in:
commit
5ea6d2704a
1 changed files with 8 additions and 0 deletions
|
@ -32,12 +32,20 @@ void DataWebPage::javaScriptConsoleMessage(const QString& message, int lineNumbe
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataWebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, QWebPage::NavigationType type) {
|
bool DataWebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, QWebPage::NavigationType type) {
|
||||||
|
// Handle hifi:// links and links to files with particular extensions
|
||||||
QString urlString = request.url().toString();
|
QString urlString = request.url().toString();
|
||||||
if (Application::getInstance()->canAcceptURL(urlString)) {
|
if (Application::getInstance()->canAcceptURL(urlString)) {
|
||||||
if (Application::getInstance()->acceptURL(urlString)) {
|
if (Application::getInstance()->acceptURL(urlString)) {
|
||||||
return false; // we handled it, so QWebPage doesn't need to handle it
|
return false; // we handled it, so QWebPage doesn't need to handle it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make hyperlinks with target="_blank" open in user's Web browser
|
||||||
|
if (type == QWebPage::NavigationTypeLinkClicked && frame == nullptr) {
|
||||||
|
Application::getInstance()->openUrl(request.url());
|
||||||
|
return false; // We handled it.
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue