mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 07:10:06 +02:00
fix for DataWebPage hifi link handling
This commit is contained in:
parent
0d77063e1e
commit
04416ff40c
2 changed files with 16 additions and 3 deletions
|
@ -9,6 +9,9 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <qnetworkrequest.h>
|
||||||
|
|
||||||
|
#include <AddressManager.h>
|
||||||
#include <OAuthNetworkAccessManager.h>
|
#include <OAuthNetworkAccessManager.h>
|
||||||
|
|
||||||
#include "DataWebPage.h"
|
#include "DataWebPage.h"
|
||||||
|
@ -19,9 +22,6 @@ DataWebPage::DataWebPage(QObject* parent) :
|
||||||
// use an OAuthNetworkAccessManager instead of regular QNetworkAccessManager so our requests are authed
|
// use an OAuthNetworkAccessManager instead of regular QNetworkAccessManager so our requests are authed
|
||||||
setNetworkAccessManager(OAuthNetworkAccessManager::getInstance());
|
setNetworkAccessManager(OAuthNetworkAccessManager::getInstance());
|
||||||
|
|
||||||
// have the page delegate external links so they can be captured by the Application in case they are a hifi link
|
|
||||||
setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
|
|
||||||
|
|
||||||
// give the page an empty stylesheet
|
// give the page an empty stylesheet
|
||||||
settings()->setUserStyleSheetUrl(QUrl());
|
settings()->setUserStyleSheetUrl(QUrl());
|
||||||
}
|
}
|
||||||
|
@ -29,3 +29,15 @@ DataWebPage::DataWebPage(QObject* parent) :
|
||||||
void DataWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) {
|
void DataWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) {
|
||||||
qDebug() << "JS console message at line" << lineNumber << "from" << sourceID << "-" << message;
|
qDebug() << "JS console message at line" << lineNumber << "from" << sourceID << "-" << message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DataWebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, QWebPage::NavigationType type) {
|
||||||
|
|
||||||
|
if (!request.url().toString().startsWith(HIFI_URL_SCHEME)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// this is a hifi URL - have the AddressManager handle it
|
||||||
|
QMetaObject::invokeMethod(&AddressManager::getInstance(), "handleLookupString",
|
||||||
|
Qt::AutoConnection, Q_ARG(const QString&, request.url().toString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ public:
|
||||||
DataWebPage(QObject* parent = 0);
|
DataWebPage(QObject* parent = 0);
|
||||||
protected:
|
protected:
|
||||||
void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID);
|
void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID);
|
||||||
|
bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, QWebPage::NavigationType type);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_DataWebPage_h
|
#endif // hifi_DataWebPage_h
|
Loading…
Reference in a new issue