diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-04-06 16:45:04 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-04-06 16:45:04 +0200 |
commit | a301d1db33fdecb0e66495b51019922a9b040c1f (patch) | |
tree | daa93751bcfd171b79d116d74f707e88175e0733 | |
parent | 72a9eeb01cdfd4f0ee5dbffcd3fe083897d8a390 (diff) | |
download | kube-a301d1db33fdecb0e66495b51019922a9b040c1f.tar.gz kube-a301d1db33fdecb0e66495b51019922a9b040c1f.zip |
Conversation view keyboard navigation
-rw-r--r-- | framework/qml/ConversationListView.qml | 16 | ||||
-rw-r--r-- | framework/qml/ConversationView.qml | 36 | ||||
-rw-r--r-- | framework/qml/FolderListView.qml | 10 | ||||
-rw-r--r-- | framework/qml/ListView.qml | 8 | ||||
-rw-r--r-- | framework/qml/MailListView.qml | 37 | ||||
-rw-r--r-- | framework/qml/Messages.qml | 8 | ||||
-rw-r--r-- | framework/qml/TreeView.qml | 12 | ||||
-rw-r--r-- | views/conversation/qml/View.qml | 33 |
8 files changed, 111 insertions, 49 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 | ||
20 | import QtQuick 2.7 | 20 | import QtQuick 2.9 |
21 | import QtQuick.Controls 2 | 21 | import QtQuick.Controls 2 |
22 | import QtQuick.Layouts 1.1 | 22 | import QtQuick.Layouts 1.1 |
23 | import org.kube.framework 1.0 as Kube | 23 | import 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 | ||
diff --git a/views/conversation/qml/View.qml b/views/conversation/qml/View.qml index c1f3625b..c965b4c7 100644 --- a/views/conversation/qml/View.qml +++ b/views/conversation/qml/View.qml | |||
@@ -18,7 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | 20 | ||
21 | import QtQuick 2.7 | 21 | import QtQuick 2.9 |
22 | import QtQuick.Controls 1.3 as Controls1 | 22 | import QtQuick.Controls 1.3 as Controls1 |
23 | import QtQuick.Controls 2.0 as Controls2 | 23 | import QtQuick.Controls 2.0 as Controls2 |
24 | import QtQuick.Layouts 1.1 | 24 | import QtQuick.Layouts 1.1 |
@@ -27,6 +27,37 @@ import org.kube.framework 1.0 as Kube | |||
27 | 27 | ||
28 | FocusScope { | 28 | FocusScope { |
29 | property alias currentAccount: accountFolderview.currentAccount | 29 | property alias currentAccount: accountFolderview.currentAccount |
30 | |||
31 | Shortcut { | ||
32 | sequences: ['j'] | ||
33 | onActivated: Kube.Fabric.postMessage(Kube.Messages.selectNextConversation, {}) | ||
34 | } | ||
35 | Shortcut { | ||
36 | sequences: ['k'] | ||
37 | onActivated: Kube.Fabric.postMessage(Kube.Messages.selectPreviousConversation, {}) | ||
38 | } | ||
39 | Shortcut { | ||
40 | sequences: ['n'] | ||
41 | onActivated: Kube.Fabric.postMessage(Kube.Messages.selectNextMessage, {}) | ||
42 | } | ||
43 | Shortcut { | ||
44 | sequences: ['p'] | ||
45 | onActivated: Kube.Fabric.postMessage(Kube.Messages.selectPreviousMessage, {}) | ||
46 | } | ||
47 | Shortcut { | ||
48 | sequences: ['f,n'] | ||
49 | onActivated: Kube.Fabric.postMessage(Kube.Messages.selectNextFolder, {}) | ||
50 | } | ||
51 | Shortcut { | ||
52 | sequences: ['f,p'] | ||
53 | onActivated: Kube.Fabric.postMessage(Kube.Messages.selectPreviousFolder, {}) | ||
54 | } | ||
55 | Shortcut { | ||
56 | sequences: ['c'] | ||
57 | onActivated: Kube.Fabric.postMessage(Kube.Messages.compose, {}) | ||
58 | } | ||
59 | |||
60 | |||
30 | Controls1.SplitView { | 61 | Controls1.SplitView { |
31 | anchors.fill: parent | 62 | anchors.fill: parent |
32 | Rectangle { | 63 | Rectangle { |