popup windows

This commit is contained in:
James B. Pollack 2016-02-19 13:48:54 -08:00
parent e3ae2baa7b
commit 66e8f070e4
3 changed files with 27 additions and 12 deletions

View file

@ -14,7 +14,8 @@ Window {
destroyOnInvisible: true destroyOnInvisible: true
width: 800 width: 800
height: 600 height: 600
property alias webView: webview
Component.onCompleted: { Component.onCompleted: {
visible = true visible = true
addressBar.text = webview.url addressBar.text = webview.url
@ -28,6 +29,7 @@ Window {
} }
Item { Item {
id:item
anchors.fill: parent anchors.fill: parent
Rectangle { Rectangle {
anchors.left: parent.left anchors.left: parent.left
@ -125,12 +127,10 @@ Window {
console.log("New icon: " + icon) console.log("New icon: " + icon)
} }
profile: WebEngineProfile { profile: desktop.browserProfile
id: webviewProfile
storageName: "qmlUserBrowser"
}
} }
} // item } // item
Keys.onPressed: { Keys.onPressed: {

View file

@ -11,6 +11,7 @@ WebEngineView {
root.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) { root.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);
}); });
} }
// FIXME hack to get the URL with the auth token included. Remove when we move to Qt 5.6 // FIXME hack to get the URL with the auth token included. Remove when we move to Qt 5.6
@ -36,6 +37,11 @@ WebEngineView {
} }
} }
onFeaturePermissionRequested: {
console.log('permission requested',securityOrigin, feature)
grantFeaturePermission(securityOrigin, feature, true);
}
onLoadingChanged: { onLoadingChanged: {
// Required to support clicking on "hifi://" links // Required to support clicking on "hifi://" links
if (WebEngineView.LoadStartedStatus == loadRequest.status) { if (WebEngineView.LoadStartedStatus == loadRequest.status) {
@ -48,9 +54,12 @@ WebEngineView {
} }
} }
profile: WebEngineProfile { onNewViewRequested:{
id: webviewProfile var component = Qt.createComponent("../Browser.qml");
httpUserAgent: "Mozilla/5.0 (HighFidelityInterface)" var newWindow = component.createObject(desktop);
storageName: "qmlWebEngine" request.openIn(newWindow.webView)
} }
profile: desktop.browserProfile
} }

View file

@ -9,8 +9,8 @@ Desktop {
id: desktop id: desktop
Component.onCompleted: { Component.onCompleted: {
WebEngine.settings.javascriptCanOpenWindows = false; WebEngine.settings.javascriptCanOpenWindows = true;
WebEngine.settings.javascriptCanAccessClipboard = false; WebEngine.settings.javascriptCanAccessClipboard = true;
WebEngine.settings.spatialNavigationEnabled = true; WebEngine.settings.spatialNavigationEnabled = true;
WebEngine.settings.localContentCanAccessRemoteUrls = true; WebEngine.settings.localContentCanAccessRemoteUrls = true;
} }
@ -18,6 +18,12 @@ Desktop {
// The tool window, one instance // The tool window, one instance
property alias toolWindow: toolWindow property alias toolWindow: toolWindow
ToolWindow { id: toolWindow } ToolWindow { id: toolWindow }
property var browserProfile: WebEngineProfile {
id: webviewProfile
httpUserAgent: "Chrome/48.0 (HighFidelityInterface)"
storageName: "qmlWebEngine"
}
Action { Action {
text: "Open Browser" text: "Open Browser"