mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 20:31:29 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into dk/oneFileWallet
This commit is contained in:
commit
7550374f8f
3 changed files with 52 additions and 93 deletions
|
@ -6,57 +6,36 @@ import QtQuick.Controls 2.2
|
||||||
|
|
||||||
import "../styles-uit" as StylesUIt
|
import "../styles-uit" as StylesUIt
|
||||||
|
|
||||||
Flickable {
|
Item {
|
||||||
id: flick
|
id: flick
|
||||||
|
|
||||||
property alias url: _webview.url
|
property alias url: webViewCore.url
|
||||||
property alias canGoBack: _webview.canGoBack
|
property alias canGoBack: webViewCore.canGoBack
|
||||||
property alias webViewCore: _webview
|
property alias webViewCore: webViewCore
|
||||||
property alias webViewCoreProfile: _webview.profile
|
property alias webViewCoreProfile: webViewCore.profile
|
||||||
|
property string webViewCoreUserAgent
|
||||||
|
|
||||||
property string userScriptUrl: ""
|
property string userScriptUrl: ""
|
||||||
property string urlTag: "noDownload=false";
|
property string urlTag: "noDownload=false";
|
||||||
|
|
||||||
signal newViewRequestedCallback(var request)
|
signal newViewRequestedCallback(var request)
|
||||||
signal loadingChangedCallback(var loadRequest)
|
signal loadingChangedCallback(var loadRequest)
|
||||||
pressDelay: 300
|
|
||||||
|
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
property bool interactive: false
|
||||||
|
|
||||||
StylesUIt.HifiConstants {
|
StylesUIt.HifiConstants {
|
||||||
id: hifi
|
id: hifi
|
||||||
}
|
}
|
||||||
|
|
||||||
onHeightChanged: {
|
|
||||||
if (height > 0) {
|
|
||||||
//reload page since window dimentions changed,
|
|
||||||
//so web engine should recalculate page render dimentions
|
|
||||||
reloadTimer.start()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
|
||||||
id: scrollBar
|
|
||||||
visible: flick.contentHeight > flick.height
|
|
||||||
|
|
||||||
contentItem: Rectangle {
|
|
||||||
opacity: 0.75
|
|
||||||
implicitWidth: hifi.dimensions.scrollbarHandleWidth
|
|
||||||
radius: height / 2
|
|
||||||
color: hifi.colors.tableScrollHandleDark
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onLoadingChanged(loadRequest) {
|
function onLoadingChanged(loadRequest) {
|
||||||
if (WebEngineView.LoadStartedStatus === loadRequest.status) {
|
if (WebEngineView.LoadStartedStatus === loadRequest.status) {
|
||||||
flick.contentWidth = flick.width
|
|
||||||
flick.contentHeight = flick.height
|
|
||||||
|
|
||||||
// Required to support clicking on "hifi://" links
|
// Required to support clicking on "hifi://" links
|
||||||
var url = loadRequest.url.toString();
|
var url = loadRequest.url.toString();
|
||||||
|
url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
|
||||||
if (urlHandler.canHandleUrl(url)) {
|
if (urlHandler.canHandleUrl(url)) {
|
||||||
if (urlHandler.handleUrl(url)) {
|
if (urlHandler.handleUrl(url)) {
|
||||||
_webview.stop();
|
webViewCore.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,34 +46,18 @@ Flickable {
|
||||||
|
|
||||||
if (WebEngineView.LoadSucceededStatus === loadRequest.status) {
|
if (WebEngineView.LoadSucceededStatus === loadRequest.status) {
|
||||||
//disable Chromium's scroll bars
|
//disable Chromium's scroll bars
|
||||||
_webview.runJavaScript("document.body.style.overflow = 'hidden';");
|
|
||||||
//calculate page height
|
|
||||||
_webview.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) {
|
|
||||||
if (i_actualPageHeight !== undefined) {
|
|
||||||
flick.contentHeight = i_actualPageHeight
|
|
||||||
} else {
|
|
||||||
flick.contentHeight = flick.height;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
flick.contentWidth = flick.width
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: reloadTimer
|
|
||||||
interval: 100
|
|
||||||
repeat: false
|
|
||||||
onTriggered: {
|
|
||||||
_webview.reload()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebEngineView {
|
WebEngineView {
|
||||||
id: _webview
|
id: webViewCore
|
||||||
|
|
||||||
height: parent.height
|
anchors.fill: parent
|
||||||
|
|
||||||
profile: HFWebEngineProfile;
|
profile: HFWebEngineProfile;
|
||||||
|
settings.pluginsEnabled: true
|
||||||
|
settings.touchIconsEnabled: true
|
||||||
|
settings.allowRunningInsecureContent: true
|
||||||
|
|
||||||
// creates a global EventBridge object.
|
// creates a global EventBridge object.
|
||||||
WebEngineScript {
|
WebEngineScript {
|
||||||
|
@ -125,25 +88,23 @@ Flickable {
|
||||||
property string newUrl: ""
|
property string newUrl: ""
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
width = Qt.binding(function() { return flick.width; });
|
|
||||||
webChannel.registerObject("eventBridge", eventBridge);
|
webChannel.registerObject("eventBridge", eventBridge);
|
||||||
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
|
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
|
||||||
// Ensure the JS from the web-engine makes it to our logging
|
// Ensure the JS from the web-engine makes it to our logging
|
||||||
_webview.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
webViewCore.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
||||||
console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
|
console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
|
||||||
});
|
});
|
||||||
_webview.profile.httpUserAgent = "Mozilla/5.0 Chrome (HighFidelityInterface)";
|
if (webViewCoreUserAgent !== undefined) {
|
||||||
|
webViewCore.profile.httpUserAgent = webViewCoreUserAgent
|
||||||
|
} else {
|
||||||
|
webViewCore.profile.httpUserAgent += " (HighFidelityInterface)";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onFeaturePermissionRequested: {
|
onFeaturePermissionRequested: {
|
||||||
grantFeaturePermission(securityOrigin, feature, true);
|
grantFeaturePermission(securityOrigin, feature, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
onContentsSizeChanged: {
|
|
||||||
flick.contentHeight = Math.max(contentsSize.height, flick.height);
|
|
||||||
flick.contentWidth = flick.width
|
|
||||||
}
|
|
||||||
//disable popup
|
//disable popup
|
||||||
onContextMenuRequested: {
|
onContextMenuRequested: {
|
||||||
request.accepted = true;
|
request.accepted = true;
|
||||||
|
@ -164,15 +125,8 @@ Flickable {
|
||||||
x: flick.width/2 - width/2
|
x: flick.width/2 - width/2
|
||||||
y: flick.height/2 - height/2
|
y: flick.height/2 - height/2
|
||||||
source: "../../icons/loader-snake-64-w.gif"
|
source: "../../icons/loader-snake-64-w.gif"
|
||||||
visible: _webview.loading && /^(http.*|)$/i.test(_webview.url.toString())
|
visible: webViewCore.loading && /^(http.*|)$/i.test(webViewCore.url.toString())
|
||||||
playing: visible
|
playing: visible
|
||||||
z: 10000
|
z: 10000
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onWheel: {
|
|
||||||
flick.flick(0, wheel.angleDelta.y*10)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -640,7 +640,7 @@ void OffscreenQmlSurface::setBaseUrl(const QUrl& baseUrl) {
|
||||||
_qmlContext->setBaseUrl(baseUrl);
|
_qmlContext->setBaseUrl(baseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::load(const QUrl& qmlSource, bool createNewContext, std::function<void(QQmlContext*, QObject*)> f) {
|
void OffscreenQmlSurface::load(const QUrl& qmlSource, bool createNewContext, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
qCWarning(uiLogging) << "Called load on a non-surface thread";
|
qCWarning(uiLogging) << "Called load on a non-surface thread";
|
||||||
}
|
}
|
||||||
|
@ -660,28 +660,28 @@ void OffscreenQmlSurface::load(const QUrl& qmlSource, bool createNewContext, std
|
||||||
auto qmlComponent = new QQmlComponent(_qmlContext->engine(), finalQmlSource, QQmlComponent::PreferSynchronous);
|
auto qmlComponent = new QQmlComponent(_qmlContext->engine(), finalQmlSource, QQmlComponent::PreferSynchronous);
|
||||||
if (qmlComponent->isLoading()) {
|
if (qmlComponent->isLoading()) {
|
||||||
connect(qmlComponent, &QQmlComponent::statusChanged, this,
|
connect(qmlComponent, &QQmlComponent::statusChanged, this,
|
||||||
[this, qmlComponent, targetContext, f](QQmlComponent::Status) {
|
[this, qmlComponent, targetContext, onQmlLoadedCallback](QQmlComponent::Status) {
|
||||||
finishQmlLoad(qmlComponent, targetContext, f);
|
finishQmlLoad(qmlComponent, targetContext, onQmlLoadedCallback);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
finishQmlLoad(qmlComponent, targetContext, f);
|
finishQmlLoad(qmlComponent, targetContext, onQmlLoadedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::loadInNewContext(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f) {
|
void OffscreenQmlSurface::loadInNewContext(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback) {
|
||||||
load(qmlSource, true, f);
|
load(qmlSource, true, onQmlLoadedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f) {
|
void OffscreenQmlSurface::load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback) {
|
||||||
load(qmlSource, false, f);
|
load(qmlSource, false, onQmlLoadedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::clearCache() {
|
void OffscreenQmlSurface::clearCache() {
|
||||||
_qmlContext->engine()->clearComponentCache();
|
_qmlContext->engine()->clearComponentCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext* qmlContext, std::function<void(QQmlContext*, QObject*)> f) {
|
void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext* qmlContext, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback) {
|
||||||
disconnect(qmlComponent, &QQmlComponent::statusChanged, this, 0);
|
disconnect(qmlComponent, &QQmlComponent::statusChanged, this, 0);
|
||||||
if (qmlComponent->isError()) {
|
if (qmlComponent->isError()) {
|
||||||
for (const auto& error : qmlComponent->errors()) {
|
for (const auto& error : qmlComponent->errors()) {
|
||||||
|
@ -691,7 +691,6 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QObject* newObject = qmlComponent->beginCreate(qmlContext);
|
QObject* newObject = qmlComponent->beginCreate(qmlContext);
|
||||||
if (qmlComponent->isError()) {
|
if (qmlComponent->isError()) {
|
||||||
for (const auto& error : qmlComponent->errors()) {
|
for (const auto& error : qmlComponent->errors()) {
|
||||||
|
@ -705,7 +704,20 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
|
||||||
}
|
}
|
||||||
|
|
||||||
qmlContext->engine()->setObjectOwnership(this, QQmlEngine::CppOwnership);
|
qmlContext->engine()->setObjectOwnership(this, QQmlEngine::CppOwnership);
|
||||||
f(qmlContext, newObject);
|
|
||||||
|
// All quick items should be focusable
|
||||||
|
QQuickItem* newItem = qobject_cast<QQuickItem*>(newObject);
|
||||||
|
if (newItem) {
|
||||||
|
// Make sure we make items focusable (critical for
|
||||||
|
// supporting keyboard shortcuts)
|
||||||
|
newItem->setFlag(QQuickItem::ItemIsFocusScope, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure we will call callback for this codepath
|
||||||
|
// Call this before qmlComponent->completeCreate() otherwise ghost window appears
|
||||||
|
if (newItem && _rootItem) {
|
||||||
|
onQmlLoadedCallback(qmlContext, newObject);
|
||||||
|
}
|
||||||
|
|
||||||
QObject* eventBridge = qmlContext->contextProperty("eventBridge").value<QObject*>();
|
QObject* eventBridge = qmlContext->contextProperty("eventBridge").value<QObject*>();
|
||||||
if (qmlContext != _qmlContext && eventBridge && eventBridge != this) {
|
if (qmlContext != _qmlContext && eventBridge && eventBridge != this) {
|
||||||
|
@ -717,15 +729,6 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
|
||||||
qmlComponent->completeCreate();
|
qmlComponent->completeCreate();
|
||||||
qmlComponent->deleteLater();
|
qmlComponent->deleteLater();
|
||||||
|
|
||||||
|
|
||||||
// All quick items should be focusable
|
|
||||||
QQuickItem* newItem = qobject_cast<QQuickItem*>(newObject);
|
|
||||||
if (newItem) {
|
|
||||||
// Make sure we make items focusable (critical for
|
|
||||||
// supporting keyboard shortcuts)
|
|
||||||
newItem->setFlag(QQuickItem::ItemIsFocusScope, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we already have a root, just set a couple of flags and the ancestry
|
// If we already have a root, just set a couple of flags and the ancestry
|
||||||
if (newItem && _rootItem) {
|
if (newItem && _rootItem) {
|
||||||
// Allow child windows to be destroyed from JS
|
// Allow child windows to be destroyed from JS
|
||||||
|
@ -748,6 +751,8 @@ void OffscreenQmlSurface::finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext
|
||||||
_rootItem = newItem;
|
_rootItem = newItem;
|
||||||
_rootItem->setParentItem(_quickWindow->contentItem());
|
_rootItem->setParentItem(_quickWindow->contentItem());
|
||||||
_rootItem->setSize(_quickWindow->renderTargetSize());
|
_rootItem->setSize(_quickWindow->renderTargetSize());
|
||||||
|
// Call this callback after rootitem is set, otherwise VrMenu wont work
|
||||||
|
onQmlLoadedCallback(qmlContext, newObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::updateQuick() {
|
void OffscreenQmlSurface::updateQuick() {
|
||||||
|
|
|
@ -50,11 +50,11 @@ public:
|
||||||
void resize(const QSize& size, bool forceResize = false);
|
void resize(const QSize& size, bool forceResize = false);
|
||||||
QSize size() const;
|
QSize size() const;
|
||||||
|
|
||||||
Q_INVOKABLE void load(const QUrl& qmlSource, bool createNewContext, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
Q_INVOKABLE void load(const QUrl& qmlSource, bool createNewContext, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback = [](QQmlContext*, QObject*) {});
|
||||||
Q_INVOKABLE void loadInNewContext(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
Q_INVOKABLE void loadInNewContext(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback = [](QQmlContext*, QObject*) {});
|
||||||
Q_INVOKABLE void load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
Q_INVOKABLE void load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback = [](QQmlContext*, QObject*) {});
|
||||||
Q_INVOKABLE void load(const QString& qmlSourceFile, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}) {
|
Q_INVOKABLE void load(const QString& qmlSourceFile, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback = [](QQmlContext*, QObject*) {}) {
|
||||||
return load(QUrl(qmlSourceFile), f);
|
return load(QUrl(qmlSourceFile), onQmlLoadedCallback);
|
||||||
}
|
}
|
||||||
void clearCache();
|
void clearCache();
|
||||||
void setMaxFps(uint8_t maxFps) { _maxFps = maxFps; }
|
void setMaxFps(uint8_t maxFps) { _maxFps = maxFps; }
|
||||||
|
@ -120,7 +120,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
static QOpenGLContext* getSharedContext();
|
static QOpenGLContext* getSharedContext();
|
||||||
|
|
||||||
void finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext* qmlContext, std::function<void(QQmlContext*, QObject*)> f);
|
void finishQmlLoad(QQmlComponent* qmlComponent, QQmlContext* qmlContext, std::function<void(QQmlContext*, QObject*)> onQmlLoadedCallback);
|
||||||
QPointF mapWindowToUi(const QPointF& sourcePosition, QObject* sourceObject);
|
QPointF mapWindowToUi(const QPointF& sourcePosition, QObject* sourceObject);
|
||||||
void setupFbo();
|
void setupFbo();
|
||||||
bool allowNewFrame(uint8_t fps);
|
bool allowNewFrame(uint8_t fps);
|
||||||
|
|
Loading…
Reference in a new issue