Merge branch 'feature/qml_whitelist_tablet' of https://github.com/jherico/hifi into commerce_QmlWhitelist

This commit is contained in:
Zach Fox 2017-11-08 09:32:09 -08:00
commit 845ff64c1e
2 changed files with 67 additions and 28 deletions

View file

@ -202,8 +202,16 @@ Item {
} }
function load(newSource, callback) { function load(newSource, callback) {
loader.source = newSource; if (loader.source == newSource) {
loader.item = null; loader.loaded();
return;
}
if (loader.item) {
loader.item.destroy();
loader.item = null;
}
QmlSurface.load(newSource, loader, function(newItem) { QmlSurface.load(newSource, loader, function(newItem) {
loader.item = newItem; loader.item = newItem;
loader.item.width = loader.width; loader.item.width = loader.width;
@ -232,7 +240,6 @@ Item {
callback(); callback();
} }
}); });
console.log("QQQ done calling QmlSurface.load")
} }
} }

View file

@ -59,18 +59,15 @@ Windows.ScrollingWindow {
} }
function loadSource(url) { function loadSource(url) {
loader.source = ""; // make sure we load the qml fresh each time. loader.load(url)
loader.source = url;
} }
function loadWebBase() { function loadWebBase() {
loader.source = ""; loader.load("hifi/tablet/TabletWebView.qml");
loader.source = "WindowWebView.qml";
} }
function loadTabletWebBase() { function loadTabletWebBase() {
loader.source = ""; loader.load("hifi/tablet/BlocksWebView.qml");
loader.source = "./BlocksWebView.qml";
} }
function loadWebUrl(url, injectedJavaScriptUrl) { function loadWebUrl(url, injectedJavaScriptUrl) {
@ -111,38 +108,73 @@ Windows.ScrollingWindow {
username = newUsername; username = newUsername;
} }
Loader { // Hook up callback for clara.io download from the marketplace.
Connections {
id: eventBridgeConnection
target: eventBridge
onWebEventReceived: {
if (message.slice(0, 17) === "CLARA.IO DOWNLOAD") {
ApplicationInterface.addAssetToWorldFromURL(message.slice(18));
}
}
}
Item {
id: loader id: loader
objectName: "loader" objectName: "loader";
asynchronous: false property string source: "";
property var item: null;
height: pane.scrollHeight height: pane.scrollHeight
width: pane.contentWidth width: pane.contentWidth
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
signal loaded;
// Hook up callback for clara.io download from the marketplace.
Connections { onWidthChanged: {
id: eventBridgeConnection if (loader.item) {
target: eventBridge loader.item.width = loader.width;
onWebEventReceived: {
if (message.slice(0, 17) === "CLARA.IO DOWNLOAD") {
ApplicationInterface.addAssetToWorldFromURL(message.slice(18));
}
} }
} }
onHeightChanged: {
if (loader.item) {
loader.item.height = loader.height;
}
}
function load(newSource, callback) {
if (loader.source == newSource) {
loader.loaded();
return;
}
onLoaded: { if (loader.item) {
if (loader.item.hasOwnProperty("sendToScript")) { loader.item.destroy();
loader.item.sendToScript.connect(tabletRoot.sendToScript); loader.item = null;
} }
if (loader.item.hasOwnProperty("setRootMenu")) {
loader.item.setRootMenu(tabletRoot.rootMenu, tabletRoot.subMenu); QmlSurface.load(newSource, loader, function(newItem) {
} loader.item = newItem;
loader.item.forceActiveFocus(); loader.item.width = loader.width;
loader.item.height = loader.height;
loader.loaded();
if (loader.item.hasOwnProperty("sendToScript")) {
loader.item.sendToScript.connect(tabletRoot.sendToScript);
}
if (loader.item.hasOwnProperty("setRootMenu")) {
loader.item.setRootMenu(tabletRoot.rootMenu, tabletRoot.subMenu);
}
loader.item.forceActiveFocus();
if (callback) {
callback();
}
});
} }
} }
implicitWidth: 480 implicitWidth: 480
implicitHeight: 706 implicitHeight: 706
} }