diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-14 01:21:25 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-14 01:23:37 +0200 |
commit | fa7300e3cd0297282907f703bc4b07965d9f85a9 (patch) | |
tree | 9ffbc5e7a3bc496b16764afc8ec3198479836c89 /components/package/contents/ui/WebView.qml | |
parent | df326b81ddcafb45467c9e1e434c09e8b12a6baa (diff) | |
download | kube-fa7300e3cd0297282907f703bc4b07965d9f85a9.tar.gz kube-fa7300e3cd0297282907f703bc4b07965d9f85a9.zip |
Ported the WebView to webengine
Diffstat (limited to 'components/package/contents/ui/WebView.qml')
-rw-r--r-- | components/package/contents/ui/WebView.qml | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/components/package/contents/ui/WebView.qml b/components/package/contents/ui/WebView.qml index fe3a8bcd..01998911 100644 --- a/components/package/contents/ui/WebView.qml +++ b/components/package/contents/ui/WebView.qml | |||
@@ -2,49 +2,30 @@ import QtQuick 2.4 | |||
2 | import QtQuick.Controls 1.3 | 2 | import QtQuick.Controls 1.3 |
3 | import QtWebKit 3.0 | 3 | import QtWebKit 3.0 |
4 | // import QtWebEngine 1.3 //This would give use contentsSize | 4 | // import QtWebEngine 1.3 //This would give use contentsSize |
5 | // import QtWebEngine 1.2 | 5 | import QtWebEngine 1.2 |
6 | 6 | ||
7 | Item { | 7 | Item { |
8 | id: root | 8 | id: root |
9 | property string content; | 9 | property string content; |
10 | // property int contentWidth: 500; | 10 | property int contentWidth: helperView.contentWidth; |
11 | // property int contentHeight: 500; | 11 | property int contentHeight: helperView.contentHeight; |
12 | property int contentWidth: htmlView.contentWidth; | 12 | //FIXME workaround until QtWebEngine 1.3 with contentsSize |
13 | property int contentHeight: htmlView.contentHeight; | ||
14 | // width: htmlView.width | ||
15 | // height: htmlView.height | ||
16 | WebView { | 13 | WebView { |
14 | id: helperView | ||
15 | visible: false | ||
16 | Component.onCompleted: loadHtml(content, "file:///") | ||
17 | } | ||
18 | WebEngineView { | ||
17 | id: htmlView | 19 | id: htmlView |
18 | anchors.top: parent.top | 20 | anchors.fill: parent |
19 | anchors.horizontalCenter: parent.horizontalCenter | ||
20 | width: contentWidth | ||
21 | height: contentHeight | ||
22 | onNavigationRequested: { | ||
23 | // detect URL scheme prefix, most likely an external link | ||
24 | var schemaRE = /^\w+:/; | ||
25 | if (schemaRE.test(request.url)) { | ||
26 | request.action = WebView.AcceptRequest; | ||
27 | } else { | ||
28 | request.action = WebView.IgnoreRequest; | ||
29 | // delegate request.url here | ||
30 | } | ||
31 | } | ||
32 | onLoadingChanged: { | 21 | onLoadingChanged: { |
33 | console.warn("Error is ", loadRequest.errorString); | 22 | console.warn("Error is ", loadRequest.errorString); |
34 | console.warn("Status is ", loadRequest.status); | 23 | console.warn("Status is ", loadRequest.status); |
35 | } | 24 | } |
36 | Component.onCompleted: loadHtml(content, "file:///") | 25 | Component.onCompleted: loadHtml(content, "file:///") |
37 | } | 26 | } |
38 | // WebEngineView { | ||
39 | // id: htmlView | ||
40 | // anchors.fill: parent | ||
41 | // onLoadingChanged: { | ||
42 | // console.warn("Error is ", loadRequest.errorString); | ||
43 | // console.warn("Status is ", loadRequest.status); | ||
44 | // } | ||
45 | // Component.onCompleted: loadHtml(content, "file:///") | ||
46 | // } | ||
47 | onContentChanged: { | 27 | onContentChanged: { |
48 | htmlView.loadHtml(content, "file:///"); | 28 | htmlView.loadHtml(content, "file:///"); |
29 | helperView.loadHtml(content, "file:///"); | ||
49 | } | 30 | } |
50 | } | 31 | } |