summaryrefslogtreecommitdiffstats
path: root/components/package/contents/ui
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
parent1213815b42e94f41817b79fc9e311742a330d9ae (diff)
downloadkube-df326b81ddcafb45467c9e1e434c09e8b12a6baa.tar.gz
kube-df326b81ddcafb45467c9e1e434c09e8b12a6baa.zip
Prepared WebEngine port and resize according to content
Diffstat (limited to 'components/package/contents/ui')
-rw-r--r--components/package/contents/ui/ContentView.qml53
-rw-r--r--components/package/contents/ui/MailListView.qml4
-rw-r--r--components/package/contents/ui/MailViewer.qml7
-rw-r--r--components/package/contents/ui/MessagePartTree.qml11
-rw-r--r--components/package/contents/ui/TextView.qml15
-rw-r--r--components/package/contents/ui/WebView.qml50
6 files changed, 90 insertions, 50 deletions
diff --git a/components/package/contents/ui/ContentView.qml b/components/package/contents/ui/ContentView.qml
index d4ddabce..a8f4c437 100644
--- a/components/package/contents/ui/ContentView.qml
+++ b/components/package/contents/ui/ContentView.qml
@@ -1,6 +1,5 @@
1import QtQuick 2.4 1import QtQuick 2.4
2import QtQuick.Controls 1.3 2import QtQuick.Controls 1.3
3import QtWebKit 3.0
4 3
5Item { 4Item {
6 id: root 5 id: root
@@ -8,7 +7,8 @@ Item {
8 property bool isHtml; 7 property bool isHtml;
9 property string content; 8 property string content;
10 property string contentType; 9 property string contentType;
11 height: contentRect.height 10 property int contentWidth: contentLoader.item.contentWidth
11 property int contentHeight: contentLoader.item.contentHeight
12 Rectangle { 12 Rectangle {
13 id: contentRect 13 id: contentRect
14 14
@@ -17,61 +17,26 @@ Item {
17 // border.color: "black" 17 // border.color: "black"
18 // radius: 5 18 // radius: 5
19 // anchors.leftMargin: nestingLevel * 5 19 // anchors.leftMargin: nestingLevel * 5
20 20 anchors.fill: parent
21 height: contentLoader.height
22 width: root.width
23 21
24 Loader { 22 Loader {
25 id: contentLoader 23 id: contentLoader
26 anchors.top: contentRect.top 24 property string content: root.content
27 anchors.left: contentRect.left 25 anchors.fill: parent
28 width: contentRect.width
29 sourceComponent: isHtml ? htmlComponent : textComponent 26 sourceComponent: isHtml ? htmlComponent : textComponent
30 height: isHtml ? item.flickableItem.contentHeight : text.height
31 onStatusChanged: {
32 if (isHtml) {
33 item.flickableItem.loadHtml(root.content, "file:///");
34 }
35 }
36 } 27 }
37 28
38 Component { 29 Component {
39 id: textComponent 30 id: textComponent
40 Text { 31 TextView {
41 id: text 32 content: root.content
42 text: content
43 } 33 }
44 } 34 }
45 Component { 35 Component {
46 id: htmlComponent 36 id: htmlComponent
47 //We need the scrollview so the WebView can fully expand so we have access to the contentHeight 37 WebView {
48 //Otherwise it would just scale the content. 38 content: root.content
49 ScrollView {
50 horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
51 verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
52 WebView {
53 id: htmlView
54 onNavigationRequested: {
55 // detect URL scheme prefix, most likely an external link
56 var schemaRE = /^\w+:/;
57 if (schemaRE.test(request.url)) {
58 request.action = WebView.AcceptRequest;
59 } else {
60 request.action = WebView.IgnoreRequest;
61 // delegate request.url here
62 }
63 }
64 onLoadingChanged: {
65 console.warn("Error is ", loadRequest.errorString);
66 console.warn("Status is ", loadRequest.status);
67 }
68 }
69 } 39 }
70 } 40 }
71 } 41 }
72 onContentChanged: {
73 if (isHtml) {
74 contentLoader.item.flickableItem.loadHtml(content, "file:///");
75 }
76 }
77} 42}
diff --git a/components/package/contents/ui/MailListView.qml b/components/package/contents/ui/MailListView.qml
index bc292705..d0278833 100644
--- a/components/package/contents/ui/MailListView.qml
+++ b/components/package/contents/ui/MailListView.qml
@@ -31,6 +31,10 @@ Controls.ScrollView {
31 property variant currentMail 31 property variant currentMail
32 property bool isDraft : false 32 property bool isDraft : false
33 33
34 onParentFolderChanged: {
35 currentMail = null
36 }
37
34 ListView { 38 ListView {
35 id: listView 39 id: listView
36 40
diff --git a/components/package/contents/ui/MailViewer.qml b/components/package/contents/ui/MailViewer.qml
index d62daaf2..53808ddd 100644
--- a/components/package/contents/ui/MailViewer.qml
+++ b/components/package/contents/ui/MailViewer.qml
@@ -26,12 +26,13 @@ Item {
26 spacing:2 26 spacing:2
27 MessagePartTree { 27 MessagePartTree {
28 id: topPartLoader 28 id: topPartLoader
29 width: rootRectangle.width 29 // width: rootRectangle.width
30 height: topPartLoader.desiredHeight 30 height: topPartLoader.contentHeight
31 width: topPartLoader.contentWidth >= rootRectangle.width ? topPartLoader.contentWidth : rootRectangle.width
31 } 32 }
32 TreeView { 33 TreeView {
33 visible: enablePartTreeView 34 visible: enablePartTreeView
34 width: 500 35 width: rootRectangle.width
35 height: 400 36 height: 400
36 TableViewColumn { 37 TableViewColumn {
37 role: "type" 38 role: "type"
diff --git a/components/package/contents/ui/MessagePartTree.qml b/components/package/contents/ui/MessagePartTree.qml
index d44a1e5e..8bc13e6e 100644
--- a/components/package/contents/ui/MessagePartTree.qml
+++ b/components/package/contents/ui/MessagePartTree.qml
@@ -5,7 +5,8 @@ Item {
5 id: root 5 id: root
6 property alias rootIndex: visualModel.rootIndex 6 property alias rootIndex: visualModel.rootIndex
7 property int nestingLevel: 0 7 property int nestingLevel: 0
8 property int desiredHeight: messagePartRect.height 8 property int contentHeight: messagePartRect.height
9 property int contentWidth: 0
9 Rectangle { 10 Rectangle {
10 id: messagePartRect 11 id: messagePartRect
11 height: partListView.contentHeight 12 height: partListView.contentHeight
@@ -24,6 +25,7 @@ Item {
24 anchors.top: delegateRect.top 25 anchors.top: delegateRect.top
25 anchors.left: delegateRect.left 26 anchors.left: delegateRect.left
26 width: messagePartRect.width 27 width: messagePartRect.width
28 height: contentHeight
27 content: model.text 29 content: model.text
28 isHtml: model.isHtml 30 isHtml: model.isHtml
29 visible: model.hasContent 31 visible: model.hasContent
@@ -33,16 +35,19 @@ Item {
33 height = 0 35 height = 0
34 } 36 }
35 } 37 }
38 onContentWidthChanged: {
39 root.contentWidth = contentWidth > root.contentWidth ? contentWidth : root.contentWidth
40 }
36 contentType: model.type 41 contentType: model.type
37 } 42 }
38 Loader { 43 Loader {
39 id: partLoader 44 id: partLoader
40 anchors.top: contentView.bottom 45 anchors.top: contentView.bottom
41 anchors.left: contentView.left 46 anchors.left: contentView.left
42 width: messagePartRect.width
43 visible: model.hasModelChildren 47 visible: model.hasModelChildren
44 active: model.hasModelChildren 48 active: model.hasModelChildren
45 height: item ? item.desiredHeight : 0 49 height: item ? item.contentHeight : 0
50 width: messagePartRect.width
46 } 51 }
47 Component.onCompleted: { 52 Component.onCompleted: {
48 if (model.hasModelChildren) { 53 if (model.hasModelChildren) {
diff --git a/components/package/contents/ui/TextView.qml b/components/package/contents/ui/TextView.qml
new file mode 100644
index 00000000..7c2f3153
--- /dev/null
+++ b/components/package/contents/ui/TextView.qml
@@ -0,0 +1,15 @@
1import QtQuick 2.4
2import QtQuick.Controls 1.3
3
4Item {
5 id: root
6 property string content;
7 property int contentWidth: 0;
8 property int contentHeight: textView.contentHeight;
9 Text {
10 id: textView
11 wrapMode: Text.WordWrap
12 anchors.fill: parent
13 text: content
14 }
15}
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}