Changeset View
Changeset View
Standalone View
Standalone View
lib/qml/ResultsView.qml
Show All 35 Lines | 29 | ListView { | |||
---|---|---|---|---|---|
36 | signal activated | 36 | signal activated | ||
37 | signal updateQueryString(string text, int cursorPosition) | 37 | signal updateQueryString(string text, int cursorPosition) | ||
38 | 38 | | |||
39 | // NOTE this also flips increment/decrementCurrentIndex (Bug 360789) | 39 | // NOTE this also flips increment/decrementCurrentIndex (Bug 360789) | ||
40 | verticalLayoutDirection: reversed ? ListView.BottomToTop : ListView.TopToBottom | 40 | verticalLayoutDirection: reversed ? ListView.BottomToTop : ListView.TopToBottom | ||
41 | keyNavigationWraps: true | 41 | keyNavigationWraps: true | ||
42 | highlight: PlasmaComponents.Highlight {} | 42 | highlight: PlasmaComponents.Highlight {} | ||
43 | highlightMoveDuration: 0 | 43 | highlightMoveDuration: 0 | ||
44 | activeFocusOnTab: true | ||||
44 | 45 | | |||
45 | section { | 46 | section { | ||
46 | criteria: ViewSection.FullString | 47 | criteria: ViewSection.FullString | ||
47 | property: "type" | 48 | property: "type" | ||
48 | } | 49 | } | ||
49 | 50 | | |||
50 | // This is used to keep track if the user has pressed enter before | 51 | // This is used to keep track if the user has pressed enter before | ||
51 | // the first result has been shown, in the case the first result should | 52 | // the first result has been shown, in the case the first result should | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | |||||
121 | } | 122 | } | ||
122 | 123 | | |||
123 | function runAction(index) { | 124 | function runAction(index) { | ||
124 | if (resultModel.runAction(currentIndex, index)) { | 125 | if (resultModel.runAction(currentIndex, index)) { | ||
125 | activated() | 126 | activated() | ||
126 | } | 127 | } | ||
127 | } | 128 | } | ||
128 | 129 | | |||
130 | onActiveFocusChanged: { | ||||
131 | if (activeFocus && currentIndex == listView.count-1) { | ||||
132 | currentIndex = 0; | ||||
133 | } | ||||
134 | } | ||||
135 | | ||||
129 | Keys.onTabPressed: { | 136 | Keys.onTabPressed: { | ||
130 | if (!currentItem || !currentItem.activateNextAction()) { | 137 | if (!currentItem || !currentItem.activateNextAction()) { | ||
131 | if (reversed) { | 138 | if (reversed) { | ||
139 | if (currentIndex == 0) { | ||||
140 | listView.nextItemInFocusChain(false).forceActiveFocus(); | ||||
broulik: Can we perhaps bind the "isCurrentItem" to activeFocus instead of doing this in addition to… | |||||
mart: will give a try | |||||
what i'm trying to do here is to focus the next item when cycling items with tabs arrives to the last item, so yeah, it's a bit hacky but works mart: what i'm trying to do here is to focus the next item when cycling items with tabs arrives to… | |||||
141 | return; | ||||
142 | } | ||||
132 | decrementCurrentIndex() | 143 | decrementCurrentIndex() | ||
133 | } else { | 144 | } else { | ||
145 | if (currentIndex == listView.count-1) { | ||||
146 | listView.nextItemInFocusChain(true).forceActiveFocus(); | ||||
147 | return; | ||||
148 | } | ||||
134 | incrementCurrentIndex() | 149 | incrementCurrentIndex() | ||
135 | } | 150 | } | ||
136 | } | 151 | } | ||
137 | } | 152 | } | ||
138 | Keys.onBacktabPressed: { | 153 | Keys.onBacktabPressed: { | ||
139 | if (!currentItem || !currentItem.activatePreviousAction()) { | 154 | if (!currentItem || !currentItem.activatePreviousAction()) { | ||
140 | if (reversed) { | 155 | if (reversed) { | ||
156 | if (currentIndex == listView.count-1) { | ||||
157 | listView.nextItemInFocusChain(true).forceActiveFocus(); | ||||
158 | return; | ||||
159 | } | ||||
141 | incrementCurrentIndex() | 160 | incrementCurrentIndex() | ||
142 | } else { | 161 | } else { | ||
162 | if (currentIndex == 0) { | ||||
163 | listView.nextItemInFocusChain(false).forceActiveFocus(); | ||||
164 | return; | ||||
165 | } | ||||
143 | decrementCurrentIndex() | 166 | decrementCurrentIndex() | ||
144 | } | 167 | } | ||
145 | 168 | | |||
146 | // activate previous action cannot know whether we want to back tab from an action | 169 | // activate previous action cannot know whether we want to back tab from an action | ||
147 | // to the main result or back tab from another search result, so we explicitly highlight | 170 | // to the main result or back tab from another search result, so we explicitly highlight | ||
148 | // the last action here to provide a consistent navigation experience | 171 | // the last action here to provide a consistent navigation experience | ||
149 | if (currentItem) { | 172 | if (currentItem) { | ||
150 | currentItem.activateLastAction() | 173 | currentItem.activateLastAction() | ||
Show All 17 Lines |
Can we perhaps bind the "isCurrentItem" to activeFocus instead of doing this in addition to incrementing/decrementing the index?