diff --git a/qt/qml/Main.qml b/qt/qml/Main.qml index dc9b46c..372120e 100644 --- a/qt/qml/Main.qml +++ b/qt/qml/Main.qml @@ -57,7 +57,9 @@ Window { readonly property real colW: (gridW - (cols - 1) * L.CGAP) / cols readonly property real panelY: insetTop + 16 readonly property real panelH: 54 - readonly property real gridTop: panelY + panelH + 16 // in home content coordinates + readonly property real searchY: panelY + panelH + 10 // the home search pill, under the panel + readonly property real searchH: 44 + readonly property real gridTop: searchY + searchH + 16 // in home content coordinates readonly property real gridBottom: height - (insetBottom + 24) readonly property int nrows: home.length > 0 ? Math.max(1, Math.floor((gridBottom - gridTop + L.RGAP) / (L.CELL + L.RGAP))) : 0 @@ -499,6 +501,43 @@ Window { } } + // The search pill under the panel: a tap opens the drawer, where its + // search takes focus and the keyboard (Drawer.onOpenChanged). + Rectangle { + id: searchPill + objectName: "homeSearch" + property bool pressed: false + width: panel.width + height: root.searchH + x: panel.x + y: root.searchY + radius: height / 2 + color: pressed ? Qt.rgba(1, 1, 1, .18) : Qt.rgba(1, 1, 1, .1) + border.color: Qt.rgba(1, 1, 1, .15) + border.width: 1 + Row { + x: 18 + anchors.verticalCenter: parent.verticalCenter + spacing: 10 + Item { // a magnifier, drawn: phone fonts may have no search glyph + width: 16; height: 16 + anchors.verticalCenter: parent.verticalCenter + Rectangle { x: 0; y: 0; width: 11; height: 11; radius: 5.5; color: "transparent" + border.color: Qt.rgba(1, 1, 1, .75); border.width: 2; antialiasing: true } + Rectangle { x: 8; y: 11; width: 7; height: 2; radius: 1; rotation: 45 + color: Qt.rgba(1, 1, 1, .75); antialiasing: true } + } + Text { + text: "Search apps" + color: Qt.rgba(1, 1, 1, .6) + font.pixelSize: 16 + style: Text.Raised + styleColor: Qt.rgba(0, 0, 0, .35) + anchors.verticalCenter: parent.verticalCenter + } + } + } + // The home grid. Item { id: grid @@ -610,6 +649,10 @@ Window { const p = windowsBtn.mapFromItem(touch, x, y); return p.x >= 0 && p.y >= 0 && p.x <= windowsBtn.width && p.y <= windowsBtn.height; } + function onSearch(x, y) { + const p = searchPill.mapFromItem(touch, x, y); + return p.x >= 0 && p.y >= 0 && p.x <= searchPill.width && p.y <= searchPill.height; + } onPressed: (m) => { const g = root.toGrid(m.x, m.y); @@ -618,6 +661,7 @@ Window { longFired = false; dragged = false; windowsBtn.pressed = onPanel(m.x, m.y); + searchPill.pressed = onSearch(m.x, m.y); if (root.resizing >= 0 && pressedSlot === root.resizing) { // A widget showing handles is moved by its body, no long press needed. root.grab(pressedSlot); @@ -629,13 +673,14 @@ Window { onPositionChanged: (m) => { if (!start) return; if (!start.moved && Math.hypot(m.x - start.x, m.y - start.y) < 10) return; - if (!start.moved) { start.moved = true; hold.stop(); windowsBtn.pressed = false; } + if (!start.moved) { start.moved = true; hold.stop(); windowsBtn.pressed = false; searchPill.pressed = false; } if (root.lifted >= 0) { dragged = true; root.dragTo(m.x, m.y, start.x, start.y); return; } if (!longFired) root.scrollY = Math.max(0, Math.min(root.maxScroll, start.scroll - (m.y - start.y))); } onReleased: (m) => { hold.stop(); windowsBtn.pressed = false; + searchPill.pressed = false; const s = start; start = null; if (!s) return; @@ -644,6 +689,7 @@ Window { if (!s.moved) { const i = pressedSlot; if (onPanel(m.x, m.y)) { Host.openRecents(); root.resizing = -1; } + else if (onSearch(m.x, m.y)) { root.resizing = -1; root.openDrawer(); } else if (i >= 0 && root.home[i].kind === "app") { root.resizing = -1; Host.launch(root.home[i].str); } else if (root.resizing >= 0) root.resizing = -1; // a tap beside the widget finishes return; @@ -656,6 +702,7 @@ Window { onCanceled: { hold.stop(); windowsBtn.pressed = false; + searchPill.pressed = false; if (root.lifted >= 0) root.drop(start ? start.moved : false); start = null; } @@ -666,6 +713,7 @@ Window { if (!touch.start || touch.start.moved) return; touch.longFired = true; windowsBtn.pressed = false; + searchPill.pressed = false; if (touch.pressedSlot >= 0) root.lift(touch.pressedSlot); else { root.resizing = -1; Host.haptic(); root.sheet = "menu"; } } diff --git a/qt/tests/e2e.cpp b/qt/tests/e2e.cpp index 917331e..86fa75f 100644 --- a/qt/tests/e2e.cpp +++ b/qt/tests/e2e.cpp @@ -295,6 +295,14 @@ int main(int argc, char *argv[]) { tap(center(slotRect(0))); eq(js("notice"), "Open com.example.gmail/.MainActivity", "tapping a home app opens it"); + // the search pill on the front page opens the drawer (its search focuses there) + tap(itemCenter("homeSearch")); + check(js("drawerOpen").toBool(), "tapping the home search opens the drawer"); + snap("home-search"); + js("closeDrawer()"); + settle(300); + check(!js("drawerOpen").toBool(), "and it closes again"); + // hold a widget without moving: resize handles; drag them to snap it to the grid hold(center(slotRect(3))); release(center(slotRect(3))); settle(200); eq(js("resizing"), 3, "a widget gets handles, not the menu");