mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Fixed spinner in center. Flicking only vertically
This commit is contained in:
parent
78e9bb6020
commit
3be684b973
3 changed files with 53 additions and 39 deletions
|
@ -11,8 +11,9 @@
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
|
|
||||||
AnimatedImage {
|
AnimatedImage {
|
||||||
|
property Item webroot: parent
|
||||||
source: "../../icons/loader-snake-64-w.gif"
|
source: "../../icons/loader-snake-64-w.gif"
|
||||||
visible: parent.loading && /^(http.*|)$/i.test(parent.url.toString())
|
visible: webroot.loading && /^(http.*|)$/i.test(webroot.url.toString())
|
||||||
z: 10000
|
z: 10000
|
||||||
anchors {
|
anchors {
|
||||||
horizontalCenter: parent.horizontalCenter
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
|
|
@ -4,11 +4,12 @@ import QtWebChannel 1.0
|
||||||
import "../controls-uit" as HiFiControls
|
import "../controls-uit" as HiFiControls
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
property alias url: root.url
|
id: root
|
||||||
property alias scriptURL: root.userScriptUrl
|
property alias url: webroot.url
|
||||||
property alias canGoBack: root.canGoBack;
|
property alias scriptURL: webroot.userScriptUrl
|
||||||
property var goBack: root.goBack;
|
property alias canGoBack: webroot.canGoBack;
|
||||||
property alias urlTag: root.urlTag
|
property var goBack: webroot.goBack;
|
||||||
|
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
|
||||||
|
@ -21,17 +22,15 @@ Item {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
property alias viewProfile: root.profile
|
property alias viewProfile: webroot.profile
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
id: flick
|
id: flick
|
||||||
x: 0
|
|
||||||
y: 0
|
|
||||||
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 {
|
WebEngineView {
|
||||||
id: root
|
id: webroot
|
||||||
objectName: "webEngineView"
|
objectName: "webEngineView"
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ Item {
|
||||||
// User script.
|
// User script.
|
||||||
WebEngineScript {
|
WebEngineScript {
|
||||||
id: userScript
|
id: userScript
|
||||||
sourceUrl: root.userScriptUrl
|
sourceUrl: webroot.userScriptUrl
|
||||||
injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished.
|
injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished.
|
||||||
worldId: WebEngineScript.MainWorld
|
worldId: WebEngineScript.MainWorld
|
||||||
}
|
}
|
||||||
|
@ -69,21 +68,25 @@ Item {
|
||||||
|
|
||||||
property string newUrl: ""
|
property string newUrl: ""
|
||||||
|
|
||||||
|
//disable popup
|
||||||
|
onContextMenuRequested: {
|
||||||
|
request.accepted = true;
|
||||||
|
}
|
||||||
|
|
||||||
onContentsSizeChanged: {
|
onContentsSizeChanged: {
|
||||||
console.log("WebView contentsSize", contentsSize)
|
flick.contentHeight = Math.max(contentsSize.height, flick.height);
|
||||||
flick.contentWidth = Math.max(contentsSize.width, flick.width)
|
flick.contentWidth = flick.width
|
||||||
flick.contentHeight = Math.max(contentsSize.height, flick.height)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
webChannel.registerObject("eventBridge", eventBridge);
|
webChannel.registerObject("eventBridge", eventBridge);
|
||||||
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
|
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
|
||||||
// Ensure the JS from the web-engine makes it to our logging
|
// Ensure the JS from the web-engine makes it to our logging
|
||||||
root.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
webroot.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
||||||
console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
|
console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
|
||||||
});
|
});
|
||||||
|
|
||||||
root.profile.httpUserAgent = "Mozilla/5.0 Chrome (HighFidelityInterface)";
|
webroot.profile.httpUserAgent = "Mozilla/5.0 Chrome (HighFidelityInterface)";
|
||||||
}
|
}
|
||||||
|
|
||||||
onFeaturePermissionRequested: {
|
onFeaturePermissionRequested: {
|
||||||
|
@ -99,28 +102,19 @@ Item {
|
||||||
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
||||||
flick.contentWidth = 0
|
flick.contentWidth = 0
|
||||||
flick.contentHeight = 0
|
flick.contentHeight = 0
|
||||||
flick.contentX = 0
|
|
||||||
flick.contentY = 0
|
|
||||||
var url = loadRequest.url.toString();
|
var url = loadRequest.url.toString();
|
||||||
url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
|
url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
|
||||||
if (urlHandler.canHandleUrl(url)) {
|
if (urlHandler.canHandleUrl(url)) {
|
||||||
if (urlHandler.handleUrl(url)) {
|
if (urlHandler.handleUrl(url)) {
|
||||||
root.stop();
|
webroot.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
|
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
|
||||||
root.runJavaScript("document.body.scrollHeight;",
|
webroot.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) {
|
||||||
function (i_actualPageHeight) {
|
flick.contentHeight = Math.max(i_actualPageHeight, flick.height);
|
||||||
console.log("on reloaded documentElement.scrollHeigh:", i_actualPageHeight)
|
})
|
||||||
flick.contentHeight = Math.max(i_actualPageHeight, flick.height);
|
flick.contentWidth = flick.width
|
||||||
})
|
|
||||||
root.runJavaScript("document.body.scrollWidth;",
|
|
||||||
function (i_actualPageWidth) {
|
|
||||||
console.log("on reloaded documentElement.scrollWidth:", i_actualPageWidth)
|
|
||||||
|
|
||||||
flick.contentWidth = Math.max(i_actualPageWidth, flick.width);
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,11 +126,14 @@ Item {
|
||||||
tabletRoot.openBrowserWindow(request, profile);
|
tabletRoot.openBrowserWindow(request, profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HiFiControls.WebSpinner { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HiFiControls.WebSpinner {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
webroot: webroot
|
||||||
|
}
|
||||||
|
|
||||||
HiFiControls.Keyboard {
|
HiFiControls.Keyboard {
|
||||||
id: keyboard
|
id: keyboard
|
||||||
raised: parent.keyboardEnabled && parent.keyboardRaised
|
raised: parent.keyboardEnabled && parent.keyboardRaised
|
||||||
|
@ -147,5 +144,4 @@ Item {
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,8 +138,6 @@ Item {
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
id: flick
|
id: flick
|
||||||
x: 0
|
|
||||||
y: 0
|
|
||||||
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 - web.headerHeight : parent.height - web.headerHeight
|
||||||
anchors.top: buttons.bottom
|
anchors.top: buttons.bottom
|
||||||
|
@ -206,12 +204,23 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onContentsSizeChanged: {
|
||||||
|
flick.contentHeight = Math.max(contentsSize.height, flick.height);
|
||||||
|
flick.contentWidth = flick.width//Math.max(contentsSize.width, flick.width);
|
||||||
|
}
|
||||||
|
//disable popup
|
||||||
|
onContextMenuRequested: {
|
||||||
|
request.accepted = true;
|
||||||
|
}
|
||||||
|
|
||||||
onLoadingChanged: {
|
onLoadingChanged: {
|
||||||
keyboardRaised = false;
|
keyboardRaised = false;
|
||||||
punctuationMode = false;
|
punctuationMode = false;
|
||||||
keyboard.resetShiftMode(false);
|
keyboard.resetShiftMode(false);
|
||||||
// Required to support clicking on "hifi://" links
|
// Required to support clicking on "hifi://" links
|
||||||
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
||||||
|
flick.contentWidth = 0
|
||||||
|
flick.contentHeight = 0
|
||||||
var url = loadRequest.url.toString();
|
var url = loadRequest.url.toString();
|
||||||
if (urlHandler.canHandleUrl(url)) {
|
if (urlHandler.canHandleUrl(url)) {
|
||||||
if (urlHandler.handleUrl(url)) {
|
if (urlHandler.handleUrl(url)) {
|
||||||
|
@ -225,8 +234,13 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
|
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
|
||||||
flick.contentWidth = Math.max(contentsSize.width, flick.width)
|
webroot.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) {
|
||||||
flick.contentHeight = Math.max(contentsSize.height, flick.height)
|
flick.contentHeight = Math.max(i_actualPageHeight, flick.height);
|
||||||
|
})
|
||||||
|
// webroot.runJavaScript("document.body.scrollWidth;", function (i_actualPageWidth) {
|
||||||
|
flick.contentWidth = flick.width//Math.max(i_actualPageWidth, flick.width);
|
||||||
|
// })
|
||||||
|
|
||||||
webview.forceActiveFocus();
|
webview.forceActiveFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,11 +248,14 @@ Item {
|
||||||
onNewViewRequested: {
|
onNewViewRequested: {
|
||||||
request.openIn(webview);
|
request.openIn(webview);
|
||||||
}
|
}
|
||||||
|
|
||||||
HiFiControls.WebSpinner { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HiFiControls.WebSpinner {
|
||||||
|
webroot: webview
|
||||||
|
anchors.centerIn: parent
|
||||||
|
}
|
||||||
|
|
||||||
HiFiControls.Keyboard {
|
HiFiControls.Keyboard {
|
||||||
id: keyboard
|
id: keyboard
|
||||||
raised: parent.keyboardEnabled && parent.keyboardRaised
|
raised: parent.keyboardEnabled && parent.keyboardRaised
|
||||||
|
|
Loading…
Reference in a new issue