summaryrefslogtreecommitdiffstats
path: root/components/package/contents/ui/WebView.qml
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-13 01:02:21 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-14 01:23:10 +0200
commitdf326b81ddcafb45467c9e1e434c09e8b12a6baa (patch)
tree3b005fa68a3504f0b7454a4e1a8ef56c0dd7b9dd /components/package/contents/ui/WebView.qml
parent1213815b42e94f41817b79fc9e311742a330d9ae (diff)
downloadkube-df326b81ddcafb45467c9e1e434c09e8b12a6baa.tar.gz
kube-df326b81ddcafb45467c9e1e434c09e8b12a6baa.zip
Prepared WebEngine port and resize according to content
Diffstat (limited to 'components/package/contents/ui/WebView.qml')
-rw-r--r--components/package/contents/ui/WebView.qml50
1 files changed, 50 insertions, 0 deletions
diff --git a/components/package/contents/ui/WebView.qml b/components/package/contents/ui/WebView.qml
new file mode 100644
index 00000000..fe3a8bcd
--- /dev/null
+++ b/components/package/contents/ui/WebView.qml
@@ -0,0 +1,50 @@
1import QtQuick 2.4
2import QtQuick.Controls 1.3
3import QtWebKit 3.0
4// import QtWebEngine 1.3 //This would give use contentsSize
5// import QtWebEngine 1.2
6
7Item {
8 id: root
9 property string content;
10 // property int contentWidth: 500;
11 // property int contentHeight: 500;
12 property int contentWidth: htmlView.contentWidth;
13 property int contentHeight: htmlView.contentHeight;
14 // width: htmlView.width
15 // height: htmlView.height
16 WebView {
17 id: htmlView
18 anchors.top: parent.top
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: {
33 console.warn("Error is ", loadRequest.errorString);
34 console.warn("Status is ", loadRequest.status);
35 }
36 Component.onCompleted: loadHtml(content, "file:///")
37 }
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: {
48 htmlView.loadHtml(content, "file:///");
49 }
50}