diff options
Diffstat (limited to 'components/package/contents/ui/WebView.qml')
-rw-r--r-- | components/package/contents/ui/WebView.qml | 50 |
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 @@ | |||
1 | import QtQuick 2.4 | ||
2 | import QtQuick.Controls 1.3 | ||
3 | import QtWebKit 3.0 | ||
4 | // import QtWebEngine 1.3 //This would give use contentsSize | ||
5 | // import QtWebEngine 1.2 | ||
6 | |||
7 | Item { | ||
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 | } | ||