Fix width of html pages in Create mode

This commit is contained in:
vladest 2017-08-21 17:07:24 +02:00
parent 9fd2a742a9
commit 43d3544a0d

View file

@ -4,6 +4,9 @@ import QtWebChannel 1.0
import "../controls-uit" as HiFiControls
Item {
width: parent !== null ? parent.width : undefined
height: parent !== null ? parent.height : undefined
property alias url: root.url
property alias scriptURL: root.userScriptUrl
property alias canGoBack: root.canGoBack;
@ -25,12 +28,9 @@ Item {
Flickable {
id: flick
x: 0
y: 0
width: parent.width
height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height
WebEngineView {
id: root
objectName: "webEngineView"
@ -86,9 +86,13 @@ Item {
onContentsSizeChanged: {
console.log("WebView contentsSize", contentsSize)
flick.contentWidth = Math.max(contentsSize.width, flick.width)
flick.contentWidth = flick.width
flick.contentHeight = Math.max(contentsSize.height, flick.height)
}
//disable popup
onContextMenuRequested: {
request.accepted = true;
}
onLoadingChanged: {
keyboardRaised = false;
@ -97,6 +101,8 @@ Item {
// 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)) {
@ -106,22 +112,10 @@ 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);
})
root.runJavaScript("document.body.scrollHeight;", function (i_actualPageHeight) {
flick.contentHeight = Math.max(i_actualPageHeight, flick.height);
})
flick.contentWidth = flick.width
}
}
@ -133,11 +127,14 @@ Item {
tabletRoot.openBrowserWindow(request, profile);
}
}
HiFiControls.WebSpinner { }
}
}
HiFiControls.WebSpinner {
anchors.centerIn: parent
webroot: root
}
HiFiControls.Keyboard {
id: keyboard
raised: parent.keyboardEnabled && parent.keyboardRaised