on xenial help sign in
Start searching directly as you type, w/o having to first focus/click the search field.
e14a31eLukáš Tinkl
qml/Launcher/Drawer.qml+9
@@ -43,6 +43,14 @@ FocusScope {
43 searchField.focus = true;
43 searchField.focus = true;
44 }
44 }
45
45
46+ Keys.onPressed: {
47+ if (event.text.trim() !== "") {
48+ focusInput();
49+ searchField.text = event.text;
50+ event.accepted = true;
51+ }
52+ }
53+
46 Settings {
54 Settings {
47 property alias selectedTab: sections.selectedIndex
55 property alias selectedTab: sections.selectedIndex
48 }
56 }
@@ -76,6 +84,7 @@ FocusScope {
76
84
77 TextField {
85 TextField {
78 id: searchField
86 id: searchField
87+ objectName: "searchField"
79 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
88 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
80 placeholderText: i18n.tr("Search…")
89 placeholderText: i18n.tr("Search…")
81 focus: true
90 focus: true
qml/Launcher/Launcher.qml+4−1
@@ -74,7 +74,7 @@ FocusScope {
74 } else {
74 } else {
75 superPressTimer.stop();
75 superPressTimer.stop();
76 superLongPressTimer.stop();
76 superLongPressTimer.stop();
77− launcher.switchToNextState("");
77+ switchToNextState("");
78 panel.shortcutHintsShown = false;
78 panel.shortcutHintsShown = false;
79 }
79 }
80 }
80 }
@@ -474,6 +474,8 @@ FocusScope {
474 onPassed: {
474 onPassed: {
475 if (root.drawerEnabled) {
475 if (root.drawerEnabled) {
476 root.switchToNextState("drawer");
476 root.switchToNextState("drawer");
477+ root.focus = true;
478+ drawer.focus = true;
477 }
479 }
478 }
480 }
479
481
@@ -551,6 +553,7 @@ FocusScope {
551 if (root.drawerEnabled && distance > panel.width * 3 && dragDirection() !== "left") {
553 if (root.drawerEnabled && distance > panel.width * 3 && dragDirection() !== "left") {
552 root.switchToNextState("drawer");
554 root.switchToNextState("drawer");
553 root.focus = true;
555 root.focus = true;
556+ drawer.focus = true;
554 } else {
557 } else {
555 root.switchToNextState("visible");
558 root.switchToNextState("visible");
556 }
559 }
tests/mocks/Unity/Launcher/MockAppDrawerModel.cpp−1
@@ -48,7 +48,6 @@ MockAppDrawerModel::MockAppDrawerModel(QObject *parent):
48 m_list.append(item);
48 m_list.append(item);
49 item = new MockLauncherItem("libreoffice", "/usr/share/applications/libreoffice.desktop","Libre Office", "libreoffice", this);
49 item = new MockLauncherItem("libreoffice", "/usr/share/applications/libreoffice.desktop","Libre Office", "libreoffice", this);
50 m_list.append(item);
50 m_list.append(item);
51− qDebug() << "mock model created";
52
51
53 qsrand(QDateTime::currentMSecsSinceEpoch() / 1000);
52 qsrand(QDateTime::currentMSecsSinceEpoch() / 1000);
54}
53}
tests/qmltests/Launcher/tst_Drawer.qml+18−6
@@ -26,6 +26,7 @@ import Unity.Test 0.1
26StyledItem {
26StyledItem {
27 id: root
27 id: root
28 theme.name: "Ubuntu.Components.Themes.SuruDark"
28 theme.name: "Ubuntu.Components.Themes.SuruDark"
29+ focus: true
29
30
30 width: units.gu(140)
31 width: units.gu(140)
31 height: units.gu(70)
32 height: units.gu(70)
@@ -108,6 +109,7 @@ StyledItem {
108 tryCompareFunction( function(){ return drawer.x === 0; }, true );
109 tryCompareFunction( function(){ return drawer.x === 0; }, true );
109 tryCompare(launcher, "state", "drawer");
110 tryCompare(launcher, "state", "drawer");
110 tryCompare(launcher, "drawerShown", true);
111 tryCompare(launcher, "drawerShown", true);
112+ return drawer;
111 }
113 }
112
114
113 function revealByEdgePush() {
115 function revealByEdgePush() {
@@ -168,11 +170,9 @@ StyledItem {
168 function test_hideByDraggingDrawer(data) {
170 function test_hideByDraggingDrawer(data) {
169 launcher.lockedVisible = !data.autohide;
171 launcher.lockedVisible = !data.autohide;
170
172
171− dragDrawerIntoView();
173+ var drawer = dragDrawerIntoView();
172 waitForRendering(launcher);
174 waitForRendering(launcher);
173
175
174− var drawer = findChild(launcher, "drawer");
175−
176 mouseFlick(root, drawer.width - units.gu(1), drawer.height / 2, units.gu(2), drawer.height / 2, true, true);
176 mouseFlick(root, drawer.width - units.gu(1), drawer.height / 2, units.gu(2), drawer.height / 2, true, true);
177
177
178 tryCompare(drawer.anchors, "rightMargin", 0);
178 tryCompare(drawer.anchors, "rightMargin", 0);
@@ -181,9 +181,7 @@ StyledItem {
181 }
181 }
182
182
183 function test_hideByClickingOutside() {
183 function test_hideByClickingOutside() {
184− dragDrawerIntoView();
184+ var drawer = dragDrawerIntoView();
185−
186− var drawer = findChild(launcher, "drawer");
187
185
188 mouseClick(root, drawer.width + units.gu(1), root.height / 2);
186 mouseClick(root, drawer.width + units.gu(1), root.height / 2);
189
187
@@ -240,6 +238,8 @@ StyledItem {
240 keyClick(Qt.Key_Enter);
238 keyClick(Qt.Key_Enter);
241
239
242 compare(launcher.lastSelectedApplication, "camera-app");
240 compare(launcher.lastSelectedApplication, "camera-app");
241+ waitForRendering(launcher);
242+ tryCompare(launcher, "drawerShown", false);
243 }
243 }
244
244
245 function test_dragDirectionOnLeftEdgeDrag_data() {
245 function test_dragDirectionOnLeftEdgeDrag_data() {
@@ -260,5 +260,17 @@ StyledItem {
260
260
261 tryCompare(launcher, "state", data.endState)
261 tryCompare(launcher, "state", data.endState)
262 }
262 }
263+
264+ function test_searchDirectly() {
265+ var drawer = dragDrawerIntoView();
266+ waitForRendering(drawer);
267+ waitUntilTransitionsEnd(drawer);
268+ tryCompare(drawer, "focus", true);
269+
270+ var searchField = findChild(drawer, "searchField");
271+ tryCompareFunction(function() { return !!searchField }, true);
272+ typeString("cam");
273+ tryCompareFunction(function() { return searchField.displayText }, "cam");
274+ }
263 }
275 }
264}
276}