on xenial help sign in
Start searching directly as you type, w/o having to first focus/click the search field.

Approved by: Michael Zanetti, Unity8 CI Bot

commite14a31e5db2e27f003a0fed2f77bad866094b4b4 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateTue 24 Jan 2017, 07:42 (10 years ago) parent64d94a3803b594
4 files changed+31−8
qml/Launcher/Drawer.qml+9 qml/Launcher/Launcher.qml+4−1 tests/mocks/Unity/Launcher/MockAppDrawerModel.cpp−1 tests/qmltests/Launcher/tst_Drawer.qml+18−6
qml/Launcher/Drawer.qml+9
@@ -43,6 +43,14 @@ FocusScope {
4343 searchField.focus = true;
4444 }
4545
46+ Keys.onPressed: {
47+ if (event.text.trim() !== "") {
48+ focusInput();
49+ searchField.text = event.text;
50+ event.accepted = true;
51+ }
52+ }
53+
4654 Settings {
4755 property alias selectedTab: sections.selectedIndex
4856 }
@@ -76,6 +84,7 @@ FocusScope {
7684
7785 TextField {
7886 id: searchField
87+ objectName: "searchField"
7988 anchors { left: parent.left; top: parent.top; right: parent.right; margins: units.gu(1) }
8089 placeholderText: i18n.tr("Search…")
8190 focus: true
qml/Launcher/Launcher.qml+4−1
@@ -74,7 +74,7 @@ FocusScope {
7474 } else {
7575 superPressTimer.stop();
7676 superLongPressTimer.stop();
77− launcher.switchToNextState("");
77+ switchToNextState("");
7878 panel.shortcutHintsShown = false;
7979 }
8080 }
@@ -474,6 +474,8 @@ FocusScope {
474474 onPassed: {
475475 if (root.drawerEnabled) {
476476 root.switchToNextState("drawer");
477+ root.focus = true;
478+ drawer.focus = true;
477479 }
478480 }
479481
@@ -551,6 +553,7 @@ FocusScope {
551553 if (root.drawerEnabled && distance > panel.width * 3 && dragDirection() !== "left") {
552554 root.switchToNextState("drawer");
553555 root.focus = true;
556+ drawer.focus = true;
554557 } else {
555558 root.switchToNextState("visible");
556559 }
tests/mocks/Unity/Launcher/MockAppDrawerModel.cpp−1
@@ -48,7 +48,6 @@ MockAppDrawerModel::MockAppDrawerModel(QObject *parent):
4848 m_list.append(item);
4949 item = new MockLauncherItem("libreoffice", "/usr/share/applications/libreoffice.desktop","Libre Office", "libreoffice", this);
5050 m_list.append(item);
51− qDebug() << "mock model created";
5251
5352 qsrand(QDateTime::currentMSecsSinceEpoch() / 1000);
5453}
tests/qmltests/Launcher/tst_Drawer.qml+18−6
@@ -26,6 +26,7 @@ import Unity.Test 0.1
2626StyledItem {
2727 id: root
2828 theme.name: "Ubuntu.Components.Themes.SuruDark"
29+ focus: true
2930
3031 width: units.gu(140)
3132 height: units.gu(70)
@@ -108,6 +109,7 @@ StyledItem {
108109 tryCompareFunction( function(){ return drawer.x === 0; }, true );
109110 tryCompare(launcher, "state", "drawer");
110111 tryCompare(launcher, "drawerShown", true);
112+ return drawer;
111113 }
112114
113115 function revealByEdgePush() {
@@ -168,11 +170,9 @@ StyledItem {
168170 function test_hideByDraggingDrawer(data) {
169171 launcher.lockedVisible = !data.autohide;
170172
171− dragDrawerIntoView();
173+ var drawer = dragDrawerIntoView();
172174 waitForRendering(launcher);
173175
174− var drawer = findChild(launcher, "drawer");
175−
176176 mouseFlick(root, drawer.width - units.gu(1), drawer.height / 2, units.gu(2), drawer.height / 2, true, true);
177177
178178 tryCompare(drawer.anchors, "rightMargin", 0);
@@ -181,9 +181,7 @@ StyledItem {
181181 }
182182
183183 function test_hideByClickingOutside() {
184− dragDrawerIntoView();
185−
186− var drawer = findChild(launcher, "drawer");
184+ var drawer = dragDrawerIntoView();
187185
188186 mouseClick(root, drawer.width + units.gu(1), root.height / 2);
189187
@@ -240,6 +238,8 @@ StyledItem {
240238 keyClick(Qt.Key_Enter);
241239
242240 compare(launcher.lastSelectedApplication, "camera-app");
241+ waitForRendering(launcher);
242+ tryCompare(launcher, "drawerShown", false);
243243 }
244244
245245 function test_dragDirectionOnLeftEdgeDrag_data() {
@@ -260,5 +260,17 @@ StyledItem {
260260
261261 tryCompare(launcher, "state", data.endState)
262262 }
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+ }
263275 }
264276}