mirror of
https://github.com/overte-org/overte.git
synced 2025-05-30 07:10:26 +02:00
start on moving edit.js to tablet
This commit is contained in:
parent
c5085681df
commit
4c3a6842a5
9 changed files with 56 additions and 19 deletions
|
@ -27,6 +27,10 @@ var EventBridge;
|
|||
};
|
||||
};
|
||||
|
||||
console.log("---");
|
||||
console.log("CREATING GLOBAL EVENT BRIDGE");
|
||||
console.log("---");
|
||||
|
||||
EventBridge = new TempEventBridge();
|
||||
|
||||
var webChannel = new QWebChannel(qt.webChannelTransport, function (channel) {
|
||||
|
|
|
@ -15,7 +15,7 @@ import HFWebEngineProfile 1.0
|
|||
WebEngineView {
|
||||
id: root
|
||||
|
||||
profile: desktop.browserProfile
|
||||
// profile: desktop.browserProfile
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("Connecting JS messaging to Hifi Logging")
|
||||
|
|
|
@ -84,14 +84,10 @@ Item {
|
|||
topMenu.focus = true;
|
||||
topMenu.forceActiveFocus();
|
||||
// show current menu level on nav bar
|
||||
if (topMenu.objectName === "") {
|
||||
if (topMenu.objectName === "" || menuStack.length === 1) {
|
||||
breadcrumbText.text = "Menu";
|
||||
} else {
|
||||
if (menuStack.length === 1) {
|
||||
breadcrumbText.text = "Menu";
|
||||
} else {
|
||||
breadcrumbText.text = topMenu.objectName;
|
||||
}
|
||||
breadcrumbText.text = topMenu.objectName;
|
||||
}
|
||||
} else {
|
||||
breadcrumbText.text = "Menu";
|
||||
|
|
|
@ -133,12 +133,29 @@ QString Web3DOverlay::pickURL() {
|
|||
|
||||
void Web3DOverlay::loadSourceURL() {
|
||||
|
||||
// if (_javaScriptToInject == "") {
|
||||
// QString javaScriptToInject;
|
||||
// QFile webChannelFile(":qtwebchannel/qwebchannel.js");
|
||||
// QFile createGlobalEventBridgeFile(PathUtils::resourcesPath() + "/html/createGlobalEventBridge.js");
|
||||
// if (webChannelFile.open(QFile::ReadOnly | QFile::Text) &&
|
||||
// createGlobalEventBridgeFile.open(QFile::ReadOnly | QFile::Text)) {
|
||||
// QString webChannelStr = QTextStream(&webChannelFile).readAll();
|
||||
// QString createGlobalEventBridgeStr = QTextStream(&createGlobalEventBridgeFile).readAll();
|
||||
// // concatenate these js files
|
||||
// _javaScriptToInject = webChannelStr + createGlobalEventBridgeStr;
|
||||
// }
|
||||
// }
|
||||
|
||||
QUrl sourceUrl(_url);
|
||||
if (sourceUrl.scheme() == "http" || sourceUrl.scheme() == "https" ||
|
||||
_url.toLower().endsWith(".htm") || _url.toLower().endsWith(".html")) {
|
||||
|
||||
_webSurface->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
|
||||
_webSurface->load("Web3DOverlay.qml");
|
||||
// _webSurface->load("Web3DOverlay.qml", [&](QQmlContext* context, QObject* obj) {
|
||||
// qDebug() << "Web3DOverlay::loadSourceURL -- " << _javaScriptToInject;
|
||||
// context->setContextProperty("eventBridgeJavaScriptToInject", QVariant(_javaScriptToInject));
|
||||
// });
|
||||
_webSurface->resume();
|
||||
_webSurface->getRootItem()->setProperty("url", _url);
|
||||
_webSurface->getRootItem()->setProperty("scriptURL", _scriptURL);
|
||||
|
|
|
@ -82,6 +82,8 @@ private:
|
|||
|
||||
QMetaObject::Connection _emitScriptEventConnection;
|
||||
QMetaObject::Connection _webEventReceivedConnection;
|
||||
|
||||
// QString _javaScriptToInject;
|
||||
};
|
||||
|
||||
#endif // hifi_Web3DOverlay_h
|
||||
|
|
|
@ -215,6 +215,7 @@ void TabletProxy::gotoMenuScreen() {
|
|||
void TabletProxy::loadQMLSource(const QVariant& path) {
|
||||
if (_qmlTabletRoot) {
|
||||
if (_state != State::QML) {
|
||||
// _qmlTabletRoot->setProperty("eventBridge", QVariant::fromValue(_qmlOffscreenSurface));
|
||||
QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, path));
|
||||
_state = State::QML;
|
||||
}
|
||||
|
@ -370,7 +371,7 @@ QQuickItem* TabletProxy::getQmlTablet() const {
|
|||
}
|
||||
|
||||
QQuickItem* TabletProxy::getQmlMenu() const {
|
||||
if (!_qmlTabletRoot) {
|
||||
if (!_qmlTabletRoot) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -391,6 +392,15 @@ QQuickItem* TabletProxy::getQmlMenu() const {
|
|||
return menuList;
|
||||
}
|
||||
|
||||
QQuickItem* TabletProxy::findChild(QString childName) const {
|
||||
if (!_qmlTabletRoot) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return _qmlTabletRoot->findChild<QQuickItem*>(childName);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// TabletButtonProxy
|
||||
//
|
||||
|
|
|
@ -130,6 +130,8 @@ public:
|
|||
|
||||
QQuickItem* getQmlMenu() const;
|
||||
|
||||
Q_INVOKABLE QQuickItem* findChild(QString childName) const;
|
||||
|
||||
signals:
|
||||
/**jsdoc
|
||||
* Signaled when this tablet receives an event from the html/js embedded in the tablet
|
||||
|
|
|
@ -457,7 +457,7 @@ var toolBar = (function () {
|
|||
|
||||
that.toggle = function () {
|
||||
that.setActive(!isActive);
|
||||
activeButton.editProperties({isActive: isActive});
|
||||
// activeButton.editProperties({isActive: isActive});
|
||||
};
|
||||
|
||||
that.setActive = function (active) {
|
||||
|
@ -1436,11 +1436,12 @@ var ServerScriptStatusMonitor = function(entityID, statusCallback) {
|
|||
var PropertiesTool = function (opts) {
|
||||
var that = {};
|
||||
|
||||
var webView = new OverlayWebWindow({
|
||||
title: 'Entity Properties',
|
||||
source: ENTITY_PROPERTIES_URL,
|
||||
toolWindow: true
|
||||
});
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
// var webView = new OverlayWebWindow({
|
||||
// title: 'Entity Properties',
|
||||
// source: ENTITY_PROPERTIES_URL,
|
||||
// toolWindow: true
|
||||
// });
|
||||
|
||||
var visible = false;
|
||||
|
||||
|
@ -1449,16 +1450,20 @@ var PropertiesTool = function (opts) {
|
|||
var currentSelectedEntityID = null;
|
||||
var statusMonitor = null;
|
||||
|
||||
webView.setVisible(visible);
|
||||
// webView.setVisible(visible);
|
||||
|
||||
that.setVisible = function (newVisible) {
|
||||
print("PropertiesTool.setVisible --> " + newVisible);
|
||||
visible = newVisible;
|
||||
webView.setVisible(visible);
|
||||
// webView.setVisible(visible);
|
||||
if (visible) {
|
||||
tablet.loadQMLSource("Edit.qml");
|
||||
}
|
||||
};
|
||||
|
||||
function updateScriptStatus(info) {
|
||||
info.type = "server_script_status";
|
||||
webView.emitScriptEvent(JSON.stringify(info));
|
||||
tablet.emitScriptEvent(JSON.stringify(info));
|
||||
};
|
||||
|
||||
function resetScriptStatus() {
|
||||
|
@ -1510,10 +1515,10 @@ var PropertiesTool = function (opts) {
|
|||
selections.push(entity);
|
||||
}
|
||||
data.selections = selections;
|
||||
webView.emitScriptEvent(JSON.stringify(data));
|
||||
tablet.emitScriptEvent(JSON.stringify(data));
|
||||
});
|
||||
|
||||
webView.webEventReceived.connect(function (data) {
|
||||
tablet.webEventReceived.connect(function (data) {
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
|
|
|
@ -710,6 +710,7 @@ function loaded() {
|
|||
|
||||
if (window.EventBridge !== undefined) {
|
||||
var properties;
|
||||
console.log("HERE -- " + (typeof EventBridge) + " -- " + JSON.stringify(EventBridge));
|
||||
EventBridge.scriptEventReceived.connect(function(data) {
|
||||
data = JSON.parse(data);
|
||||
if (data.type == "server_script_status") {
|
||||
|
|
Loading…
Reference in a new issue