mirror of
https://github.com/overte-org/overte.git
synced 2025-07-05 15:29:12 +02:00
Move directory web UI into the overlay
This commit is contained in:
parent
82c865af2c
commit
5088eec2a2
4 changed files with 28 additions and 2 deletions
|
@ -62,7 +62,7 @@ var directory = (function () {
|
||||||
function setUp() {
|
function setUp() {
|
||||||
viewport = Controller.getViewportDimensions();
|
viewport = Controller.getViewportDimensions();
|
||||||
|
|
||||||
directoryWindow = new WebWindow('Directory', DIRECTORY_URL, 900, 700, false);
|
directoryWindow = new OverlayWebWindow('Directory', DIRECTORY_URL, 900, 700, false);
|
||||||
directoryWindow.setVisible(false);
|
directoryWindow.setVisible(false);
|
||||||
|
|
||||||
directoryButton = Overlays.addOverlay("image", {
|
directoryButton = Overlays.addOverlay("image", {
|
||||||
|
|
|
@ -19,12 +19,27 @@ VrDialog {
|
||||||
backgroundColor: "#7f000000"
|
backgroundColor: "#7f000000"
|
||||||
property url source: "about:blank"
|
property url source: "about:blank"
|
||||||
|
|
||||||
|
signal navigating(string url)
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
enabled = true
|
enabled = true
|
||||||
console.log("Web Window Created " + root);
|
console.log("Web Window Created " + root);
|
||||||
webview.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
webview.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
||||||
console.log("Web Window JS message: " + sourceID + " " + lineNumber + " " + message);
|
console.log("Web Window JS message: " + sourceID + " " + lineNumber + " " + message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
webview.loadingChanged.connect(handleWebviewLoading)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function handleWebviewLoading(loadRequest) {
|
||||||
|
var HIFI_URL_PATTERN = /^hifi:\/\//;
|
||||||
|
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
||||||
|
var newUrl = loadRequest.url.toString();
|
||||||
|
if (newUrl.match(HIFI_URL_PATTERN)) {
|
||||||
|
root.navigating(newUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
@ -40,6 +55,9 @@ VrDialog {
|
||||||
id: webview
|
id: webview
|
||||||
url: root.source
|
url: root.source
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
profile: WebEngineProfile {
|
||||||
|
httpUserAgent: "Mozilla/5.0 (HighFidelityInterface)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // item
|
} // item
|
||||||
} // dialog
|
} // dialog
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <QtWebSockets/QWebSocketServer>
|
#include <QtWebSockets/QWebSocketServer>
|
||||||
#include <QtWebChannel/QWebChannel>
|
#include <QtWebChannel/QWebChannel>
|
||||||
|
|
||||||
|
#include <AddressManager.h>
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
|
|
||||||
#include "impl/websocketclientwrapper.h"
|
#include "impl/websocketclientwrapper.h"
|
||||||
|
@ -86,8 +87,14 @@ QmlWebWindowClass::QmlWebWindowClass(QObject* qmlWindow)
|
||||||
qDebug() << "Created window with ID " << _windowId;
|
qDebug() << "Created window with ID " << _windowId;
|
||||||
Q_ASSERT(_qmlWindow);
|
Q_ASSERT(_qmlWindow);
|
||||||
Q_ASSERT(dynamic_cast<const QQuickItem*>(_qmlWindow));
|
Q_ASSERT(dynamic_cast<const QQuickItem*>(_qmlWindow));
|
||||||
|
QObject::connect(_qmlWindow, SIGNAL(navigating(QString)), this, SLOT(handleNavigation(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlWebWindowClass::handleNavigation(const QString& url) {
|
||||||
|
DependencyManager::get<AddressManager>()->handleLookupString(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QmlWebWindowClass::setVisible(bool visible) {
|
void QmlWebWindowClass::setVisible(bool visible) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "setVisible", Qt::AutoConnection, Q_ARG(bool, visible));
|
QMetaObject::invokeMethod(this, "setVisible", Qt::AutoConnection, Q_ARG(bool, visible));
|
||||||
|
|
|
@ -81,6 +81,7 @@ signals:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void hasClosed();
|
void hasClosed();
|
||||||
|
void handleNavigation(const QString& url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmlScriptEventBridge* _eventBridge;
|
QmlScriptEventBridge* _eventBridge;
|
||||||
|
|
Loading…
Reference in a new issue