Add home search pill that opens the app drawer
Launcher / apk (push) Failing after 2m47s

This commit is contained in:
nandi committed 2026-11-18 22:18:50 +00:00
1 parent 02ce0491c1
commit 7d2bf5996f
2 files changed
+58 -2

No files matched your search

+50 -2
View File
@@ -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"; }
}