summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/qml/ConversationListView.qml130
-rw-r--r--framework/qml/ConversationView.qml14
2 files changed, 75 insertions, 69 deletions
diff --git a/framework/qml/ConversationListView.qml b/framework/qml/ConversationListView.qml
index fb91e14d..b00002b1 100644
--- a/framework/qml/ConversationListView.qml
+++ b/framework/qml/ConversationListView.qml
@@ -24,11 +24,11 @@ import org.kube.framework 1.0 as Kube
24 24
25import QtQml 2.2 as QtQml 25import QtQml 2.2 as QtQml
26 26
27Flickable { 27FocusScope {
28 id: root 28 id: root
29 focus: true
30 property alias model: repeater.model 29 property alias model: repeater.model
31 property alias delegate: repeater.delegate 30 property alias delegate: repeater.delegate
31 property alias contentHeight: flickable.contentHeight
32 property int currentIndex: -1 32 property int currentIndex: -1
33 33
34 property var currentItem: null 34 property var currentItem: null
@@ -56,83 +56,87 @@ Flickable {
56 setCurrentItem() 56 setCurrentItem()
57 } 57 }
58 58
59 //Optimize for view quality 59 Flickable {
60 pixelAligned: true 60 id: flickable
61 61 anchors.fill: parent
62 contentWidth: width
63 contentHeight: col.height
64 62
65 function scrollToIndex(index) { 63 //Optimize for view quality
66 var item = repeater.itemAt(index) 64 pixelAligned: true
67 var pos = item.y 65
68 var scrollToEndPos = (root.contentHeight - root.height) 66 contentWidth: width
69 //Avoid scrolling past the end 67 contentHeight: col.height
70 if (pos < scrollToEndPos) { 68
71 root.contentY = pos 69 function scrollToIndex(index) {
72 } else { 70 var item = repeater.itemAt(index)
73 root.contentY = scrollToEndPos 71 var pos = item.y
72 var scrollToEndPos = (flickable.contentHeight - flickable.height)
73 //Avoid scrolling past the end
74 if (pos < scrollToEndPos) {
75 flickable.contentY = pos
76 } else {
77 flickable.contentY = scrollToEndPos
78 }
74 } 79 }
75 }
76 80
77 onContentHeightChanged: { 81 onContentHeightChanged: {
78 if (repeater.count) { 82 if (repeater.count) {
79 //Scroll to the last item 83 //Scroll to the last item
80 currentIndex = repeater.count - 1 84 currentIndex = repeater.count - 1
81 scrollToIndex(repeater.count - 1) 85 scrollToIndex(repeater.count - 1)
86 }
82 } 87 }
83 }
84 88
85 property real span : contentY + height 89 Column {
86 Column { 90 id: col
87 id: col 91 width: parent.width
88 width: parent.width 92 spacing: 2
89 spacing: 2 93 Repeater {
90 Repeater { 94 id: repeater
91 id: repeater 95 onCountChanged: {
92 onCountChanged: { 96 for (var i = 0; i < count; i++) {
93 for (var i = 0; i < count; i++) { 97 itemAt(i).index = i
94 itemAt(i).index = i 98 }
95 } 99 }
96 } 100 }
97 } 101 }
98 }
99 102
100 function incrementCurrentIndex() { 103 function incrementCurrentIndex() {
101 if (currentIndex < repeater.count - 1) { 104 if (currentIndex < repeater.count - 1) {
102 currentIndex = currentIndex + 1 105 currentIndex = currentIndex + 1
106 }
103 } 107 }
104 }
105 108
106 function decrementCurrentIndex() { 109 function decrementCurrentIndex() {
107 if (currentIndex > 0) { 110 if (currentIndex > 0) {
108 currentIndex = currentIndex - 1 111 currentIndex = currentIndex - 1
112 }
109 } 113 }
110 }
111 114
112 Keys.onDownPressed: { 115 Keys.onDownPressed: {
113 incrementCurrentIndex() 116 incrementCurrentIndex()
114 scrollToIndex(currentIndex) 117 scrollToIndex(currentIndex)
115 } 118 }
116 119
117 Keys.onUpPressed: { 120 Keys.onUpPressed: {
118 decrementCurrentIndex() 121 decrementCurrentIndex()
119 scrollToIndex(currentIndex) 122 scrollToIndex(currentIndex)
120 } 123 }
121 124
122 Kube.ScrollHelper { 125 Kube.ScrollHelper {
123 id: scrollHelper 126 id: scrollHelper
124 flickable: root 127 flickable: flickable
125 anchors.fill: parent 128 anchors.fill: parent
126 } 129 }
127 130
128 //Intercept all scroll events, 131 //Intercept all scroll events,
129 //necessary due to the webengineview 132 //necessary due to the webengineview
130 Kube.MouseProxy { 133 Kube.MouseProxy {
131 anchors.fill: parent 134 anchors.fill: parent
132 target: scrollHelper 135 target: scrollHelper
133 forwardWheelEvents: true 136 forwardWheelEvents: true
134 } 137 }
135 138
136 ScrollBar.vertical: ScrollBar {} 139 ScrollBar.vertical: ScrollBar {}
137 140
141 }
138} 142}
diff --git a/framework/qml/ConversationView.qml b/framework/qml/ConversationView.qml
index 92b2a0c1..9eab9afa 100644
--- a/framework/qml/ConversationView.qml
+++ b/framework/qml/ConversationView.qml
@@ -74,8 +74,13 @@ FocusScope {
74 property bool isCurrentItem: false 74 property bool isCurrentItem: false
75 property int index: -1 75 property int index: -1
76 76
77 focus: false 77 focus: true
78 activeFocusOnTab: false 78 activeFocusOnTab: false
79 onActiveFocusChanged: {
80 if (activeFocus) {
81 listView.currentIndex = delegateRoot.index
82 }
83 }
79 84
80 height: sheet.height + Kube.Units.gridUnit 85 height: sheet.height + Kube.Units.gridUnit
81 width: listView.width 86 width: listView.width
@@ -83,12 +88,9 @@ FocusScope {
83 88
84 MouseArea { 89 MouseArea {
85 anchors.fill: parent 90 anchors.fill: parent
91 acceptedButtons: Qt.NoButton
86 hoverEnabled: true 92 hoverEnabled: true
87 onEntered: listView.currentIndex = delegateRoot.index 93 onEntered: delegateRoot.forceActiveFocus(Qt.MouseFocusReason)
88 onClicked: {
89 listView.currentIndex = delegateRoot.index
90 listView.forceActiveFocus(Qt.MouseFocusReason)
91 }
92 } 94 }
93 95
94 MailViewer { 96 MailViewer {