@@ -20,6 +20,7 @@ import Unity.Launcher 0.1
20import Utils 0.1
20import Utils 0.1
21import "../Components"
21import "../Components"
22import Qt.labs.settings 1.0
22import Qt.labs.settings 1.0
24FocusScope {
25FocusScope {
@@ -43,6 +44,16 @@ FocusScope {
43 searchField.focus = true;
44 searchField.focus = true;
48+ if (event.text.trim() !== "") {
50+ searchField.text = event.text;
52+ // Catch all presses here in case the navigation lets something through
53+ // We never want to end up in the launcher with focus
54+ event.accepted = true;
46 Settings {
57 Settings {
47 property alias selectedTab: sections.selectedIndex
58 property alias selectedTab: sections.selectedIndex
@@ -76,9 +87,13 @@ FocusScope {
77 TextField {
88 TextField {
78 id: searchField
89 id: searchField
90+ objectName: "searchField"
79 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
91 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
80 placeholderText: i18n.tr("Search…")
92 placeholderText: i18n.tr("Search…")
81 focus: true
93 focus: true
95+ KeyNavigation.down: sections
82 onAccepted: {
97 onAccepted: {
83 if (searchField.displayText != "" && listLoader.item && listLoader.item.currentItem) {
98 if (searchField.displayText != "" && listLoader.item && listLoader.item.currentItem) {
84 root.applicationSelected(listLoader.item.getFirstAppId());
99 root.applicationSelected(listLoader.item.getFirstAppId());
@@ -95,14 +110,21 @@ FocusScope {
96 Sections {
111 Sections {
97 id: sections
112 id: sections
113+ objectName: "drawerSections"
98 width: parent.width
114 width: parent.width
116+ KeyNavigation.up: searchField
117+ KeyNavigation.down: headerFocusScope
118+ KeyNavigation.backtab: searchField
119+ KeyNavigation.tab: headerFocusScope
99 actions: [
121 actions: [
101 text: i18n.ctr("Apps sorted alphabetically", "A-Z")
123 text: i18n.ctr("Apps sorted alphabetically", "A-Z")
102 // TODO: Disabling this for now as we don't get the right input from u-a-l yet.
124 // TODO: Disabling this for now as we don't get the right input from u-a-l yet.
104−// Action {
126+ Action {
105−// text: i18n.ctr("Most used apps", "Most used")
127+ text: i18n.ctr("Most used apps", "Most used")
@@ -115,9 +137,45 @@ FocusScope {
141+ id: headerFocusScope
142+ objectName: "headerFocusScope"
143+ KeyNavigation.up: sections
144+ KeyNavigation.down: listLoader.item
145+ KeyNavigation.backtab: sections
146+ KeyNavigation.tab: listLoader.item
147+ activeFocusOnTab: true
151+ schema.id: "com.canonical.Unity8"
155+ switch (event.key) {
160+ event.accepted = true;
164+ function trigger() {
165+ Qt.openUrlExternally(settings.appstoreUri)
119 id: listLoader
170 id: listLoader
171+ objectName: "drawerListLoader"
120 anchors { left: parent.left; top: sectionsContainer.bottom; right: parent.right; bottom: parent.bottom; leftMargin: units.gu(1); rightMargin: units.gu(1) }
172 anchors { left: parent.left; top: sectionsContainer.bottom; right: parent.right; bottom: parent.bottom; leftMargin: units.gu(1); rightMargin: units.gu(1) }
174+ KeyNavigation.up: headerFocusScope
175+ KeyNavigation.down: searchField
176+ KeyNavigation.backtab: headerFocusScope
177+ KeyNavigation.tab: searchField
121 sourceComponent: {
179 sourceComponent: {
122 switch (sections.selectedIndex) {
180 switch (sections.selectedIndex) {
123 case 0: return aToZComponent;
181 case 0: return aToZComponent;
@@ -167,10 +225,13 @@ FocusScope {
167 Component {
225 Component {
168 id: mostUsedComponent
226 id: mostUsedComponent
169 DrawerListView {
227 DrawerListView {
228+ id: mostUsedListView
171 header: MoreAppsHeader {
230 header: MoreAppsHeader {
172 width: parent.width
231 width: parent.width
173 height: units.gu(6)
232 height: units.gu(6)
233+ highlighted: headerFocusScope.activeFocus
234+ onClicked: headerFocusScope.trigger();
176 model: AppDrawerProxyModel {
237 model: AppDrawerProxyModel {
@@ -196,6 +257,9 @@ FocusScope {
196 bottomMargin: units.gu(1)
257 bottomMargin: units.gu(1)
197 clip: true
258 clip: true
261+ focus: index == mostUsedListView.currentIndex
199 model: sortProxyModel
263 model: sortProxyModel
201 delegateWidth: units.gu(8)
265 delegateWidth: units.gu(8)
@@ -209,10 +273,13 @@ FocusScope {
209 Component {
273 Component {
210 id: aToZComponent
274 id: aToZComponent
211 DrawerListView {
275 DrawerListView {
213 header: MoreAppsHeader {
278 header: MoreAppsHeader {
214 width: parent.width
279 width: parent.width
215 height: units.gu(6)
280 height: units.gu(6)
281+ highlighted: headerFocusScope.activeFocus
282+ onClicked: headerFocusScope.trigger();
218 model: AppDrawerProxyModel {
285 model: AppDrawerProxyModel {
@@ -244,7 +311,11 @@ FocusScope {
244 anchors { left: parent.left; top: categoryNameLabel.bottom; right: parent.right; topMargin: units.gu(1) }
311 anchors { left: parent.left; top: categoryNameLabel.bottom; right: parent.right; topMargin: units.gu(1) }
245 height: rows * delegateHeight
312 height: rows * delegateHeight
247− interactive: false
314+ interactive: true
315+ focus: index == aToZListView.currentIndex
316+ onFocusChanged: print("drawer grid", index, "has focus", focus)
318+ onCurrentIndexChanged: print("grid currentIndex changed", currentIndex)
249 model: AppDrawerProxyModel {
320 model: AppDrawerProxyModel {
250 id: categoryModel
321 id: categoryModel
@@ -263,10 +334,13 @@ FocusScope {
263 Component {
334 Component {
264 id: drawerDelegateComponent
335 id: drawerDelegateComponent
265 AbstractButton {
336 AbstractButton {
266 width: GridView.view.cellWidth
338 width: GridView.view.cellWidth
267 height: units.gu(10)
339 height: units.gu(10)
268 objectName: "drawerItem_" + model.appId
340 objectName: "drawerItem_" + model.appId
342+ readonly property bool focused: index === GridView.view.currentIndex && GridView.view.activeFocus
270 onClicked: root.applicationSelected(model.appId)
344 onClicked: root.applicationSelected(model.appId)
@@ -290,6 +364,17 @@ FocusScope {
290 source: model.icon
364 source: model.icon
292 sourceFillMode: UbuntuShape.PreserveAspectCrop
366 sourceFillMode: UbuntuShape.PreserveAspectCrop
369+ objectName: "focusRing"
370+ anchors.centerIn: parent
371+ height: width * 15 / 16
372+ width: parent.width + units.gu(1)
373+ source: "graphics/launcher-app-focus-ring.svg"
374+ sourceSize.width: width
375+ sourceSize.height: height
376+ visible: drawerDelegate.focused