From f4bd2afc8e4dd5417821babfdc310d9ec5ac7dd1 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 30 Dec 2015 11:38:34 -0800 Subject: [PATCH] Make script launched windows invisible at creation time --- examples/directory.js | 9 ++++- interface/resources/qml/QmlWebWindow.qml | 6 ++- interface/resources/qml/QmlWindow.qml | 40 +------------------ interface/resources/qml/controls/VrDialog.qml | 5 +++ libraries/ui/src/QmlWindowClass.cpp | 2 +- 5 files changed, 19 insertions(+), 43 deletions(-) diff --git a/examples/directory.js b/examples/directory.js index d2a3768051..8d9993ffda 100644 --- a/examples/directory.js +++ b/examples/directory.js @@ -62,8 +62,13 @@ var directory = (function () { function setUp() { viewport = Controller.getViewportDimensions(); - directoryWindow = new OverlayWebWindow('Directory', DIRECTORY_URL, 900, 700, false); - directoryWindow.setVisible(false); + directoryWindow = new OverlayWebWindow({ + title: 'Directory', + source: DIRECTORY_URL, + width: 900, + height: 700, + visible: false + }); directoryButton = Overlays.addOverlay("image", { imageURL: DIRECTORY_BUTTON_URL, diff --git a/interface/resources/qml/QmlWebWindow.qml b/interface/resources/qml/QmlWebWindow.qml index d9345e8539..22ff5708dc 100644 --- a/interface/resources/qml/QmlWebWindow.qml +++ b/interface/resources/qml/QmlWebWindow.qml @@ -10,7 +10,8 @@ VrDialog { HifiConstants { id: hifi } title: "WebWindow" resizable: true - enabled: false + enabled: false + visible: false // Don't destroy on close... otherwise the JS/C++ will have a dangling pointer destroyOnCloseButton: false contentImplicitWidth: clientArea.implicitWidth @@ -29,7 +30,7 @@ VrDialog { console.log("Web Window JS message: " + sourceID + " " + lineNumber + " " + message); }); - // Required to support clicking on "hifi://" links + // Required to support clicking on "hifi://" links webview.loadingChanged.connect(handleWebviewLoading) } @@ -54,6 +55,7 @@ VrDialog { id: webview url: root.source anchors.fill: parent + focus: true onUrlChanged: { var currentUrl = url.toString(); diff --git a/interface/resources/qml/QmlWindow.qml b/interface/resources/qml/QmlWindow.qml index c5d942518f..7b79b04343 100644 --- a/interface/resources/qml/QmlWindow.qml +++ b/interface/resources/qml/QmlWindow.qml @@ -14,52 +14,16 @@ VrDialog { title: "QmlWindow" resizable: true enabled: false + visible: false focus: true property var channel; - // Don't destroy on close... otherwise the JS/C++ will have a dangling pointer destroyOnCloseButton: false contentImplicitWidth: clientArea.implicitWidth contentImplicitHeight: clientArea.implicitHeight property alias source: pageLoader.source - /* - WebSocket { - id: socket - url: "ws://localhost:51016"; - active: false - - // the following three properties/functions are required to align the QML WebSocket API with the HTML5 WebSocket API. - property var send: function (arg) { - sendTextMessage(arg); - } - - onTextMessageReceived: { - onmessage({data: message}); - } - - property var onmessage; - - onStatusChanged: { - if (socket.status == WebSocket.Error) { - console.error("Error: " + socket.errorString) - } else if (socket.status == WebSocket.Closed) { - console.log("Socket closed"); - } else if (socket.status == WebSocket.Open) { - console.log("Connected") - //open the webchannel with the socket as transport - new WebChannel.QWebChannel(socket, function(ch) { - root.channel = ch; - var myUrl = root.source.toString().toLowerCase(); - console.log(myUrl); - var bridge = root.channel.objects[myUrl]; - console.log(bridge); - }); - } - } - } - */ Keys.onPressed: { console.log("QmlWindow keypress") } @@ -73,6 +37,7 @@ VrDialog { width: root.clientWidth height: root.clientHeight focus: true + clip: true Loader { id: pageLoader @@ -82,7 +47,6 @@ VrDialog { onLoaded: { console.log("Loaded content") - //socket.active = true; //connect forceActiveFocus() } diff --git a/interface/resources/qml/controls/VrDialog.qml b/interface/resources/qml/controls/VrDialog.qml index aa14e2fcba..411fdbbb0b 100644 --- a/interface/resources/qml/controls/VrDialog.qml +++ b/interface/resources/qml/controls/VrDialog.qml @@ -41,6 +41,11 @@ DialogBase { // modify the visibility onEnabledChanged: { opacity = enabled ? 1.0 : 0.0 + // If the dialog is initially invisible, setting opacity doesn't + // trigger making it visible. + if (enabled) { + visible = true; + } } // The actual animator diff --git a/libraries/ui/src/QmlWindowClass.cpp b/libraries/ui/src/QmlWindowClass.cpp index 29eca50724..956a5a42c7 100644 --- a/libraries/ui/src/QmlWindowClass.cpp +++ b/libraries/ui/src/QmlWindowClass.cpp @@ -122,7 +122,7 @@ QScriptValue QmlWindowClass::internalConstructor(const QString& qmlSource, height = argumentObject.property(HEIGHT_PROPERTY).toInt32(); } if (argumentObject.property(VISIBILE_PROPERTY).isBool()) { - visible = argumentObject.property(VISIBILE_PROPERTY).isBool(); + visible = argumentObject.property(VISIBILE_PROPERTY).toBool(); } }