The empty launcher stays in the widened notch, now laid out exactly like the launcher window's bar. Typing (or the magnifying glass / Down) hands over to the launcher window, which opens at the notch's size with the text already in it and only grows down with the results; clearing the search shrinks it back into the notch. The query and browse state are shared through ShellState, keys typed during the hand-over carry across, and the bar keeps its keyboard claim so focus returns on its own. The launcher window's open state is read from plain properties so it never maps for a frame on a stale value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
144 lines
4.8 KiB
QML
144 lines
4.8 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import QtQuick.Controls
|
|
import "../components"
|
|
import "../core"
|
|
import "../theme"
|
|
|
|
// The launcher's empty state in notch mode: its search bar inside the widened
|
|
// notch, laid out exactly like the launcher window's bar. The first keystroke
|
|
// (or the magnifying glass) hands over to the launcher window, which opens at
|
|
// this size and grows down with the results; clearing the search hands back.
|
|
Item {
|
|
id: root
|
|
property bool active: false
|
|
// The launcher window's bar is this tall; rows centre on it.
|
|
readonly property int barHeight: 60
|
|
readonly property int pillSize: 36
|
|
property string pillHover: ""
|
|
onActiveChanged: {
|
|
if (!active)
|
|
return;
|
|
if (input.text !== ShellState.launcherQuery)
|
|
input.text = ShellState.launcherQuery;
|
|
Qt.callLater(() => {
|
|
input.forceActiveFocus();
|
|
input.cursorPosition = input.text.length;
|
|
});
|
|
}
|
|
Connections {
|
|
target: ShellState
|
|
function onLauncherQueryChanged() {
|
|
if (input.text !== ShellState.launcherQuery)
|
|
input.text = ShellState.launcherQuery;
|
|
}
|
|
}
|
|
|
|
// Swallows clicks so they reach the field, not the pill behind it.
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: input.forceActiveFocus()
|
|
}
|
|
Rectangle {
|
|
x: 12
|
|
y: (root.barHeight - height) / 2
|
|
width: 38
|
|
height: 38
|
|
radius: 12
|
|
color: browseArea.containsMouse ? Theme.hover : Theme.transparent
|
|
Accessible.role: Accessible.Button
|
|
Accessible.name: "Show all applications"
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: Icons.available ? "" : "⌕"
|
|
font.family: Icons.available ? Icons.family : ""
|
|
color: Theme.textSecondary
|
|
font.pixelSize: 20
|
|
}
|
|
MouseArea {
|
|
id: browseArea
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
onClicked: ShellState.launcherBrowse = true
|
|
}
|
|
}
|
|
TextField {
|
|
id: input
|
|
objectName: "notchSearchInput"
|
|
x: 60
|
|
y: (root.barHeight - height) / 2
|
|
width: pills.x - x - 18
|
|
height: 40
|
|
placeholderText: root.pillHover || "Search :3"
|
|
color: Theme.text
|
|
placeholderTextColor: Theme.textSecondary
|
|
selectByMouse: true
|
|
font.pixelSize: 22
|
|
font.weight: Font.Light
|
|
background: Item {}
|
|
padding: 0
|
|
maximumLength: 256
|
|
// Any text opens the launcher window with it.
|
|
onTextChanged: if (ShellState.notchLauncher && text !== ShellState.launcherQuery)
|
|
ShellState.launcherQuery = text
|
|
Keys.onEscapePressed: ShellState.launcherOpen = false
|
|
Keys.onDownPressed: ShellState.launcherBrowse = true
|
|
}
|
|
// Clipboard history and emoji, as in the launcher's bar.
|
|
Row {
|
|
id: pills
|
|
x: root.width - width - 14
|
|
y: (root.barHeight - root.pillSize) / 2
|
|
spacing: 6
|
|
Repeater {
|
|
model: [
|
|
{
|
|
mode: "clipboard",
|
|
label: "Clipboard",
|
|
glyph: "",
|
|
fallback: "⎘"
|
|
},
|
|
{
|
|
mode: "emoji",
|
|
label: "Emoji",
|
|
glyph: "",
|
|
fallback: "☺"
|
|
}
|
|
]
|
|
GlassPanel {
|
|
id: pill
|
|
required property var modelData
|
|
width: root.pillSize
|
|
height: width
|
|
radius: width / 2
|
|
color: pillArea.containsMouse ? Theme.hover : Theme.fill
|
|
border.color: Theme.hairline
|
|
plain: true
|
|
Accessible.role: Accessible.Button
|
|
Accessible.name: modelData.label
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: Icons.available ? pill.modelData.glyph : pill.modelData.fallback
|
|
font.family: Icons.available ? Icons.family : ""
|
|
font.pixelSize: 17
|
|
color: Theme.text
|
|
}
|
|
MouseArea {
|
|
id: pillArea
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
onContainsMouseChanged: {
|
|
if (containsMouse)
|
|
root.pillHover = pill.modelData.label;
|
|
else if (root.pillHover === pill.modelData.label)
|
|
root.pillHover = "";
|
|
}
|
|
onClicked: ShellState.openLauncher(pill.modelData.mode)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|