summaryrefslogtreecommitdiffstats
path: root/framework/qml
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-04-06 16:45:04 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-04-06 16:45:04 +0200
commita301d1db33fdecb0e66495b51019922a9b040c1f (patch)
treedaa93751bcfd171b79d116d74f707e88175e0733 /framework/qml
parent72a9eeb01cdfd4f0ee5dbffcd3fe083897d8a390 (diff)
downloadkube-a301d1db33fdecb0e66495b51019922a9b040c1f.tar.gz
kube-a301d1db33fdecb0e66495b51019922a9b040c1f.zip
Conversation view keyboard navigation
Diffstat (limited to 'framework/qml')
-rw-r--r--framework/qml/ConversationListView.qml16
-rw-r--r--framework/qml/ConversationView.qml36
-rw-r--r--framework/qml/FolderListView.qml10
-rw-r--r--framework/qml/ListView.qml8
-rw-r--r--framework/qml/MailListView.qml37
-rw-r--r--framework/qml/Messages.qml8
-rw-r--r--framework/qml/TreeView.qml12
7 files changed, 79 insertions, 48 deletions
diff --git a/framework/qml/ConversationListView.qml b/framework/qml/ConversationListView.qml
index a7dc1f7d..1d408edc 100644
--- a/framework/qml/ConversationListView.qml
+++ b/framework/qml/ConversationListView.qml
@@ -68,14 +68,6 @@ FocusScope {
68 flickable.decrementCurrentIndex() 68 flickable.decrementCurrentIndex()
69 } 69 }
70 70
71 function scrollDown() {
72 scrollHelper.scrollDown()
73 }
74
75 function scrollUp() {
76 scrollHelper.scrollUp()
77 }
78
79 Flickable { 71 Flickable {
80 id: flickable 72 id: flickable
81 anchors.fill: parent 73 anchors.fill: parent
@@ -145,6 +137,14 @@ FocusScope {
145 scrollToIndex(currentIndex) 137 scrollToIndex(currentIndex)
146 } 138 }
147 139
140 Keys.onPressed: {
141 if (event.matches(StandardKey.MoveToNextLine)) {
142 scrollHelper.scrollDown()
143 } else if (event.matches(StandardKey.MoveToPreviousLine)) {
144 scrollHelper.scrollUp()
145 }
146 }
147
148 Kube.ScrollHelper { 148 Kube.ScrollHelper {
149 id: scrollHelper 149 id: scrollHelper
150 flickable: flickable 150 flickable: flickable
diff --git a/framework/qml/ConversationView.qml b/framework/qml/ConversationView.qml
index 8331e581..1109ad8e 100644
--- a/framework/qml/ConversationView.qml
+++ b/framework/qml/ConversationView.qml
@@ -17,7 +17,7 @@
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20import QtQuick 2.7 20import QtQuick 2.9
21import QtQuick.Controls 2 21import QtQuick.Controls 2
22import QtQuick.Layouts 1.1 22import QtQuick.Layouts 1.1
23import org.kube.framework 1.0 as Kube 23import org.kube.framework 1.0 as Kube
@@ -38,6 +38,22 @@ FocusScope {
38 onMessageReceived: root.searchString = message.searchString 38 onMessageReceived: root.searchString = message.searchString
39 } 39 }
40 40
41 Kube.Listener {
42 filter: Kube.Messages.selectNextMessage
43 onMessageReceived: {
44 listView.incrementCurrentIndex()
45 listView.forceActiveFocus()
46 }
47 }
48
49 Kube.Listener {
50 filter: Kube.Messages.selectPreviousMessage
51 onMessageReceived: {
52 listView.decrementCurrentIndex()
53 listView.forceActiveFocus()
54 }
55 }
56
41 Rectangle { 57 Rectangle {
42 anchors.fill: parent 58 anchors.fill: parent
43 color: Kube.Colors.backgroundColor 59 color: Kube.Colors.backgroundColor
@@ -61,21 +77,9 @@ FocusScope {
61 } 77 }
62 78
63 Keys.onPressed: { 79 Keys.onPressed: {
64 if (event.text == "j" || event.matches(StandardKey.MoveToNextLine)) { 80 if (event.text == "d") {
65 listView.scrollDown() 81 //Not implemented as a shortcut because we want it only to apply if we have the focus
66 } else if (event.text == "J" || event.matches(StandardKey.MoveToNextPage)) { 82 Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": listView.currentItem.currentData.mail})
67 listView.incrementCurrentIndex()
68 } else if (event.text == "k" || event.matches(StandardKey.MoveToPreviousLine)) {
69 listView.scrollUp()
70 } else if (event.text == "K" || event.matches(StandardKey.MoveToPreviousPage)) {
71 listView.decrementCurrentIndex()
72 } else if (event.text == "n") {
73 Kube.Fabric.postMessage(Kube.Messages.nextConversation, {})
74 } else if (event.text == "p") {
75 Kube.Fabric.postMessage(Kube.Messages.previousConversation, {})
76 } else if (event.text == "d") {
77 //Not implemented as a shortcut because we want it only to apply if we have the focus
78 Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": listView.currentItem.currentData.mail})
79 } 83 }
80 } 84 }
81 85
diff --git a/framework/qml/FolderListView.qml b/framework/qml/FolderListView.qml
index 3a203083..221ec31c 100644
--- a/framework/qml/FolderListView.qml
+++ b/framework/qml/FolderListView.qml
@@ -27,6 +27,16 @@ Kube.TreeView {
27 id: root 27 id: root
28 property variant accountId 28 property variant accountId
29 29
30 Kube.Listener {
31 filter: Kube.Messages.selectNextFolder
32 onMessageReceived: root.selectNext()
33 }
34
35 Kube.Listener {
36 filter: Kube.Messages.selectPreviousFolder
37 onMessageReceived: root.selectPrevious()
38 }
39
30 Controls1.TableViewColumn { 40 Controls1.TableViewColumn {
31 title: "Name" 41 title: "Name"
32 role: "name" 42 role: "name"
diff --git a/framework/qml/ListView.qml b/framework/qml/ListView.qml
index 52942b65..3017e377 100644
--- a/framework/qml/ListView.qml
+++ b/framework/qml/ListView.qml
@@ -29,6 +29,14 @@ ListView {
29 clip: true 29 clip: true
30 ScrollBar.vertical: Kube.ScrollBar { id: scrollBar } 30 ScrollBar.vertical: Kube.ScrollBar { id: scrollBar }
31 31
32 Keys.onPressed: {
33 if (event.matches(StandardKey.MoveToNextLine)) {
34 incrementCurrentIndex()
35 } else if (event.matches(StandardKey.MoveToPreviousLine)) {
36 decrementCurrentIndex()
37 }
38 }
39
32 Kube.ScrollHelper { 40 Kube.ScrollHelper {
33 id: scrollHelper 41 id: scrollHelper
34 flickable: root 42 flickable: root
diff --git a/framework/qml/MailListView.qml b/framework/qml/MailListView.qml
index f5806d82..a8322f15 100644
--- a/framework/qml/MailListView.qml
+++ b/framework/qml/MailListView.qml
@@ -46,10 +46,20 @@ FocusScope {
46 find.forceActiveFocus() 46 find.forceActiveFocus()
47 } 47 }
48 48
49 Shortcut { 49 Kube.Listener {
50 sequences: [StandardKey.Delete] 50 filter: Kube.Messages.selectNextConversation
51 enabled: !isTrash 51 onMessageReceived: {
52 onActivated: Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail":currentMail}) 52 listView.incrementCurrentIndex()
53 listView.forceActiveFocus()
54 }
55 }
56
57 Kube.Listener {
58 filter: Kube.Messages.selectPreviousConversation
59 onMessageReceived: {
60 listView.decrementCurrentIndex()
61 listView.forceActiveFocus()
62 }
53 } 63 }
54 64
55 Kube.Label { 65 Kube.Label {
@@ -59,16 +69,6 @@ FocusScope {
59 text: qsTr("Nothing here...") 69 text: qsTr("Nothing here...")
60 } 70 }
61 71
62 Kube.Listener {
63 filter: Kube.Messages.nextConversation
64 onMessageReceived: listView.incrementCurrentIndex()
65 }
66
67 Kube.Listener {
68 filter: Kube.Messages.previousConversation
69 onMessageReceived: listView.decrementCurrentIndex()
70 }
71
72 ColumnLayout { 72 ColumnLayout {
73 anchors.fill: parent 73 anchors.fill: parent
74 74
@@ -123,7 +123,6 @@ FocusScope {
123 clip: true 123 clip: true
124 focus: true 124 focus: true
125 125
126 //BEGIN keyboard nav
127 onActiveFocusChanged: { 126 onActiveFocusChanged: {
128 if (activeFocus && currentIndex < 0) { 127 if (activeFocus && currentIndex < 0) {
129 currentIndex = 0 128 currentIndex = 0
@@ -131,18 +130,12 @@ FocusScope {
131 } 130 }
132 131
133 Keys.onPressed: { 132 Keys.onPressed: {
134 if (event.text == "j" || event.matches(StandardKey.MoveToNextLine)) { 133 if (event.text == "d") {
135 incrementCurrentIndex()
136 } else if (event.text == "k" || event.matches(StandardKey.MoveToPreviousLine)) {
137 decrementCurrentIndex()
138 } else if (event.text == "d") {
139 //Not implemented as a shortcut because we want it only to apply if we have the focus 134 //Not implemented as a shortcut because we want it only to apply if we have the focus
140 Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": root.currentMail}) 135 Kube.Fabric.postMessage(Kube.Messages.moveToTrash, {"mail": root.currentMail})
141 } 136 }
142 } 137 }
143 138
144 //END keyboard nav
145
146 onCurrentItemChanged: { 139 onCurrentItemChanged: {
147 if (currentItem) { 140 if (currentItem) {
148 var currentData = currentItem.currentData; 141 var currentData = currentItem.currentData;
diff --git a/framework/qml/Messages.qml b/framework/qml/Messages.qml
index a3f6ef00..630d05ab 100644
--- a/framework/qml/Messages.qml
+++ b/framework/qml/Messages.qml
@@ -52,7 +52,11 @@ Item {
52 52
53 property string componentDone: "done" 53 property string componentDone: "done"
54 54
55 property string nextConversation: "nextConversation" 55 property string selectNextConversation: "selectNextConversation"
56 property string previousConversation: "previousConversation" 56 property string selectPreviousConversation: "selectPreviousConversation"
57 property string selectNextMessage: "selectNextMessage"
58 property string selectPreviousMessage: "selectPreviousMessage"
59 property string selectNextFolder: "selectNextFolder"
60 property string selectPreviousFolder: "selectPreviousFolder"
57} 61}
58 62
diff --git a/framework/qml/TreeView.qml b/framework/qml/TreeView.qml
index 21345fb0..d7fed711 100644
--- a/framework/qml/TreeView.qml
+++ b/framework/qml/TreeView.qml
@@ -46,6 +46,18 @@ FocusScope {
46 return treeView.__model.mapRowToModelIndex(row) 46 return treeView.__model.mapRowToModelIndex(row)
47 } 47 }
48 48
49 function selectNext() {
50 treeView.__listView.incrementCurrentIndexBlocking()
51 treeView.__mouseArea.keySelect(Qt.NoModifier)
52 activated(treeView.selection.currentIndex)
53 }
54
55 function selectPrevious() {
56 treeView.__listView.decrementCurrentIndexBlocking()
57 treeView.__mouseArea.keySelect(Qt.NoModifier)
58 activated(treeView.selection.currentIndex)
59 }
60
49 Flickable { 61 Flickable {
50 id: flickableItem 62 id: flickableItem
51 63