mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 10:37:56 +02:00
saving work
This commit is contained in:
parent
a2721d21ef
commit
59f84a60c5
6 changed files with 177 additions and 2 deletions
132
interface/resources/qml/controls/TabletWebScreen.qml
Normal file
132
interface/resources/qml/controls/TabletWebScreen.qml
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtWebEngine 1.1
|
||||||
|
import QtWebChannel 1.0
|
||||||
|
import "../controls-uit" as HiFiControls
|
||||||
|
import HFTabletWebEngineProfile 1.0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
property alias url: root.url
|
||||||
|
property alias scriptURL: root.userScriptUrl
|
||||||
|
property alias eventBridge: eventBridgeWrapper.eventBridge
|
||||||
|
property alias canGoBack: root.canGoBack;
|
||||||
|
property var goBack: root.goBack;
|
||||||
|
property alias urlTag: root.urlTag
|
||||||
|
property bool keyboardEnabled: true // FIXME - Keyboard HMD only: Default to false
|
||||||
|
property bool keyboardRaised: false
|
||||||
|
property bool punctuationMode: false
|
||||||
|
|
||||||
|
// FIXME - Keyboard HMD only: Make Interface either set keyboardRaised property directly in OffscreenQmlSurface
|
||||||
|
// or provide HMDinfo object to QML in RenderableWebEntityItem and do the following.
|
||||||
|
/*
|
||||||
|
onKeyboardRaisedChanged: {
|
||||||
|
keyboardEnabled = HMDinfo.active;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: eventBridgeWrapper
|
||||||
|
WebChannel.id: "eventBridgeWrapper"
|
||||||
|
property var eventBridge;
|
||||||
|
}
|
||||||
|
|
||||||
|
property alias viewProfile: root.profile
|
||||||
|
|
||||||
|
WebEngineView {
|
||||||
|
id: root
|
||||||
|
objectName: "webEngineView"
|
||||||
|
x: 0
|
||||||
|
y: 0
|
||||||
|
width: parent.width
|
||||||
|
height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height
|
||||||
|
|
||||||
|
profile: HFTabletWebEngineProfile {
|
||||||
|
id: webviewProfile
|
||||||
|
storageName: "qmlTabletWebEngine"
|
||||||
|
}
|
||||||
|
|
||||||
|
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: ""
|
||||||
|
|
||||||
|
webChannel.registeredObjects: [eventBridgeWrapper]
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
// 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);
|
||||||
|
});
|
||||||
|
|
||||||
|
root.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) {
|
||||||
|
var url = loadRequest.url.toString();
|
||||||
|
url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
|
||||||
|
if (urlHandler.canHandleUrl(url)) {
|
||||||
|
if (urlHandler.handleUrl(url)) {
|
||||||
|
root.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onNewViewRequested:{
|
||||||
|
// desktop is not defined for web-entities or tablet
|
||||||
|
if (typeof desktop !== "undefined") {
|
||||||
|
desktop.openBrowserWindow(request, profile);
|
||||||
|
} else {
|
||||||
|
tabletRoot.openBrowserWindow(request, profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HiFiControls.Keyboard {
|
||||||
|
id: keyboard
|
||||||
|
raised: parent.keyboardEnabled && parent.keyboardRaised
|
||||||
|
numeric: parent.punctuationMode
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -25,6 +25,9 @@ Item {
|
||||||
property bool isDesktop: false
|
property bool isDesktop: false
|
||||||
property bool removingPage: false
|
property bool removingPage: false
|
||||||
property bool loadingPage: false
|
property bool loadingPage: false
|
||||||
|
property alias webView: webview
|
||||||
|
property alias profile: webview.profile
|
||||||
|
property bool remove: false
|
||||||
|
|
||||||
|
|
||||||
property int currentPage: -1 // used as a model for repeater
|
property int currentPage: -1 // used as a model for repeater
|
||||||
|
@ -110,6 +113,10 @@ Item {
|
||||||
|
|
||||||
|
|
||||||
function closeWebEngine() {
|
function closeWebEngine() {
|
||||||
|
if (remove) {
|
||||||
|
web.destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (parentStackItem) {
|
if (parentStackItem) {
|
||||||
parentStackItem.pop();
|
parentStackItem.pop();
|
||||||
} else {
|
} else {
|
||||||
|
@ -263,8 +270,13 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onNewViewRequested: {
|
onNewViewRequested: {
|
||||||
|
console.log("--------------> new window opened <-------------");
|
||||||
request.openIn(webview);
|
request.openIn(webview);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onWindowCloseRequested: {
|
||||||
|
console.log("-------------> requested to cloes window <---------------");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HiFiControls.Keyboard {
|
HiFiControls.Keyboard {
|
||||||
|
|
|
@ -113,7 +113,7 @@ Item {
|
||||||
if (typeof desktop !== "undefined") {
|
if (typeof desktop !== "undefined") {
|
||||||
desktop.openBrowserWindow(request, profile);
|
desktop.openBrowserWindow(request, profile);
|
||||||
} else {
|
} else {
|
||||||
console.log("onNewViewRequested: desktop not defined");
|
tabletRoot.openBrowserWindow(request, profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import Hifi 1.0
|
import Hifi 1.0
|
||||||
import QtQuick.Controls 1.4
|
import QtQuick.Controls 1.4
|
||||||
|
import HFTabletWebEngineProfile 1.0
|
||||||
import "../../dialogs"
|
import "../../dialogs"
|
||||||
|
import "../../controls"
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: tabletRoot
|
id: tabletRoot
|
||||||
|
@ -11,6 +13,7 @@ Item {
|
||||||
property var rootMenu;
|
property var rootMenu;
|
||||||
property var openModal: null;
|
property var openModal: null;
|
||||||
property var openMessage: null;
|
property var openMessage: null;
|
||||||
|
property var openBrowser: null;
|
||||||
property string subMenu: ""
|
property string subMenu: ""
|
||||||
signal showDesktop();
|
signal showDesktop();
|
||||||
property bool shown: true
|
property bool shown: true
|
||||||
|
@ -21,6 +24,7 @@ Item {
|
||||||
option = value;
|
option = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component { id: profileCreator; HFTabletWebEngineProfile {} }
|
||||||
Component { id: inputDialogBuilder; TabletQueryDialog { } }
|
Component { id: inputDialogBuilder; TabletQueryDialog { } }
|
||||||
function inputDialog(properties) {
|
function inputDialog(properties) {
|
||||||
openModal = inputDialogBuilder.createObject(tabletRoot, properties);
|
openModal = inputDialogBuilder.createObject(tabletRoot, properties);
|
||||||
|
@ -101,8 +105,20 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openBrowserWindow(request, profile) {
|
||||||
|
var component = Qt.createComponent("../../controls/TabletWebView.qml");
|
||||||
|
var newWindow = component.createObject(tabletRoot);
|
||||||
|
newWindow.eventBridge = tabletRoot.eventBridge;
|
||||||
|
newWindow.remove = true;
|
||||||
|
newWindow.profile = profile;
|
||||||
|
request.openIn(newWindow.webView);
|
||||||
|
tabletRoot.openBrowser = newWindow;
|
||||||
|
}
|
||||||
|
|
||||||
function loadWebUrl(url, injectedJavaScriptUrl) {
|
function loadWebUrl(url, injectedJavaScriptUrl) {
|
||||||
tabletApps.clear();
|
tabletApps.clear();
|
||||||
|
var newProfile = profileCreator.createObject();
|
||||||
|
loader.item.viewProfile = newProfile;
|
||||||
loader.item.url = url;
|
loader.item.url = url;
|
||||||
loader.item.scriptURL = injectedJavaScriptUrl;
|
loader.item.scriptURL = injectedJavaScriptUrl;
|
||||||
tabletApps.append({"appUrl": "TabletWebView.qml", "isWebUrl": true, "scriptUrl": injectedJavaScriptUrl, "appWebUrl": url});
|
tabletApps.append({"appUrl": "TabletWebView.qml", "isWebUrl": true, "scriptUrl": injectedJavaScriptUrl, "appWebUrl": url});
|
||||||
|
@ -180,6 +196,11 @@ Item {
|
||||||
openModal.destroy();
|
openModal.destroy();
|
||||||
openModal = null;
|
openModal = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (openBrowser) {
|
||||||
|
openBrowser.destroy();
|
||||||
|
openBrowser = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import QtWebEngine 1.2
|
||||||
|
|
||||||
import "../../controls" as Controls
|
import "../../controls" as Controls
|
||||||
|
|
||||||
Controls.WebView {
|
Controls.TabletWebScreen {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
interface/resources/qml/hifi/tablet/WindowWebView.qml
Normal file
10
interface/resources/qml/hifi/tablet/WindowWebView.qml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import QtQuick 2.0
|
||||||
|
import QtWebEngine 1.2
|
||||||
|
|
||||||
|
import "../../controls" as Controls
|
||||||
|
|
||||||
|
Controls.WebView {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue