mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Merge branch 'master' of github.com:highfidelity/hifi into brown
This commit is contained in:
commit
893bbe3a37
25 changed files with 838 additions and 348 deletions
275
interface/resources/qml/+webengine/Browser.qml
Normal file
275
interface/resources/qml/+webengine/Browser.qml
Normal file
|
@ -0,0 +1,275 @@
|
|||
import QtQuick 2.5
|
||||
import QtWebChannel 1.0
|
||||
import QtWebEngine 1.5
|
||||
|
||||
import controlsUit 1.0
|
||||
import stylesUit 1.0
|
||||
import "qrc:////qml//windows"
|
||||
|
||||
ScrollingWindow {
|
||||
id: root
|
||||
HifiConstants { id: hifi }
|
||||
//HifiStyles.HifiConstants { id: hifistyles }
|
||||
title: "Browser"
|
||||
resizable: true
|
||||
destroyOnHidden: true
|
||||
width: 800
|
||||
height: 600
|
||||
property variant permissionsBar: {'securityOrigin':'none','feature':'none'}
|
||||
property alias url: webview.url
|
||||
property alias webView: webview
|
||||
|
||||
signal loadingChanged(int status)
|
||||
|
||||
x: 100
|
||||
y: 100
|
||||
|
||||
Component.onCompleted: {
|
||||
focus = true
|
||||
shown = true
|
||||
addressBar.text = webview.url
|
||||
}
|
||||
|
||||
function setProfile(profile) {
|
||||
webview.profile = profile;
|
||||
}
|
||||
|
||||
function showPermissionsBar(){
|
||||
permissionsContainer.visible=true;
|
||||
}
|
||||
|
||||
function hidePermissionsBar(){
|
||||
permissionsContainer.visible=false;
|
||||
}
|
||||
|
||||
function allowPermissions(){
|
||||
webview.grantFeaturePermission(permissionsBar.securityOrigin, permissionsBar.feature, true);
|
||||
hidePermissionsBar();
|
||||
}
|
||||
|
||||
function setAutoAdd(auto) {
|
||||
desktop.setAutoAdd(auto);
|
||||
}
|
||||
|
||||
Item {
|
||||
id:item
|
||||
width: pane.contentWidth
|
||||
implicitHeight: pane.scrollHeight
|
||||
|
||||
Row {
|
||||
id: buttons
|
||||
spacing: 4
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 8
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 8
|
||||
HiFiGlyphs {
|
||||
id: back;
|
||||
enabled: webview.canGoBack;
|
||||
text: hifi.glyphs.backward
|
||||
color: enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||
size: 48
|
||||
MouseArea { anchors.fill: parent; onClicked: webview.goBack() }
|
||||
}
|
||||
|
||||
HiFiGlyphs {
|
||||
id: forward;
|
||||
enabled: webview.canGoForward;
|
||||
text: hifi.glyphs.forward
|
||||
color: enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||
size: 48
|
||||
MouseArea { anchors.fill: parent; onClicked: webview.goForward() }
|
||||
}
|
||||
|
||||
HiFiGlyphs {
|
||||
id: reload;
|
||||
enabled: webview.canGoForward;
|
||||
text: webview.loading ? hifi.glyphs.close : hifi.glyphs.reload
|
||||
color: enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||
size: 48
|
||||
MouseArea { anchors.fill: parent; onClicked: webview.goForward() }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Item {
|
||||
id: border
|
||||
height: 48
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 8
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 8
|
||||
anchors.left: buttons.right
|
||||
anchors.leftMargin: 8
|
||||
|
||||
Item {
|
||||
id: barIcon
|
||||
width: parent.height
|
||||
height: parent.height
|
||||
Image {
|
||||
source: webview.icon;
|
||||
x: (parent.height - height) / 2
|
||||
y: (parent.width - width) / 2
|
||||
sourceSize: Qt.size(width, height);
|
||||
verticalAlignment: Image.AlignVCenter;
|
||||
horizontalAlignment: Image.AlignHCenter
|
||||
}
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: addressBar
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 8
|
||||
anchors.left: barIcon.right
|
||||
anchors.leftMargin: 0
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
focus: true
|
||||
colorScheme: hifi.colorSchemes.dark
|
||||
placeholderText: "Enter URL"
|
||||
Component.onCompleted: ScriptDiscoveryService.scriptsModelFilter.filterRegExp = new RegExp("^.*$", "i")
|
||||
Keys.onPressed: {
|
||||
switch(event.key) {
|
||||
case Qt.Key_Enter:
|
||||
case Qt.Key_Return:
|
||||
event.accepted = true
|
||||
if (text.indexOf("http") != 0) {
|
||||
text = "http://" + text;
|
||||
}
|
||||
root.hidePermissionsBar();
|
||||
root.keyboardRaised = false;
|
||||
webview.url = text;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id:permissionsContainer
|
||||
visible:false
|
||||
color: "#000000"
|
||||
width: parent.width
|
||||
anchors.top: buttons.bottom
|
||||
height:40
|
||||
z:100
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0.0; color: "black" }
|
||||
GradientStop { position: 1.0; color: "grey" }
|
||||
}
|
||||
|
||||
RalewayLight {
|
||||
id: permissionsInfo
|
||||
anchors.right:permissionsRow.left
|
||||
anchors.rightMargin: 32
|
||||
anchors.topMargin:8
|
||||
anchors.top:parent.top
|
||||
text: "This site wants to use your microphone/camera"
|
||||
size: 18
|
||||
color: hifi.colors.white
|
||||
}
|
||||
|
||||
Row {
|
||||
id: permissionsRow
|
||||
spacing: 4
|
||||
anchors.top:parent.top
|
||||
anchors.topMargin: 8
|
||||
anchors.right: parent.right
|
||||
visible: true
|
||||
z:101
|
||||
|
||||
Button {
|
||||
id:allow
|
||||
text: "Allow"
|
||||
color: hifi.buttons.blue
|
||||
colorScheme: root.colorScheme
|
||||
width: 120
|
||||
enabled: true
|
||||
onClicked: root.allowPermissions();
|
||||
z:101
|
||||
}
|
||||
|
||||
Button {
|
||||
id:block
|
||||
text: "Block"
|
||||
color: hifi.buttons.red
|
||||
colorScheme: root.colorScheme
|
||||
width: 120
|
||||
enabled: true
|
||||
onClicked: root.hidePermissionsBar();
|
||||
z:101
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebView {
|
||||
id: webview
|
||||
url: "https://highfidelity.com/"
|
||||
profile: FileTypeProfile;
|
||||
|
||||
// Create a global EventBridge object for raiseAndLowerKeyboard.
|
||||
WebEngineScript {
|
||||
id: createGlobalEventBridge
|
||||
sourceCode: eventBridgeJavaScriptToInject
|
||||
injectionPoint: WebEngineScript.Deferred
|
||||
worldId: WebEngineScript.MainWorld
|
||||
}
|
||||
|
||||
// Detect when may want to raise and lower keyboard.
|
||||
WebEngineScript {
|
||||
id: raiseAndLowerKeyboard
|
||||
injectionPoint: WebEngineScript.Deferred
|
||||
sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js"
|
||||
worldId: WebEngineScript.MainWorld
|
||||
}
|
||||
|
||||
userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard ]
|
||||
|
||||
anchors.top: buttons.bottom
|
||||
anchors.topMargin: 8
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
onFeaturePermissionRequested: {
|
||||
if (feature == 2) { // QWebEnginePage::MediaAudioCapture
|
||||
grantFeaturePermission(securityOrigin, feature, true);
|
||||
} else {
|
||||
permissionsBar.securityOrigin = securityOrigin;
|
||||
permissionsBar.feature = feature;
|
||||
root.showPermissionsBar();
|
||||
}
|
||||
}
|
||||
|
||||
onLoadingChanged: {
|
||||
if (loadRequest.status === WebEngineView.LoadSucceededStatus) {
|
||||
addressBar.text = loadRequest.url
|
||||
}
|
||||
root.loadingChanged(loadRequest.status);
|
||||
}
|
||||
|
||||
onWindowCloseRequested: {
|
||||
root.destroy();
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
webChannel.registerObject("eventBridge", eventBridge);
|
||||
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
|
||||
desktop.initWebviewProfileHandlers(webview.profile);
|
||||
}
|
||||
}
|
||||
|
||||
} // item
|
||||
|
||||
|
||||
Keys.onPressed: {
|
||||
switch(event.key) {
|
||||
case Qt.Key_L:
|
||||
if (event.modifiers == Qt.ControlModifier) {
|
||||
event.accepted = true
|
||||
addressBar.selectAll()
|
||||
addressBar.forceActiveFocus()
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // dialog
|
50
interface/resources/qml/+webengine/InfoView.qml
Normal file
50
interface/resources/qml/+webengine/InfoView.qml
Normal file
|
@ -0,0 +1,50 @@
|
|||
//
|
||||
// InfoView.qml
|
||||
//
|
||||
// Created by Bradley Austin Davis on 27 Apr 2015
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
import Hifi 1.0 as Hifi
|
||||
|
||||
import controlsUit 1.0
|
||||
import "qrc:////qml//windows" as Windows
|
||||
|
||||
Windows.ScrollingWindow {
|
||||
id: root
|
||||
width: 800
|
||||
height: 800
|
||||
resizable: true
|
||||
|
||||
Hifi.InfoView {
|
||||
id: infoView
|
||||
width: pane.contentWidth
|
||||
implicitHeight: pane.scrollHeight
|
||||
|
||||
WebView {
|
||||
id: webview
|
||||
objectName: "WebView"
|
||||
anchors.fill: parent
|
||||
url: infoView.url
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
centerWindow(root);
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
centerWindow(root);
|
||||
}
|
||||
}
|
||||
|
||||
function centerWindow() {
|
||||
desktop.centerOnVisible(root);
|
||||
}
|
||||
|
||||
}
|
125
interface/resources/qml/+webengine/TabletBrowser.qml
Normal file
125
interface/resources/qml/+webengine/TabletBrowser.qml
Normal file
|
@ -0,0 +1,125 @@
|
|||
import QtQuick 2.5
|
||||
import QtWebChannel 1.0
|
||||
import QtWebEngine 1.5
|
||||
|
||||
import "controls"
|
||||
import controlsUit 1.0 as HifiControls
|
||||
import "styles" as HifiStyles
|
||||
import stylesUit 1.0
|
||||
import "windows"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
HifiConstants { id: hifi }
|
||||
HifiStyles.HifiConstants { id: hifistyles }
|
||||
|
||||
height: 600
|
||||
property variant permissionsBar: {'securityOrigin':'none','feature':'none'}
|
||||
property alias url: webview.url
|
||||
|
||||
property bool canGoBack: webview.canGoBack
|
||||
property bool canGoForward: webview.canGoForward
|
||||
|
||||
|
||||
signal loadingChanged(int status)
|
||||
|
||||
x: 0
|
||||
y: 0
|
||||
|
||||
function setProfile(profile) {
|
||||
webview.profile = profile;
|
||||
}
|
||||
|
||||
WebEngineView {
|
||||
id: webview
|
||||
objectName: "webEngineView"
|
||||
x: 0
|
||||
y: 0
|
||||
width: parent.width
|
||||
height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
webview.profile.httpUserAgent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36";
|
||||
web.address = url;
|
||||
}
|
||||
|
||||
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) {
|
||||
urlAppend(loadRequest.url.toString())
|
||||
var url = loadRequest.url.toString();
|
||||
if (urlHandler.canHandleUrl(url)) {
|
||||
if (urlHandler.handleUrl(url)) {
|
||||
root.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onNewViewRequested: {
|
||||
request.openIn(webView);
|
||||
}
|
||||
|
||||
HifiControls.WebSpinner { }
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
switch(event.key) {
|
||||
case Qt.Key_L:
|
||||
if (event.modifiers == Qt.ControlModifier) {
|
||||
event.accepted = true
|
||||
addressBar.selectAll()
|
||||
addressBar.forceActiveFocus()
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,14 @@
|
|||
import QtQuick 2.5
|
||||
import QtWebChannel 1.0
|
||||
import QtWebEngine 1.5
|
||||
|
||||
import controlsUit 1.0
|
||||
import "styles" as HifiStyles
|
||||
import stylesUit 1.0
|
||||
|
||||
import "windows"
|
||||
|
||||
ScrollingWindow {
|
||||
id: root
|
||||
HifiConstants { id: hifi }
|
||||
HifiStyles.HifiConstants { id: hifistyles }
|
||||
//HifiStyles.HifiConstants { id: hifistyles }
|
||||
title: "Browser"
|
||||
resizable: true
|
||||
destroyOnHidden: true
|
||||
|
@ -32,7 +30,6 @@ ScrollingWindow {
|
|||
}
|
||||
|
||||
function setProfile(profile) {
|
||||
webview.profile = profile;
|
||||
}
|
||||
|
||||
function showPermissionsBar(){
|
||||
|
@ -44,7 +41,6 @@ ScrollingWindow {
|
|||
}
|
||||
|
||||
function allowPermissions(){
|
||||
webview.grantFeaturePermission(permissionsBar.securityOrigin, permissionsBar.feature, true);
|
||||
hidePermissionsBar();
|
||||
}
|
||||
|
||||
|
@ -68,7 +64,7 @@ ScrollingWindow {
|
|||
id: back;
|
||||
enabled: webview.canGoBack;
|
||||
text: hifi.glyphs.backward
|
||||
color: enabled ? hifistyles.colors.text : hifistyles.colors.disabledText
|
||||
color: enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||
size: 48
|
||||
MouseArea { anchors.fill: parent; onClicked: webview.goBack() }
|
||||
}
|
||||
|
@ -77,7 +73,7 @@ ScrollingWindow {
|
|||
id: forward;
|
||||
enabled: webview.canGoForward;
|
||||
text: hifi.glyphs.forward
|
||||
color: enabled ? hifistyles.colors.text : hifistyles.colors.disabledText
|
||||
color: enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||
size: 48
|
||||
MouseArea { anchors.fill: parent; onClicked: webview.goForward() }
|
||||
}
|
||||
|
@ -86,7 +82,7 @@ ScrollingWindow {
|
|||
id: reload;
|
||||
enabled: webview.canGoForward;
|
||||
text: webview.loading ? hifi.glyphs.close : hifi.glyphs.reload
|
||||
color: enabled ? hifistyles.colors.text : hifistyles.colors.disabledText
|
||||
color: enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||
size: 48
|
||||
MouseArea { anchors.fill: parent; onClicked: webview.goForward() }
|
||||
}
|
||||
|
@ -202,61 +198,10 @@ ScrollingWindow {
|
|||
}
|
||||
}
|
||||
|
||||
WebView {
|
||||
ProxyWebView {
|
||||
id: webview
|
||||
anchors.centerIn: parent
|
||||
url: "https://highfidelity.com/"
|
||||
profile: FileTypeProfile;
|
||||
|
||||
// Create a global EventBridge object for raiseAndLowerKeyboard.
|
||||
WebEngineScript {
|
||||
id: createGlobalEventBridge
|
||||
sourceCode: eventBridgeJavaScriptToInject
|
||||
injectionPoint: WebEngineScript.Deferred
|
||||
worldId: WebEngineScript.MainWorld
|
||||
}
|
||||
|
||||
// Detect when may want to raise and lower keyboard.
|
||||
WebEngineScript {
|
||||
id: raiseAndLowerKeyboard
|
||||
injectionPoint: WebEngineScript.Deferred
|
||||
sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js"
|
||||
worldId: WebEngineScript.MainWorld
|
||||
}
|
||||
|
||||
userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard ]
|
||||
|
||||
anchors.top: buttons.bottom
|
||||
anchors.topMargin: 8
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
onFeaturePermissionRequested: {
|
||||
if (feature == 2) { // QWebEnginePage::MediaAudioCapture
|
||||
grantFeaturePermission(securityOrigin, feature, true);
|
||||
} else {
|
||||
permissionsBar.securityOrigin = securityOrigin;
|
||||
permissionsBar.feature = feature;
|
||||
root.showPermissionsBar();
|
||||
}
|
||||
}
|
||||
|
||||
onLoadingChanged: {
|
||||
if (loadRequest.status === WebEngineView.LoadSucceededStatus) {
|
||||
addressBar.text = loadRequest.url
|
||||
}
|
||||
root.loadingChanged(loadRequest.status);
|
||||
}
|
||||
|
||||
onWindowCloseRequested: {
|
||||
root.destroy();
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
webChannel.registerObject("eventBridge", eventBridge);
|
||||
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
|
||||
desktop.initWebviewProfileHandlers(webview.profile);
|
||||
}
|
||||
}
|
||||
|
||||
} // item
|
||||
|
|
|
@ -19,13 +19,12 @@ Windows.ScrollingWindow {
|
|||
width: 800
|
||||
height: 800
|
||||
resizable: true
|
||||
|
||||
Hifi.InfoView {
|
||||
id: infoView
|
||||
width: pane.contentWidth
|
||||
implicitHeight: pane.scrollHeight
|
||||
|
||||
WebView {
|
||||
ProxyWebView {
|
||||
id: webview
|
||||
objectName: "WebView"
|
||||
anchors.fill: parent
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
import QtQuick 2.5
|
||||
import QtWebChannel 1.0
|
||||
import QtWebEngine 1.5
|
||||
|
||||
import "controls"
|
||||
import controlsUit 1.0 as HifiControls
|
||||
import "styles" as HifiStyles
|
||||
import stylesUit 1.0
|
||||
import "windows"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
HifiConstants { id: hifi }
|
||||
HifiStyles.HifiConstants { id: hifistyles }
|
||||
|
||||
height: 600
|
||||
property variant permissionsBar: {'securityOrigin':'none','feature':'none'}
|
||||
|
@ -30,96 +24,9 @@ Item {
|
|||
webview.profile = profile;
|
||||
}
|
||||
|
||||
WebEngineView {
|
||||
HifiControls.ProxyWebView {
|
||||
id: webview
|
||||
objectName: "webEngineView"
|
||||
x: 0
|
||||
y: 0
|
||||
width: parent.width
|
||||
height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
webview.profile.httpUserAgent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36";
|
||||
web.address = url;
|
||||
}
|
||||
|
||||
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) {
|
||||
urlAppend(loadRequest.url.toString())
|
||||
var url = loadRequest.url.toString();
|
||||
if (urlHandler.canHandleUrl(url)) {
|
||||
if (urlHandler.handleUrl(url)) {
|
||||
root.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onNewViewRequested: {
|
||||
request.openIn(webView);
|
||||
}
|
||||
|
||||
HifiControls.WebSpinner { }
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
switch(event.key) {
|
||||
case Qt.Key_L:
|
||||
if (event.modifiers == Qt.ControlModifier) {
|
||||
event.accepted = true
|
||||
addressBar.selectAll()
|
||||
addressBar.forceActiveFocus()
|
||||
}
|
||||
break;
|
||||
}
|
||||
height: parent.height
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
import QtQuick 2.7
|
||||
import QtWebEngine 1.5
|
||||
import QtWebChannel 1.0
|
||||
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
import stylesUit 1.0 as StylesUIt
|
||||
|
||||
Item {
|
||||
id: flick
|
||||
|
||||
property alias url: webViewCore.url
|
||||
property alias canGoBack: webViewCore.canGoBack
|
||||
property alias webViewCore: webViewCore
|
||||
property alias webViewCoreProfile: webViewCore.profile
|
||||
property string webViewCoreUserAgent
|
||||
|
||||
property string userScriptUrl: ""
|
||||
property string urlTag: "noDownload=false";
|
||||
|
||||
signal newViewRequestedCallback(var request)
|
||||
signal loadingChangedCallback(var loadRequest)
|
||||
|
||||
|
||||
width: parent.width
|
||||
|
||||
property bool interactive: false
|
||||
|
||||
property bool blurOnCtrlShift: true
|
||||
|
||||
StylesUIt.HifiConstants {
|
||||
id: hifi
|
||||
}
|
||||
|
||||
function stop() {
|
||||
webViewCore.stop();
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: delayedUnfocuser
|
||||
repeat: false
|
||||
interval: 200
|
||||
onTriggered: {
|
||||
|
||||
// The idea behind this is to delay unfocusing, so that fast lower/raise will not result actual unfocusing.
|
||||
// Fast lower/raise happens every time keyboard is being re-raised (see the code below in OffscreenQmlSurface::setKeyboardRaised)
|
||||
//
|
||||
// if (raised) {
|
||||
// item->setProperty("keyboardRaised", QVariant(!raised));
|
||||
// }
|
||||
//
|
||||
// item->setProperty("keyboardRaised", QVariant(raised));
|
||||
//
|
||||
|
||||
webViewCore.runJavaScript("if (document.activeElement) document.activeElement.blur();", function(result) {
|
||||
console.log('unfocus completed: ', result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function unfocus() {
|
||||
delayedUnfocuser.start();
|
||||
}
|
||||
|
||||
function stopUnfocus() {
|
||||
delayedUnfocuser.stop();
|
||||
}
|
||||
|
||||
function onLoadingChanged(loadRequest) {
|
||||
if (WebEngineView.LoadStartedStatus === loadRequest.status) {
|
||||
|
||||
// Required to support clicking on "hifi://" links
|
||||
var url = loadRequest.url.toString();
|
||||
url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
|
||||
if (urlHandler.canHandleUrl(url)) {
|
||||
if (urlHandler.handleUrl(url)) {
|
||||
webViewCore.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (WebEngineView.LoadFailedStatus === loadRequest.status) {
|
||||
console.log("Tablet WebEngineView failed to load url: " + loadRequest.url.toString());
|
||||
}
|
||||
|
||||
if (WebEngineView.LoadSucceededStatus === loadRequest.status) {
|
||||
//disable Chromium's scroll bars
|
||||
}
|
||||
}
|
||||
|
||||
WebEngineView {
|
||||
id: webViewCore
|
||||
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
|
||||
profile: HFWebEngineProfile;
|
||||
settings.pluginsEnabled: true
|
||||
settings.touchIconsEnabled: true
|
||||
settings.allowRunningInsecureContent: true
|
||||
|
||||
// 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: flick.userScriptUrl
|
||||
injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished.
|
||||
worldId: WebEngineScript.MainWorld
|
||||
}
|
||||
|
||||
userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ]
|
||||
|
||||
Component.onCompleted: {
|
||||
webChannel.registerObject("eventBridge", eventBridge);
|
||||
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
|
||||
|
||||
if (webViewCoreUserAgent !== undefined) {
|
||||
webViewCore.profile.httpUserAgent = webViewCoreUserAgent
|
||||
} else {
|
||||
webViewCore.profile.httpUserAgent += " (HighFidelityInterface)";
|
||||
}
|
||||
// Ensure the JS from the web-engine makes it to our logging
|
||||
webViewCore.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
||||
console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
|
||||
});
|
||||
}
|
||||
|
||||
onFeaturePermissionRequested: {
|
||||
grantFeaturePermission(securityOrigin, feature, true);
|
||||
}
|
||||
|
||||
//disable popup
|
||||
onContextMenuRequested: {
|
||||
request.accepted = true;
|
||||
}
|
||||
|
||||
onNewViewRequested: {
|
||||
newViewRequestedCallback(request)
|
||||
}
|
||||
|
||||
// Prior to 5.10, the WebEngineView loading property is true during initial page loading and then stays false
|
||||
// as in-page javascript adds more html content. However, in 5.10 there is a bug such that adding html turns
|
||||
// loading true, and never turns it false again. safeLoading provides a workaround, but it should be removed
|
||||
// when QT fixes this.
|
||||
property bool safeLoading: false
|
||||
property bool loadingLatched: false
|
||||
property var loadingRequest: null
|
||||
onLoadingChanged: {
|
||||
webViewCore.loadingRequest = loadRequest;
|
||||
webViewCore.safeLoading = webViewCore.loading && !loadingLatched;
|
||||
webViewCore.loadingLatched |= webViewCore.loading;
|
||||
}
|
||||
onSafeLoadingChanged: {
|
||||
flick.onLoadingChanged(webViewCore.loadingRequest)
|
||||
loadingChangedCallback(webViewCore.loadingRequest)
|
||||
}
|
||||
}
|
||||
|
||||
AnimatedImage {
|
||||
//anchoring doesnt works here when changing content size
|
||||
x: flick.width/2 - width/2
|
||||
y: flick.height/2 - height/2
|
||||
source: "../../icons/loader-snake-64-w.gif"
|
||||
visible: webViewCore.safeLoading && /^(http.*|)$/i.test(webViewCore.url.toString())
|
||||
playing: visible
|
||||
z: 10000
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (blurOnCtrlShift && (event.modifiers & Qt.ShiftModifier) && (event.modifiers & Qt.ControlModifier)) {
|
||||
webViewCore.focus = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
import QtQuick 2.7
|
||||
import QtWebEngine 1.5
|
||||
import QtWebChannel 1.0
|
||||
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
import stylesUit 1.0 as StylesUIt
|
||||
import controlsUit 1.0 as ControlsUit
|
||||
|
||||
Item {
|
||||
id: flick
|
||||
|
@ -33,157 +32,21 @@ Item {
|
|||
}
|
||||
|
||||
function stop() {
|
||||
webViewCore.stop();
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: delayedUnfocuser
|
||||
repeat: false
|
||||
interval: 200
|
||||
onTriggered: {
|
||||
|
||||
// The idea behind this is to delay unfocusing, so that fast lower/raise will not result actual unfocusing.
|
||||
// Fast lower/raise happens every time keyboard is being re-raised (see the code below in OffscreenQmlSurface::setKeyboardRaised)
|
||||
//
|
||||
// if (raised) {
|
||||
// item->setProperty("keyboardRaised", QVariant(!raised));
|
||||
// }
|
||||
//
|
||||
// item->setProperty("keyboardRaised", QVariant(raised));
|
||||
//
|
||||
|
||||
webViewCore.runJavaScript("if (document.activeElement) document.activeElement.blur();", function(result) {
|
||||
console.log('unfocus completed: ', result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function unfocus() {
|
||||
delayedUnfocuser.start();
|
||||
}
|
||||
|
||||
function stopUnfocus() {
|
||||
delayedUnfocuser.stop();
|
||||
}
|
||||
|
||||
function onLoadingChanged(loadRequest) {
|
||||
if (WebEngineView.LoadStartedStatus === loadRequest.status) {
|
||||
|
||||
// Required to support clicking on "hifi://" links
|
||||
var url = loadRequest.url.toString();
|
||||
url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
|
||||
if (urlHandler.canHandleUrl(url)) {
|
||||
if (urlHandler.handleUrl(url)) {
|
||||
webViewCore.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (WebEngineView.LoadFailedStatus === loadRequest.status) {
|
||||
console.log("Tablet WebEngineView failed to load url: " + loadRequest.url.toString());
|
||||
}
|
||||
|
||||
if (WebEngineView.LoadSucceededStatus === loadRequest.status) {
|
||||
//disable Chromium's scroll bars
|
||||
}
|
||||
}
|
||||
|
||||
WebEngineView {
|
||||
ControlsUit.ProxyWebView {
|
||||
id: webViewCore
|
||||
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
|
||||
profile: HFWebEngineProfile;
|
||||
settings.pluginsEnabled: true
|
||||
settings.touchIconsEnabled: true
|
||||
settings.allowRunningInsecureContent: true
|
||||
|
||||
// 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: flick.userScriptUrl
|
||||
injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished.
|
||||
worldId: WebEngineScript.MainWorld
|
||||
}
|
||||
|
||||
userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ]
|
||||
|
||||
Component.onCompleted: {
|
||||
webChannel.registerObject("eventBridge", eventBridge);
|
||||
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
|
||||
|
||||
if (webViewCoreUserAgent !== undefined) {
|
||||
webViewCore.profile.httpUserAgent = webViewCoreUserAgent
|
||||
} else {
|
||||
webViewCore.profile.httpUserAgent += " (HighFidelityInterface)";
|
||||
}
|
||||
// Ensure the JS from the web-engine makes it to our logging
|
||||
webViewCore.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
||||
console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
|
||||
});
|
||||
}
|
||||
|
||||
onFeaturePermissionRequested: {
|
||||
grantFeaturePermission(securityOrigin, feature, true);
|
||||
}
|
||||
|
||||
//disable popup
|
||||
onContextMenuRequested: {
|
||||
request.accepted = true;
|
||||
}
|
||||
|
||||
onNewViewRequested: {
|
||||
newViewRequestedCallback(request)
|
||||
}
|
||||
|
||||
// Prior to 5.10, the WebEngineView loading property is true during initial page loading and then stays false
|
||||
// as in-page javascript adds more html content. However, in 5.10 there is a bug such that adding html turns
|
||||
// loading true, and never turns it false again. safeLoading provides a workaround, but it should be removed
|
||||
// when QT fixes this.
|
||||
property bool safeLoading: false
|
||||
property bool loadingLatched: false
|
||||
property var loadingRequest: null
|
||||
onLoadingChanged: {
|
||||
webViewCore.loadingRequest = loadRequest;
|
||||
webViewCore.safeLoading = webViewCore.loading && !loadingLatched;
|
||||
webViewCore.loadingLatched |= webViewCore.loading;
|
||||
}
|
||||
onSafeLoadingChanged: {
|
||||
flick.onLoadingChanged(webViewCore.loadingRequest)
|
||||
loadingChangedCallback(webViewCore.loadingRequest)
|
||||
}
|
||||
}
|
||||
|
||||
AnimatedImage {
|
||||
//anchoring doesnt works here when changing content size
|
||||
x: flick.width/2 - width/2
|
||||
y: flick.height/2 - height/2
|
||||
source: "../../icons/loader-snake-64-w.gif"
|
||||
visible: webViewCore.safeLoading && /^(http.*|)$/i.test(webViewCore.url.toString())
|
||||
playing: visible
|
||||
z: 10000
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (blurOnCtrlShift && (event.modifiers & Qt.ShiftModifier) && (event.modifiers & Qt.ControlModifier)) {
|
||||
webViewCore.focus = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import QtQuick 2.7
|
||||
import QtWebEngine 1.5
|
||||
import controlsUit 1.0 as HiFiControls
|
||||
import "../styles" as HifiStyles
|
||||
import stylesUit 1.0
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// WebView.qml
|
||||
//
|
||||
// Created by Bradley Austin Davis on 12 Jan 2016
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtWebEngine 1.5
|
||||
|
||||
WebEngineView {
|
||||
id: root
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("Connecting JS messaging to Hifi Logging")
|
||||
// Ensure the JS from the web-engine makes it to our logging
|
||||
root.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
||||
console.log("Web Window JS message: " + sourceID + " " + lineNumber + " " + message);
|
||||
});
|
||||
}
|
||||
|
||||
onLoadingChanged: {
|
||||
// Required to support clicking on "hifi://" links
|
||||
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
||||
var url = loadRequest.url.toString();
|
||||
if (urlHandler.canHandleUrl(url)) {
|
||||
if (urlHandler.handleUrl(url)) {
|
||||
root.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebSpinner { }
|
||||
}
|
|
@ -8,31 +8,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtWebEngine 1.5
|
||||
import "."
|
||||
|
||||
WebEngineView {
|
||||
ProxyWebView {
|
||||
id: root
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("Connecting JS messaging to Hifi Logging")
|
||||
// Ensure the JS from the web-engine makes it to our logging
|
||||
root.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
||||
console.log("Web Window JS message: " + sourceID + " " + lineNumber + " " + message);
|
||||
});
|
||||
}
|
||||
|
||||
onLoadingChanged: {
|
||||
// Required to support clicking on "hifi://" links
|
||||
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
||||
var url = loadRequest.url.toString();
|
||||
if (urlHandler.canHandleUrl(url)) {
|
||||
if (urlHandler.handleUrl(url)) {
|
||||
root.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebSpinner { }
|
||||
}
|
||||
|
|
30
interface/resources/qml/controlsUit/ProxyWebView.qml
Normal file
30
interface/resources/qml/controlsUit/ProxyWebView.qml
Normal file
|
@ -0,0 +1,30 @@
|
|||
import QtQuick 2.7
|
||||
import stylesUit 1.0
|
||||
|
||||
Rectangle {
|
||||
HifiConstants {
|
||||
id: hifi
|
||||
}
|
||||
|
||||
color: hifi.colors.darkGray
|
||||
|
||||
signal onNewViewRequested();
|
||||
|
||||
property string url: "";
|
||||
property bool canGoBack: false
|
||||
property bool canGoForward: false
|
||||
property string icon: ""
|
||||
property var profile: {}
|
||||
|
||||
property bool safeLoading: false
|
||||
property bool loadingLatched: false
|
||||
property var loadingRequest: null
|
||||
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "This feature is not supported"
|
||||
font.pixelSize: 32
|
||||
color: hifi.colors.white
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ TextEdit 1.0 TextEdit.qml
|
|||
TextField 1.0 TextField.qml
|
||||
ToolTip 1.0 ToolTip.qml
|
||||
Tree 1.0 Tree.qml
|
||||
ProxyWebView 1.0 ProxyWebView.qml
|
||||
VerticalSpacer 1.0 VerticalSpacer.qml
|
||||
WebGlyphButton 1.0 WebGlyphButton.qml
|
||||
WebSpinner 1.0 WebSpinner.qml
|
||||
|
|
|
@ -5300,6 +5300,21 @@ void MyAvatar::releaseGrab(const QUuid& grabID) {
|
|||
bool tellHandler { false };
|
||||
|
||||
_avatarGrabsLock.withWriteLock([&] {
|
||||
|
||||
std::map<QUuid, GrabPointer>::iterator itr;
|
||||
itr = _avatarGrabs.find(grabID);
|
||||
if (itr != _avatarGrabs.end()) {
|
||||
GrabPointer grab = itr->second;
|
||||
if (grab) {
|
||||
grab->setReleased(true);
|
||||
bool success;
|
||||
SpatiallyNestablePointer target = SpatiallyNestable::findByID(grab->getTargetID(), success);
|
||||
if (target && success) {
|
||||
target->disableGrab(grab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_avatarGrabData.remove(grabID)) {
|
||||
_grabsToDelete.push_back(grabID);
|
||||
tellHandler = true;
|
||||
|
|
|
@ -412,6 +412,9 @@ void Avatar::accumulateGrabPositions(std::map<QUuid, GrabLocationAccumulator>& g
|
|||
if (!grab || !grab->getActionID().isNull()) {
|
||||
continue; // the accumulated value isn't used, in this case.
|
||||
}
|
||||
if (grab->getReleased()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
glm::vec3 jointTranslation = getAbsoluteJointTranslationInObjectFrame(grab->getParentJointIndex());
|
||||
glm::quat jointRotation = getAbsoluteJointRotationInObjectFrame(grab->getParentJointIndex());
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
virtual bool isReadyForAdd() const { return true; }
|
||||
|
||||
bool isActive() { return _active; }
|
||||
void deactivate() { _active = false; }
|
||||
|
||||
virtual void removeFromSimulation(EntitySimulationPointer simulation) const = 0;
|
||||
virtual EntityItemWeakPointer getOwnerEntity() const = 0;
|
||||
|
|
|
@ -3506,3 +3506,13 @@ void EntityItem::removeGrab(GrabPointer grab) {
|
|||
}
|
||||
disableNoBootstrap();
|
||||
}
|
||||
|
||||
void EntityItem::disableGrab(GrabPointer grab) {
|
||||
QUuid actionID = grab->getActionID();
|
||||
if (!actionID.isNull()) {
|
||||
EntityDynamicPointer action = _grabActions.value(actionID);
|
||||
if (action) {
|
||||
action->deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -561,6 +561,7 @@ public:
|
|||
|
||||
virtual void addGrab(GrabPointer grab) override;
|
||||
virtual void removeGrab(GrabPointer grab) override;
|
||||
virtual void disableGrab(GrabPointer grab) override;
|
||||
|
||||
signals:
|
||||
void requestRenderUpdate();
|
||||
|
|
|
@ -24,6 +24,17 @@ const uint32_t MAX_RANGE_QUERY_DEPTH = 10000;
|
|||
static bool timeElapsed = false;
|
||||
#endif
|
||||
|
||||
#if defined(USE_GLES)
|
||||
static bool hasTimerExtension() {
|
||||
static std::once_flag once;
|
||||
static bool result = false;
|
||||
std::call_once(once, [&] {
|
||||
result = glGetQueryObjectui64vEXT != nullptr;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
void GLBackend::do_beginQuery(const Batch& batch, size_t paramOffset) {
|
||||
auto query = batch._queries.get(batch._params[paramOffset]._uint);
|
||||
GLQuery* glquery = syncGPUObject(*query);
|
||||
|
@ -33,7 +44,11 @@ void GLBackend::do_beginQuery(const Batch& batch, size_t paramOffset) {
|
|||
++_queryStage._rangeQueryDepth;
|
||||
glquery->_batchElapsedTimeBegin = std::chrono::high_resolution_clock::now();
|
||||
|
||||
#if !defined(USE_GLES)
|
||||
#if defined(USE_GLES)
|
||||
if (hasTimerExtension()) {
|
||||
glQueryCounterEXT(glquery->_beginqo, GL_TIMESTAMP_EXT);
|
||||
}
|
||||
#else
|
||||
if (timeElapsed) {
|
||||
if (_queryStage._rangeQueryDepth <= MAX_RANGE_QUERY_DEPTH) {
|
||||
glBeginQuery(GL_TIME_ELAPSED, glquery->_endqo);
|
||||
|
@ -52,7 +67,11 @@ void GLBackend::do_endQuery(const Batch& batch, size_t paramOffset) {
|
|||
auto query = batch._queries.get(batch._params[paramOffset]._uint);
|
||||
GLQuery* glquery = syncGPUObject(*query);
|
||||
if (glquery) {
|
||||
#if !defined(USE_GLES)
|
||||
#if defined(USE_GLES)
|
||||
if (hasTimerExtension()) {
|
||||
glQueryCounterEXT(glquery->_endqo, GL_TIMESTAMP_EXT);
|
||||
}
|
||||
#else
|
||||
if (timeElapsed) {
|
||||
if (_queryStage._rangeQueryDepth <= MAX_RANGE_QUERY_DEPTH) {
|
||||
glEndQuery(GL_TIME_ELAPSED);
|
||||
|
@ -79,7 +98,21 @@ void GLBackend::do_getQuery(const Batch& batch, size_t paramOffset) {
|
|||
if (glquery->_rangeQueryDepth > MAX_RANGE_QUERY_DEPTH) {
|
||||
query->triggerReturnHandler(glquery->_result, glquery->_batchElapsedTime);
|
||||
} else {
|
||||
#if !defined(USE_GLES)
|
||||
#if defined(USE_GLES)
|
||||
glquery->_result = 0;
|
||||
if (hasTimerExtension()) {
|
||||
glGetQueryObjectui64vEXT(glquery->_endqo, GL_QUERY_RESULT_AVAILABLE, &glquery->_result);
|
||||
if (glquery->_result == GL_TRUE) {
|
||||
GLuint64 start, end;
|
||||
glGetQueryObjectui64vEXT(glquery->_beginqo, GL_QUERY_RESULT, &start);
|
||||
glGetQueryObjectui64vEXT(glquery->_endqo, GL_QUERY_RESULT, &end);
|
||||
glquery->_result = end - start;
|
||||
query->triggerReturnHandler(glquery->_result, glquery->_batchElapsedTime);
|
||||
}
|
||||
} else {
|
||||
query->triggerReturnHandler(0, glquery->_batchElapsedTime);
|
||||
}
|
||||
#else
|
||||
glGetQueryObjectui64v(glquery->_endqo, GL_QUERY_RESULT_AVAILABLE, &glquery->_result);
|
||||
if (glquery->_result == GL_TRUE) {
|
||||
if (timeElapsed) {
|
||||
|
@ -92,9 +125,6 @@ void GLBackend::do_getQuery(const Batch& batch, size_t paramOffset) {
|
|||
}
|
||||
query->triggerReturnHandler(glquery->_result, glquery->_batchElapsedTime);
|
||||
}
|
||||
#else
|
||||
// gles3 is not supporting true time query returns just the batch elapsed time
|
||||
query->triggerReturnHandler(0, glquery->_batchElapsedTime);
|
||||
#endif
|
||||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
|
|
|
@ -115,17 +115,30 @@ void EntityMotionState::updateServerPhysicsVariables() {
|
|||
}
|
||||
|
||||
void EntityMotionState::handleDeactivation() {
|
||||
// copy _server data to entity
|
||||
Transform localTransform = _entity->getLocalTransform();
|
||||
localTransform.setTranslation(_serverPosition);
|
||||
localTransform.setRotation(_serverRotation);
|
||||
_entity->setLocalTransformAndVelocities(localTransform, ENTITY_ITEM_ZERO_VEC3, ENTITY_ITEM_ZERO_VEC3);
|
||||
// and also to RigidBody
|
||||
btTransform worldTrans;
|
||||
worldTrans.setOrigin(glmToBullet(_entity->getWorldPosition()));
|
||||
worldTrans.setRotation(glmToBullet(_entity->getWorldOrientation()));
|
||||
_body->setWorldTransform(worldTrans);
|
||||
// no need to update velocities... should already be zero
|
||||
if (_entity->getDirtyFlags() & (Simulation::DIRTY_TRANSFORM | Simulation::DIRTY_VELOCITIES)) {
|
||||
// Some non-physical event (script-call or network-packet) has modified the entity's transform and/or velocities
|
||||
// at the last minute before deactivation --> the values stored in _server* and _body are stale.
|
||||
// We assume the EntityMotionState is the last to know, so we copy from EntityItem and let things sort themselves out.
|
||||
Transform localTransform;
|
||||
_entity->getLocalTransformAndVelocities(localTransform, _serverVelocity, _serverAngularVelocity);
|
||||
_serverPosition = localTransform.getTranslation();
|
||||
_serverRotation = localTransform.getRotation();
|
||||
_serverAcceleration = _entity->getAcceleration();
|
||||
_serverActionData = _entity->getDynamicData();
|
||||
_lastStep = ObjectMotionState::getWorldSimulationStep();
|
||||
} else {
|
||||
// copy _server data to entity
|
||||
Transform localTransform = _entity->getLocalTransform();
|
||||
localTransform.setTranslation(_serverPosition);
|
||||
localTransform.setRotation(_serverRotation);
|
||||
_entity->setLocalTransformAndVelocities(localTransform, ENTITY_ITEM_ZERO_VEC3, ENTITY_ITEM_ZERO_VEC3);
|
||||
// and also to RigidBody
|
||||
btTransform worldTrans;
|
||||
worldTrans.setOrigin(glmToBullet(_entity->getWorldPosition()));
|
||||
worldTrans.setRotation(glmToBullet(_entity->getWorldOrientation()));
|
||||
_body->setWorldTransform(worldTrans);
|
||||
// no need to update velocities... should already be zero
|
||||
}
|
||||
}
|
||||
|
||||
// virtual
|
||||
|
|
|
@ -26,16 +26,16 @@ public:
|
|||
void accumulate(glm::vec3 position, glm::quat orientation) {
|
||||
_position += position;
|
||||
_orientation = orientation; // XXX
|
||||
count++;
|
||||
_count++;
|
||||
}
|
||||
|
||||
glm::vec3 finalizePosition() { return count > 0 ? _position * (1.0f / count) : glm::vec3(0.0f); }
|
||||
glm::vec3 finalizePosition() { return _count > 0 ? _position * (1.0f / _count) : glm::vec3(0.0f); }
|
||||
glm::quat finalizeOrientation() { return _orientation; } // XXX
|
||||
|
||||
protected:
|
||||
glm::vec3 _position;
|
||||
glm::quat _orientation;
|
||||
int count { 0 };
|
||||
int _count { 0 };
|
||||
};
|
||||
|
||||
class Grab {
|
||||
|
@ -48,7 +48,8 @@ public:
|
|||
_parentJointIndex(newParentJointIndex),
|
||||
_hand(newHand),
|
||||
_positionalOffset(newPositionalOffset),
|
||||
_rotationalOffset(newRotationalOffset) {}
|
||||
_rotationalOffset(newRotationalOffset),
|
||||
_released(false) {}
|
||||
|
||||
QByteArray toByteArray();
|
||||
bool fromByteArray(const QByteArray& grabData);
|
||||
|
@ -61,6 +62,7 @@ public:
|
|||
_positionalOffset = other->_positionalOffset;
|
||||
_rotationalOffset = other->_rotationalOffset;
|
||||
_actionID = other->_actionID;
|
||||
_released = other->_released;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -85,6 +87,9 @@ public:
|
|||
glm::quat getRotationalOffset() const { return _rotationalOffset; }
|
||||
void setRotationalOffset(glm::quat rotationalOffset) { _rotationalOffset = rotationalOffset; }
|
||||
|
||||
bool getReleased() const { return _released; }
|
||||
void setReleased(bool value) { _released = value; }
|
||||
|
||||
protected:
|
||||
QUuid _actionID; // if an action is created in bullet for this grab, this is the ID
|
||||
QUuid _ownerID; // avatar ID of grabber
|
||||
|
@ -93,6 +98,7 @@ protected:
|
|||
QString _hand; // "left" or "right"
|
||||
glm::vec3 _positionalOffset; // relative to joint
|
||||
glm::quat _rotationalOffset; // relative to joint
|
||||
bool _released { false }; // released and scheduled for deletion
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1390,7 +1390,12 @@ void SpatiallyNestable::removeGrab(GrabPointer grab) {
|
|||
bool SpatiallyNestable::hasGrabs() {
|
||||
bool result { false };
|
||||
_grabsLock.withReadLock([&] {
|
||||
result = !_grabs.isEmpty();
|
||||
foreach (const GrabPointer &grab, _grabs) {
|
||||
if (grab && !grab->getReleased()) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -218,6 +218,7 @@ public:
|
|||
|
||||
virtual void addGrab(GrabPointer grab);
|
||||
virtual void removeGrab(GrabPointer grab);
|
||||
virtual void disableGrab(GrabPointer grab) {};
|
||||
bool hasGrabs();
|
||||
virtual QUuid getEditSenderID();
|
||||
|
||||
|
@ -241,7 +242,7 @@ protected:
|
|||
quint64 _rotationChanged { 0 };
|
||||
|
||||
mutable ReadWriteLockable _grabsLock;
|
||||
QSet<GrabPointer> _grabs;
|
||||
QSet<GrabPointer> _grabs; // upon this thing
|
||||
|
||||
private:
|
||||
SpatiallyNestable() = delete;
|
||||
|
|
|
@ -33,6 +33,10 @@ const QStringList& FileUtils::getFileSelectors() {
|
|||
#if defined(USE_GLES)
|
||||
extraSelectors << "gles";
|
||||
#endif
|
||||
|
||||
#ifndef Q_OS_ANDROID
|
||||
extraSelectors << "webengine";
|
||||
#endif
|
||||
});
|
||||
return extraSelectors;
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include <shared/ReadWriteLockable.h>
|
||||
|
||||
#include "SecurityImageProvider.h"
|
||||
#include "shared/FileUtils.h"
|
||||
#include "types/FileTypeProfile.h"
|
||||
#include "types/HFWebEngineProfile.h"
|
||||
#include "types/SoundEffect.h"
|
||||
|
@ -237,7 +238,9 @@ void OffscreenQmlSurface::clearFocusItem() {
|
|||
|
||||
void OffscreenQmlSurface::initializeEngine(QQmlEngine* engine) {
|
||||
Parent::initializeEngine(engine);
|
||||
new QQmlFileSelector(engine);
|
||||
QQmlFileSelector* fileSelector = new QQmlFileSelector(engine);
|
||||
fileSelector->setExtraSelectors(FileUtils::getFileSelectors());
|
||||
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
qRegisterMetaType<TabletProxy*>();
|
||||
|
|
Loading…
Reference in a new issue