Move common webview flickable code to separate core file

This commit is contained in:
vladest 2017-08-24 21:35:47 +02:00
parent 34c091114d
commit c7fe845403
6 changed files with 409 additions and 340 deletions

View file

@ -1,7 +1,7 @@
import QtQuick 2.5 import QtQuick 2.5
import QtQuick.Controls 1.4 import QtQuick.Controls 1.4
import QtWebChannel 1.0 import QtWebChannel 1.0
import QtWebEngine 1.2 import QtWebEngine 1.5
import "controls" import "controls"
import "controls-uit" as HifiControls import "controls-uit" as HifiControls
@ -17,7 +17,7 @@ Item {
height: 600 height: 600
property variant permissionsBar: {'securityOrigin':'none','feature':'none'} property variant permissionsBar: {'securityOrigin':'none','feature':'none'}
property alias url: webview.url property alias url: webview.url
property WebEngineView webView: webview //property WebEngineView webView: webview
property bool canGoBack: webview.canGoBack property bool canGoBack: webview.canGoBack
property bool canGoForward: webview.canGoForward property bool canGoForward: webview.canGoForward

View file

@ -9,7 +9,7 @@
// //
import QtQuick 2.5 import QtQuick 2.5
import QtWebEngine 1.2 import QtWebEngine 1.5
WebEngineView { WebEngineView {
id: root id: root

View file

@ -9,11 +9,13 @@
// //
import QtQuick 2.5 import QtQuick 2.5
import QtWebEngine 1.5
AnimatedImage { AnimatedImage {
property Item webroot: parent property WebEngineView webview: parent
source: "../../icons/loader-snake-64-w.gif" source: "../../icons/loader-snake-64-w.gif"
visible: webroot.loading && /^(http.*|)$/i.test(webroot.url.toString()) visible: webview.loading && /^(http.*|)$/i.test(webview.url.toString())
playing: visible
z: 10000 z: 10000
anchors { anchors {
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter

View file

@ -1,6 +1,4 @@
import QtQuick 2.7 import QtQuick 2.7
import QtWebEngine 1.5
import QtWebChannel 1.0
import "../controls-uit" as HiFiControls import "../controls-uit" as HiFiControls
Item { Item {
@ -8,7 +6,7 @@ Item {
property alias url: webroot.url property alias url: webroot.url
property alias scriptURL: webroot.userScriptUrl property alias scriptURL: webroot.userScriptUrl
property alias canGoBack: webroot.canGoBack; property alias canGoBack: webroot.canGoBack;
property var goBack: webroot.goBack; property var goBack: webroot.webViewCore.goBack;
property alias urlTag: webroot.urlTag property alias urlTag: webroot.urlTag
property bool keyboardEnabled: true // FIXME - Keyboard HMD only: Default to false property bool keyboardEnabled: true // FIXME - Keyboard HMD only: Default to false
property bool keyboardRaised: false property bool keyboardRaised: false
@ -22,117 +20,139 @@ Item {
} }
*/ */
property alias viewProfile: webroot.profile property alias viewProfile: webroot.webViewCoreProfile
Flickable { FlickableWebViewCore {
id: flick id: webroot
width: parent.width width: parent.width
height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height
WebEngineView { onLoadingChangedCallback: {
id: webroot keyboardRaised = false;
objectName: "webEngineView" punctuationMode = false;
anchors.fill: parent keyboard.resetShiftMode(false);
}
profile: HFWebEngineProfile; onNewViewRequestedCallback: {
// desktop is not defined for web-entities or tablet
property string userScriptUrl: "" if (typeof desktop !== "undefined") {
desktop.openBrowserWindow(request, profile);
// creates a global EventBridge object. } else {
WebEngineScript { tabletRoot.openBrowserWindow(request, profile);
id: createGlobalEventBridge
sourceCode: eventBridgeJavaScriptToInject
injectionPoint: WebEngineScript.DocumentCreation
worldId: WebEngineScript.MainWorld
}
// detects when to raise and lower virtual keyboard
WebEngineScript {
id: raiseAndLowerKeyboard
injectionPoint: WebEngineScript.Deferred
sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js"
worldId: WebEngineScript.MainWorld
}
// User script.
WebEngineScript {
id: userScript
sourceUrl: webroot.userScriptUrl
injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished.
worldId: WebEngineScript.MainWorld
}
property string urlTag: "noDownload=false";
userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ]
property string newUrl: ""
//disable popup
onContextMenuRequested: {
request.accepted = true;
}
onContentsSizeChanged: {
flick.contentHeight = Math.max(contentsSize.height, flick.height);
flick.contentWidth = flick.width
}
Component.onCompleted: {
webChannel.registerObject("eventBridge", eventBridge);
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
// Ensure the JS from the web-engine makes it to our logging
webroot.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
});
webroot.profile.httpUserAgent = "Mozilla/5.0 Chrome (HighFidelityInterface)";
}
onFeaturePermissionRequested: {
grantFeaturePermission(securityOrigin, feature, true);
}
onLoadingChanged: {
keyboardRaised = false;
punctuationMode = false;
keyboard.resetShiftMode(false);
// Required to support clicking on "hifi://" links
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
flick.contentWidth = 0
flick.contentHeight = 0
var url = loadRequest.url.toString();
url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
if (urlHandler.canHandleUrl(url)) {
if (urlHandler.handleUrl(url)) {
webroot.stop();
}
}
}
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
webroot.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) {
flick.contentHeight = Math.max(i_actualPageHeight, flick.height);
})
flick.contentWidth = flick.width
}
}
onNewViewRequested:{
// desktop is not defined for web-entities or tablet
if (typeof desktop !== "undefined") {
desktop.openBrowserWindow(request, profile);
} else {
tabletRoot.openBrowserWindow(request, profile);
}
} }
} }
} }
HiFiControls.WebSpinner { // Flickable {
anchors.centerIn: parent // id: flick
webroot: webroot // width: parent.width
} // height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height
// WebEngineView {
// id: webroot
// objectName: "webEngineView"
// anchors.fill: parent
// profile: HFWebEngineProfile;
// property string userScriptUrl: ""
// // creates a global EventBridge object.
// WebEngineScript {
// id: createGlobalEventBridge
// sourceCode: eventBridgeJavaScriptToInject
// injectionPoint: WebEngineScript.DocumentCreation
// worldId: WebEngineScript.MainWorld
// }
// // detects when to raise and lower virtual keyboard
// WebEngineScript {
// id: raiseAndLowerKeyboard
// injectionPoint: WebEngineScript.Deferred
// sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js"
// worldId: WebEngineScript.MainWorld
// }
// // User script.
// WebEngineScript {
// id: userScript
// sourceUrl: webroot.userScriptUrl
// injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished.
// worldId: WebEngineScript.MainWorld
// }
// property string urlTag: "noDownload=false";
// userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ]
// property string newUrl: ""
// //disable popup
// onContextMenuRequested: {
// request.accepted = true;
// }
// onContentsSizeChanged: {
// flick.contentHeight = Math.max(contentsSize.height, flick.height);
// flick.contentWidth = flick.width
// }
// Component.onCompleted: {
// webChannel.registerObject("eventBridge", eventBridge);
// webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
// // Ensure the JS from the web-engine makes it to our logging
// webroot.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
// console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
// });
// webroot.profile.httpUserAgent = "Mozilla/5.0 Chrome (HighFidelityInterface)";
// }
// onFeaturePermissionRequested: {
// grantFeaturePermission(securityOrigin, feature, true);
// }
// onLoadingChanged: {
// keyboardRaised = false;
// punctuationMode = false;
// keyboard.resetShiftMode(false);
// // Required to support clicking on "hifi://" links
// if (WebEngineView.LoadStartedStatus == loadRequest.status) {
// flick.contentWidth = 0
// flick.contentHeight = 0
// var url = loadRequest.url.toString();
// url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
// if (urlHandler.canHandleUrl(url)) {
// if (urlHandler.handleUrl(url)) {
// webroot.stop();
// }
// }
// }
// if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
// webroot.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) {
// flick.contentHeight = Math.max(i_actualPageHeight, flick.height);
// })
// flick.contentWidth = flick.width
// }
// }
// onNewViewRequested:{
// // desktop is not defined for web-entities or tablet
// if (typeof desktop !== "undefined") {
// desktop.openBrowserWindow(request, profile);
// } else {
// tabletRoot.openBrowserWindow(request, profile);
// }
// }
// }
// }
// HiFiControls.WebSpinner {
// anchors.centerIn: parent
// webroot: webroot
// }
HiFiControls.Keyboard { HiFiControls.Keyboard {
id: keyboard id: keyboard

View file

@ -1,15 +1,15 @@
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 1.4 //import QtQuick.Controls 1.4
import QtWebEngine 1.5 import QtWebEngine 1.5
import QtWebChannel 1.0 //import QtWebChannel 1.0
import "../controls-uit" as HiFiControls import "../controls-uit" as HiFiControls
import "../styles" as HifiStyles import "../styles" as HifiStyles
import "../styles-uit" import "../styles-uit"
import "../" //import "../"
import "." //import "."
Item { Item {
id: web id: root
HifiConstants { id: hifi } HifiConstants { id: hifi }
width: parent !== null ? parent.width : undefined width: parent !== null ? parent.width : undefined
height: parent !== null ? parent.height : undefined height: parent !== null ? parent.height : undefined
@ -21,8 +21,8 @@ Item {
property bool keyboardRaised: false property bool keyboardRaised: false
property bool punctuationMode: false property bool punctuationMode: false
property bool isDesktop: false property bool isDesktop: false
property alias webView: webview property alias webView: web.webViewCore
property alias profile: webview.profile property alias profile: web.webViewCoreProfile
property bool remove: false property bool remove: false
property bool closeButtonVisible: true property bool closeButtonVisible: true
@ -79,7 +79,7 @@ Item {
color: hifi.colors.baseGray color: hifi.colors.baseGray
font.pixelSize: 12 font.pixelSize: 12
verticalAlignment: Text.AlignLeft verticalAlignment: Text.AlignLeft
text: webview.url text: root.url
anchors { anchors {
top: nav.bottom top: nav.bottom
horizontalCenter: parent.horizontalCenter; horizontalCenter: parent.horizontalCenter;
@ -104,13 +104,13 @@ Item {
function closeWebEngine() { function closeWebEngine() {
if (remove) { if (remove) {
web.destroy(); root.destroy();
return; return;
} }
if (parentStackItem) { if (parentStackItem) {
parentStackItem.pop(); parentStackItem.pop();
} else { } else {
web.visible = false; root.visible = false;
} }
} }
@ -128,131 +128,160 @@ Item {
} }
function loadUrl(url) { function loadUrl(url) {
webview.url = url web.webViewCore.url = url
web.url = webview.url; root.url = web.webViewCore.url;
} }
onUrlChanged: { onUrlChanged: {
loadUrl(url); loadUrl(url);
} }
Flickable { FlickableWebViewCore {
id: flick id: web
width: parent.width width: parent.width
height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height - web.headerHeight : parent.height - web.headerHeight height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height - root.headerHeight : parent.height - root.headerHeight
anchors.top: buttons.bottom anchors.top: buttons.bottom
WebEngineView { onUrlChanged: {
id: webview // Record history, skipping null and duplicate items.
objectName: "webEngineView" var urlString = url + "";
anchors.fill: parent urlString = urlString.replace(/\//g, "%2F"); // Consistent representation of "/"s to avoid false differences.
if (urlString.length > 0 && (historyIndex === -1 || urlString !== history[historyIndex])) {
profile: HFWebEngineProfile; historyIndex++;
history = history.slice(0, historyIndex);
property string userScriptUrl: "" history.push(urlString);
// creates a global EventBridge object.
WebEngineScript {
id: createGlobalEventBridge
sourceCode: eventBridgeJavaScriptToInject
injectionPoint: WebEngineScript.DocumentCreation
worldId: WebEngineScript.MainWorld
} }
}
// detects when to raise and lower virtual keyboard onLoadingChangedCallback: {
WebEngineScript { keyboardRaised = false;
id: raiseAndLowerKeyboard punctuationMode = false;
injectionPoint: WebEngineScript.Deferred keyboard.resetShiftMode(false);
sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js" webViewCore.forceActiveFocus();
worldId: WebEngineScript.MainWorld }
}
// User script. onNewViewRequestedCallback: {
WebEngineScript { request.openIn(webViewCore);
id: userScript
sourceUrl: webview.userScriptUrl
injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished.
worldId: WebEngineScript.MainWorld
}
property string urlTag: "noDownload=false";
userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ]
property string newUrl: ""
Component.onCompleted: {
webChannel.registerObject("eventBridge", eventBridge);
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
// Ensure the JS from the web-engine makes it to our logging
webview.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
});
}
onFeaturePermissionRequested: {
grantFeaturePermission(securityOrigin, feature, true);
}
onUrlChanged: {
// Record history, skipping null and duplicate items.
var urlString = url + "";
urlString = urlString.replace(/\//g, "%2F"); // Consistent representation of "/"s to avoid false differences.
if (urlString.length > 0 && (historyIndex === -1 || urlString !== history[historyIndex])) {
historyIndex++;
history = history.slice(0, historyIndex);
history.push(urlString);
}
}
onContentsSizeChanged: {
flick.contentHeight = Math.max(contentsSize.height, flick.height);
flick.contentWidth = flick.width
}
//disable popup
onContextMenuRequested: {
request.accepted = true;
}
onLoadingChanged: {
keyboardRaised = false;
punctuationMode = false;
keyboard.resetShiftMode(false);
// Required to support clicking on "hifi://" links
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
flick.contentWidth = 0
flick.contentHeight = 0
var url = loadRequest.url.toString();
if (urlHandler.canHandleUrl(url)) {
if (urlHandler.handleUrl(url)) {
root.stop();
}
}
}
if (WebEngineView.LoadFailedStatus == loadRequest.status) {
console.log(" Tablet WebEngineView failed to load url: " + loadRequest.url.toString());
}
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
webview.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) {
flick.contentHeight = Math.max(i_actualPageHeight, flick.height);
})
flick.contentWidth = flick.width
webview.forceActiveFocus();
}
}
onNewViewRequested: {
request.openIn(webview);
}
} }
} }
HiFiControls.WebSpinner { // Flickable {
webroot: webview // id: flick
anchors.centerIn: parent // width: parent.width
} // height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height - web.headerHeight : parent.height - web.headerHeight
// anchors.top: buttons.bottom
// WebEngineView {
// id: webview
// objectName: "webEngineView"
// anchors.fill: parent
// profile: HFWebEngineProfile;
// property string userScriptUrl: ""
// // creates a global EventBridge object.
// WebEngineScript {
// id: createGlobalEventBridge
// sourceCode: eventBridgeJavaScriptToInject
// injectionPoint: WebEngineScript.DocumentCreation
// worldId: WebEngineScript.MainWorld
// }
// // detects when to raise and lower virtual keyboard
// WebEngineScript {
// id: raiseAndLowerKeyboard
// injectionPoint: WebEngineScript.Deferred
// sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js"
// worldId: WebEngineScript.MainWorld
// }
// // User script.
// WebEngineScript {
// id: userScript
// sourceUrl: webview.userScriptUrl
// injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished.
// worldId: WebEngineScript.MainWorld
// }
// property string urlTag: "noDownload=false";
// userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ]
// property string newUrl: ""
// Component.onCompleted: {
// webChannel.registerObject("eventBridge", eventBridge);
// webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
// // Ensure the JS from the web-engine makes it to our logging
// webview.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
// console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
// });
// }
// onFeaturePermissionRequested: {
// grantFeaturePermission(securityOrigin, feature, true);
// }
// onUrlChanged: {
// // Record history, skipping null and duplicate items.
// var urlString = url + "";
// urlString = urlString.replace(/\//g, "%2F"); // Consistent representation of "/"s to avoid false differences.
// if (urlString.length > 0 && (historyIndex === -1 || urlString !== history[historyIndex])) {
// historyIndex++;
// history = history.slice(0, historyIndex);
// history.push(urlString);
// }
// }
// onContentsSizeChanged: {
// flick.contentHeight = Math.max(contentsSize.height, flick.height);
// flick.contentWidth = flick.width
// }
// //disable popup
// onContextMenuRequested: {
// request.accepted = true;
// }
// onLoadingChanged: {
// keyboardRaised = false;
// punctuationMode = false;
// keyboard.resetShiftMode(false);
// // Required to support clicking on "hifi://" links
// if (WebEngineView.LoadStartedStatus == loadRequest.status) {
// flick.contentWidth = 0
// flick.contentHeight = 0
// var url = loadRequest.url.toString();
// if (urlHandler.canHandleUrl(url)) {
// if (urlHandler.handleUrl(url)) {
// root.stop();
// }
// }
// }
// if (WebEngineView.LoadFailedStatus == loadRequest.status) {
// console.log(" Tablet WebEngineView failed to load url: " + loadRequest.url.toString());
// }
// if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
// webview.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) {
// flick.contentHeight = Math.max(i_actualPageHeight, flick.height);
// })
// flick.contentWidth = flick.width
// webview.forceActiveFocus();
// }
// }
// onNewViewRequested: {
// request.openIn(webview);
// }
// }
// }
// HiFiControls.WebSpinner {
// webview: webview
// anchors.centerIn: parent
// }
HiFiControls.Keyboard { HiFiControls.Keyboard {
id: keyboard id: keyboard
@ -267,7 +296,7 @@ Item {
} }
Component.onCompleted: { Component.onCompleted: {
web.isDesktop = (typeof desktop !== "undefined"); root.isDesktop = (typeof desktop !== "undefined");
keyboardEnabled = HMD.active; keyboardEnabled = HMD.active;
} }

View file

@ -1,17 +1,15 @@
import QtQuick 2.7 import QtQuick 2.7
import QtWebEngine 1.5
import QtWebChannel 1.0
import "../controls-uit" as HiFiControls import "../controls-uit" as HiFiControls
Item { Item {
width: parent !== null ? parent.width : undefined width: parent !== null ? parent.width : undefined
height: parent !== null ? parent.height : undefined height: parent !== null ? parent.height : undefined
property alias url: root.url property alias url: webroot.url
property alias scriptURL: root.userScriptUrl property alias scriptURL: webroot.userScriptUrl
property alias canGoBack: root.canGoBack; property alias canGoBack: webroot.canGoBack;
property var goBack: root.goBack; property var goBack: webroot.webViewCore.goBack;
property alias urlTag: root.urlTag property alias urlTag: webroot.urlTag
property bool keyboardEnabled: true // FIXME - Keyboard HMD only: Default to false property bool keyboardEnabled: true // FIXME - Keyboard HMD only: Default to false
property bool keyboardRaised: false property bool keyboardRaised: false
property bool punctuationMode: false property bool punctuationMode: false
@ -24,116 +22,137 @@ Item {
} }
*/ */
property alias viewProfile: root.profile property alias viewProfile: webroot.webViewCoreProfile
Flickable { FlickableWebViewCore {
id: flick id: webroot
width: parent.width width: parent.width
height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height
WebEngineView { onLoadingChangedCallback: {
id: root keyboardRaised = false;
objectName: "webEngineView" punctuationMode = false;
anchors.fill: parent keyboard.resetShiftMode(false);
}
profile: HFWebEngineProfile; onNewViewRequestedCallback: {
// desktop is not defined for web-entities or tablet
property string userScriptUrl: "" if (typeof desktop !== "undefined") {
desktop.openBrowserWindow(request, profile);
// creates a global EventBridge object. } else {
WebEngineScript { tabletRoot.openBrowserWindow(request, profile);
id: createGlobalEventBridge
sourceCode: eventBridgeJavaScriptToInject
injectionPoint: WebEngineScript.DocumentCreation
worldId: WebEngineScript.MainWorld
}
// detects when to raise and lower virtual keyboard
WebEngineScript {
id: raiseAndLowerKeyboard
injectionPoint: WebEngineScript.Deferred
sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js"
worldId: WebEngineScript.MainWorld
}
// User script.
WebEngineScript {
id: userScript
sourceUrl: root.userScriptUrl
injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished.
worldId: WebEngineScript.MainWorld
}
property string urlTag: "noDownload=false";
userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ]
property string newUrl: ""
Component.onCompleted: {
webChannel.registerObject("eventBridge", eventBridge);
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
// Ensure the JS from the web-engine makes it to our logging
root.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
});
}
onFeaturePermissionRequested: {
grantFeaturePermission(securityOrigin, feature, true);
}
onContentsSizeChanged: {
console.log("WebView contentsSize", contentsSize)
flick.contentWidth = flick.width
flick.contentHeight = Math.max(contentsSize.height, flick.height)
}
//disable popup
onContextMenuRequested: {
request.accepted = true;
}
onLoadingChanged: {
keyboardRaised = false;
punctuationMode = false;
keyboard.resetShiftMode(false);
// Required to support clicking on "hifi://" links
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
flick.contentWidth = 0
flick.contentHeight = 0
var url = loadRequest.url.toString();
url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
if (urlHandler.canHandleUrl(url)) {
if (urlHandler.handleUrl(url)) {
root.stop();
}
}
}
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
root.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) {
flick.contentHeight = Math.max(i_actualPageHeight, flick.height);
})
flick.contentWidth = flick.width
}
}
onNewViewRequested:{
// desktop is not defined for web-entities or tablet
if (typeof desktop !== "undefined") {
desktop.openBrowserWindow(request, profile);
} else {
tabletRoot.openBrowserWindow(request, profile);
}
} }
} }
} }
HiFiControls.WebSpinner { // Flickable {
anchors.centerIn: parent // id: flick
webroot: root // width: parent.width
} // height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height
// WebEngineView {
// id: root
// objectName: "webEngineView"
// anchors.fill: parent
// profile: HFWebEngineProfile;
// property string userScriptUrl: ""
// // creates a global EventBridge object.
// WebEngineScript {
// id: createGlobalEventBridge
// sourceCode: eventBridgeJavaScriptToInject
// injectionPoint: WebEngineScript.DocumentCreation
// worldId: WebEngineScript.MainWorld
// }
// // detects when to raise and lower virtual keyboard
// WebEngineScript {
// id: raiseAndLowerKeyboard
// injectionPoint: WebEngineScript.Deferred
// sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js"
// worldId: WebEngineScript.MainWorld
// }
// // User script.
// WebEngineScript {
// id: userScript
// sourceUrl: root.userScriptUrl
// injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished.
// worldId: WebEngineScript.MainWorld
// }
// property string urlTag: "noDownload=false";
// userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ]
// property string newUrl: ""
// Component.onCompleted: {
// webChannel.registerObject("eventBridge", eventBridge);
// webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
// // Ensure the JS from the web-engine makes it to our logging
// root.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
// console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
// });
// }
// onFeaturePermissionRequested: {
// grantFeaturePermission(securityOrigin, feature, true);
// }
// onContentsSizeChanged: {
// console.log("WebView contentsSize", contentsSize)
// flick.contentWidth = flick.width
// flick.contentHeight = Math.max(contentsSize.height, flick.height)
// }
// //disable popup
// onContextMenuRequested: {
// request.accepted = true;
// }
// onLoadingChanged: {
// keyboardRaised = false;
// punctuationMode = false;
// keyboard.resetShiftMode(false);
// // Required to support clicking on "hifi://" links
// if (WebEngineView.LoadStartedStatus == loadRequest.status) {
// flick.contentWidth = 0
// flick.contentHeight = 0
// var url = loadRequest.url.toString();
// url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
// if (urlHandler.canHandleUrl(url)) {
// if (urlHandler.handleUrl(url)) {
// root.stop();
// }
// }
// }
// if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
// root.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) {
// flick.contentHeight = Math.max(i_actualPageHeight, flick.height);
// })
// flick.contentWidth = flick.width
// }
// }
// onNewViewRequested:{
// // desktop is not defined for web-entities or tablet
// if (typeof desktop !== "undefined") {
// desktop.openBrowserWindow(request, profile);
// } else {
// tabletRoot.openBrowserWindow(request, profile);
// }
// }
// }
// }
// HiFiControls.WebSpinner {
// anchors.centerIn: parent
// webroot: root
// }
HiFiControls.Keyboard { HiFiControls.Keyboard {
id: keyboard id: keyboard
@ -145,5 +164,4 @@ Item {
bottom: parent.bottom bottom: parent.bottom
} }
} }
} }