mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
1st experimental approach
This commit is contained in:
parent
42f6333948
commit
56dedea66c
3 changed files with 279 additions and 208 deletions
|
@ -1,5 +1,5 @@
|
||||||
import QtQuick 2.5
|
import QtQuick 2.7
|
||||||
import QtWebEngine 1.1
|
import QtWebEngine 1.5
|
||||||
import QtWebChannel 1.0
|
import QtWebChannel 1.0
|
||||||
import "../controls-uit" as HiFiControls
|
import "../controls-uit" as HiFiControls
|
||||||
|
|
||||||
|
@ -23,14 +23,18 @@ Item {
|
||||||
|
|
||||||
property alias viewProfile: root.profile
|
property alias viewProfile: root.profile
|
||||||
|
|
||||||
WebEngineView {
|
Flickable {
|
||||||
id: root
|
id: flick
|
||||||
objectName: "webEngineView"
|
|
||||||
x: 0
|
x: 0
|
||||||
y: 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 {
|
||||||
|
id: root
|
||||||
|
objectName: "webEngineView"
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
profile: HFWebEngineProfile;
|
profile: HFWebEngineProfile;
|
||||||
|
|
||||||
property string userScriptUrl: ""
|
property string userScriptUrl: ""
|
||||||
|
@ -65,6 +69,11 @@ Item {
|
||||||
|
|
||||||
property string newUrl: ""
|
property string newUrl: ""
|
||||||
|
|
||||||
|
onContentsSizeChanged: {
|
||||||
|
console.log("WebView contentsSize", contentsSize)
|
||||||
|
flick.contentWidth = Math.max(contentsSize.width, flick.width)
|
||||||
|
flick.contentHeight = Math.max(contentsSize.height, flick.height)
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
webChannel.registerObject("eventBridge", eventBridge);
|
webChannel.registerObject("eventBridge", eventBridge);
|
||||||
|
@ -82,12 +91,15 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoadingChanged: {
|
onLoadingChanged: {
|
||||||
|
console.log("loading changed", loadRequest.status)
|
||||||
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 = -1
|
||||||
|
flick.contentHeight = -1
|
||||||
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)) {
|
||||||
|
@ -96,6 +108,26 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
|
||||||
|
// flick.contentWidth = Math.max(contentsSize.width, flick.width)
|
||||||
|
// flick.contentHeight = Math.max(contentsSize.height, flick.height)
|
||||||
|
root.runJavaScript(
|
||||||
|
"document.body.scrollHeight;",
|
||||||
|
function (i_actualPageHeight) {
|
||||||
|
console.log("on reloaded documentElement.scrollHeigh:", i_actualPageHeight)
|
||||||
|
// flick.contentHeight = Math.max (
|
||||||
|
// i_actualPageHeight, flick.height);
|
||||||
|
})
|
||||||
|
root.runJavaScript(
|
||||||
|
"document.body.scrollWidth;",
|
||||||
|
function (i_actualPageWidth) {
|
||||||
|
console.log("on reloaded documentElement.scrollWidth:", i_actualPageWidth)
|
||||||
|
|
||||||
|
// flick.contentWidth = Math.max (
|
||||||
|
// i_actualPageWidth, flick.width);
|
||||||
|
})
|
||||||
|
console.log("on reloaded content size:", contentsSize)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onNewViewRequested:{
|
onNewViewRequested:{
|
||||||
|
@ -109,6 +141,7 @@ Item {
|
||||||
|
|
||||||
HiFiControls.WebSpinner { }
|
HiFiControls.WebSpinner { }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HiFiControls.Keyboard {
|
HiFiControls.Keyboard {
|
||||||
id: keyboard
|
id: keyboard
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import QtQuick 2.5
|
import QtQuick 2.7
|
||||||
import QtQuick.Controls 1.4
|
import QtQuick.Controls 1.4
|
||||||
import QtWebEngine 1.2
|
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
|
||||||
|
@ -136,14 +136,19 @@ Item {
|
||||||
loadUrl(url);
|
loadUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebEngineView {
|
Flickable {
|
||||||
id: webview
|
id: flick
|
||||||
objectName: "webEngineView"
|
|
||||||
x: 0
|
x: 0
|
||||||
y: 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
|
||||||
|
|
||||||
|
WebEngineView {
|
||||||
|
id: webview
|
||||||
|
objectName: "webEngineView"
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
profile: HFWebEngineProfile;
|
profile: HFWebEngineProfile;
|
||||||
|
|
||||||
property string userScriptUrl: ""
|
property string userScriptUrl: ""
|
||||||
|
@ -220,6 +225,8 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
|
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
|
||||||
|
flick.contentWidth = Math.max(contentsSize.width, flick.width)
|
||||||
|
flick.contentHeight = Math.max(contentsSize.height, flick.height)
|
||||||
webview.forceActiveFocus();
|
webview.forceActiveFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,6 +237,7 @@ Item {
|
||||||
|
|
||||||
HiFiControls.WebSpinner { }
|
HiFiControls.WebSpinner { }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HiFiControls.Keyboard {
|
HiFiControls.Keyboard {
|
||||||
id: keyboard
|
id: keyboard
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import QtQuick 2.5
|
import QtQuick 2.7
|
||||||
import QtWebEngine 1.1
|
import QtWebEngine 1.5
|
||||||
import QtWebChannel 1.0
|
import QtWebChannel 1.0
|
||||||
import "../controls-uit" as HiFiControls
|
import "../controls-uit" as HiFiControls
|
||||||
|
|
||||||
|
@ -23,14 +23,19 @@ Item {
|
||||||
|
|
||||||
property alias viewProfile: root.profile
|
property alias viewProfile: root.profile
|
||||||
|
|
||||||
WebEngineView {
|
Flickable {
|
||||||
id: root
|
id: flick
|
||||||
objectName: "webEngineView"
|
|
||||||
x: 0
|
x: 0
|
||||||
y: 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 {
|
||||||
|
id: root
|
||||||
|
objectName: "webEngineView"
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
profile: HFWebEngineProfile;
|
profile: HFWebEngineProfile;
|
||||||
|
|
||||||
property string userScriptUrl: ""
|
property string userScriptUrl: ""
|
||||||
|
@ -79,6 +84,12 @@ Item {
|
||||||
grantFeaturePermission(securityOrigin, feature, true);
|
grantFeaturePermission(securityOrigin, feature, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onContentsSizeChanged: {
|
||||||
|
console.log("WebView contentsSize", contentsSize)
|
||||||
|
flick.contentWidth = Math.max(contentsSize.width, flick.width)
|
||||||
|
flick.contentHeight = Math.max(contentsSize.height, flick.height)
|
||||||
|
}
|
||||||
|
|
||||||
onLoadingChanged: {
|
onLoadingChanged: {
|
||||||
keyboardRaised = false;
|
keyboardRaised = false;
|
||||||
punctuationMode = false;
|
punctuationMode = false;
|
||||||
|
@ -94,6 +105,24 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (WebEngineView.LoadSucceededStatus == loadRequest.status) {
|
||||||
|
|
||||||
|
// flick.contentWidth = Math.max(contentsSize.width, flick.width)
|
||||||
|
// flick.contentHeight = Math.max(contentsSize.height, flick.height)
|
||||||
|
root.runJavaScript(
|
||||||
|
"document.body.scrollHeight;",
|
||||||
|
function (i_actualPageHeight) {
|
||||||
|
flick.contentHeight = Math.max (
|
||||||
|
i_actualPageHeight, flick.height);
|
||||||
|
})
|
||||||
|
root.runJavaScript(
|
||||||
|
"document.body.scrollWidth;",
|
||||||
|
function (i_actualPageWidth) {
|
||||||
|
flick.contentWidth = Math.max (
|
||||||
|
i_actualPageWidth, flick.width);
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onNewViewRequested:{
|
onNewViewRequested:{
|
||||||
|
@ -107,6 +136,7 @@ Item {
|
||||||
|
|
||||||
HiFiControls.WebSpinner { }
|
HiFiControls.WebSpinner { }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HiFiControls.Keyboard {
|
HiFiControls.Keyboard {
|
||||||
id: keyboard
|
id: keyboard
|
||||||
|
|
Loading…
Reference in a new issue