summaryrefslogtreecommitdiff
blob: 75b5bc27b2ae6817403ebd6065c5c8506d468597 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From 1692ae244bc5229df78df2d5ba2e76418362cb50 Mon Sep 17 00:00:00 2001
From: Eike Hein <hein@kde.org>
Date: Wed, 5 Sep 2018 18:58:35 +0900
Subject: Improve arrow key navigation of Kicker search results

Summary:
Kicker already makes sure the first search result is highlighted
and actionable while searching. This patch makes arrow-down after
typing move to the second search result instead of merely moving
focus from the search field to the list, so the user doesn't have
to press arrow-down twice anymore.

It also allows using arrow-left/right to jump to the other result
columns, when the cursor is at the start or end of the text field,
respectively.

BUG:397779

Reviewers: ngraham

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D15286
---
 .../package/contents/ui/MenuRepresentation.qml       | 20 +++++++++++++++++++-
 .../kicker/package/contents/ui/RunnerResultsList.qml |  1 +
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/applets/kicker/package/contents/ui/MenuRepresentation.qml b/applets/kicker/package/contents/ui/MenuRepresentation.qml
index b70b76b..58cbf8d 100644
--- a/applets/kicker/package/contents/ui/MenuRepresentation.qml
+++ b/applets/kicker/package/contents/ui/MenuRepresentation.qml
@@ -393,7 +393,7 @@ FocusScope {
             } else if (event.key == Qt.Key_Down) {
                 if (rootList.visible) {
                     rootList.showChildDialogs = false;
-                    rootList.currentIndex = 0;
+                    rootList.currentIndex = Math.min(1, rootList.count);
                     rootList.forceActiveFocus();
                     rootList.showChildDialogs = true;
                 }
@@ -402,11 +402,29 @@ FocusScope {
                     for (var i = 0; i < runnerModel.count; ++i) {
                         if (runnerModel.modelForRow(i).count) {
                             var targetList = runnerColumnsRepeater.itemAt(i);
+                            targetList.currentIndex = Math.min(1, targetList.count);
+                            targetList.forceActiveFocus();
+                            break;
+                        }
+                    }
+                }
+            } else if (event.key == Qt.Key_Left && cursorPosition == 0) {
+                    for (var i = runnerModel.count; i >= 0; --i) {
+                        if (runnerModel.modelForRow(i).count) {
+                            var targetList = runnerColumnsRepeater.itemAt(i);
                             targetList.currentIndex = 0;
                             targetList.forceActiveFocus();
                             break;
                         }
                     }
+            } else if (event.key == Qt.Key_Right && cursorPosition == length) {
+                for (var i = 1; i < runnerModel.count; ++i) {
+                    if (runnerModel.modelForRow(i).count) {
+                        var targetList = runnerColumnsRepeater.itemAt(i);
+                        targetList.currentIndex = 0;
+                        targetList.forceActiveFocus();
+                        break;
+                    }
                 }
             } else if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return) {
                 if (runnerColumns.visible && runnerModel.modelForRow(0).count) {
diff --git a/applets/kicker/package/contents/ui/RunnerResultsList.qml b/applets/kicker/package/contents/ui/RunnerResultsList.qml
index 3627c2f..4e6dc2f 100644
--- a/applets/kicker/package/contents/ui/RunnerResultsList.qml
+++ b/applets/kicker/package/contents/ui/RunnerResultsList.qml
@@ -30,6 +30,7 @@ FocusScope {
     signal keyNavigationAtListEnd
 
     property alias currentIndex: runnerMatches.currentIndex
+    property alias count: runnerMatches.count
     property alias containsMouse: runnerMatches.containsMouse
 
     Accessible.name: header.text
-- 
cgit v0.11.2