pragma ComponentBehavior: Bound import QtQuick import "../core" import "../services" import "../theme" // The launcher in notch mode: a search field and a row of top matches inside // the widened notch, the way a notification shows there. Enter launches the // highlighted match, Tab and the arrow keys move along the row, Escape clears // and then closes. Clipboard history and emoji open the launcher window. Item { id: root property bool active: false readonly property string query: input.text.trim() readonly property bool commandMode: query.startsWith(">") readonly property int maxShown: 6 readonly property var results: (commandMode ? commands.results : apps.results).slice(0, maxShown) property int selectedIndex: 0 property string launchError: "" readonly property var selected: results[selectedIndex] || null onResultsChanged: selectedIndex = 0 onActiveChanged: { input.text = ""; launchError = ""; selectedIndex = 0; if (active) Qt.callLater(() => input.forceActiveFocus()); } AppSearch { id: apps enabled: root.active && root.query !== "" && !root.commandMode query: root.query limit: root.maxShown } CommandSearch { id: commands enabled: root.active && root.commandMode query: root.query limit: root.maxShown } function select(offset) { if (results.length) selectedIndex = (selectedIndex + offset + results.length) % results.length; } function activate(index) { const result = results[index]; if (!result) return; if (result.command) { const command = CommandRegistry.commands.find(c => c.id === result.id); if (!command || !command.stay) ShellState.launcherOpen = false; CommandRegistry.execute(result.id); } else if (ApplicationsService.launch(result.entry, null)) ShellState.launcherOpen = false; else launchError = ApplicationsService.error; } // Swallows clicks so they reach the field, not the pill behind it. MouseArea { anchors.fill: parent onClicked: input.forceActiveFocus() } Text { id: glass x: 14 anchors.verticalCenter: parent.verticalCenter text: Icons.available ? "󰍉" : "⌕" font.family: Icons.available ? Icons.family : "" font.pixelSize: 17 color: Theme.textSecondary } // Typed text, then the highlighted match's name in grey after it. Item { id: field anchors.left: glass.right anchors.leftMargin: 10 anchors.right: strip.left anchors.rightMargin: 12 anchors.verticalCenter: parent.verticalCenter height: 24 clip: true TextInput { id: input objectName: "notchSearchInput" anchors.verticalCenter: parent.verticalCenter width: Math.max(1, Math.min(contentWidth + 2, field.width)) color: Theme.text selectionColor: Theme.accent selectedTextColor: Theme.text font.pixelSize: 15 maximumLength: 256 onTextEdited: root.launchError = "" Keys.onEscapePressed: { if (text !== "") clear(); else ShellState.launcherOpen = false; } Keys.onTabPressed: root.select(1) Keys.onBacktabPressed: root.select(-1) Keys.onDownPressed: root.select(1) Keys.onUpPressed: root.select(-1) Keys.onRightPressed: event => { if (cursorPosition === text.length && root.results.length) root.select(1); else event.accepted = false; } Keys.onLeftPressed: event => { if (cursorPosition === text.length && root.selectedIndex > 0) root.select(-1); else event.accepted = false; } Keys.onReturnPressed: root.activate(root.selectedIndex) Keys.onEnterPressed: root.activate(root.selectedIndex) } Text { anchors.verticalCenter: parent.verticalCenter x: input.text === "" ? 0 : input.width + 8 width: Math.max(0, field.width - x) elide: Text.ElideRight font.pixelSize: 15 color: root.launchError ? Theme.urgent : Theme.textSecondary text: root.launchError ? root.launchError : input.text === "" ? "Search apps" : root.selected ? "— " + root.selected.title : "No matches" } } // Top matches; the highlighted one launches on Enter. Row { id: strip anchors.right: modes.left anchors.rightMargin: 10 anchors.verticalCenter: parent.verticalCenter spacing: 4 Repeater { model: root.results Rectangle { id: tile required property var modelData required property int index readonly property bool current: index === root.selectedIndex width: 34 height: 34 radius: 10 color: current ? Qt.alpha(Theme.accent, 0.35) : tileArea.containsMouse ? Theme.hover : Theme.transparent border.width: current ? 1 : 0 border.color: Qt.alpha(Theme.accent, 0.8) Accessible.role: Accessible.Button Accessible.name: modelData.title Image { id: tileIcon anchors.centerIn: parent width: 24 height: 24 source: tile.modelData.entry ? ApplicationsService.icon(tile.modelData.entry) : "" sourceSize: Qt.size(48, 48) asynchronous: true smooth: true mipmap: true } Text { anchors.centerIn: parent visible: tileIcon.status !== Image.Ready text: tile.modelData.command ? (Icons.available ? "󰒓" : ">") : tile.modelData.title.charAt(0).toUpperCase() font.family: Icons.available ? Icons.family : "" font.pixelSize: 15 color: Theme.text } MouseArea { id: tileArea anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onEntered: root.selectedIndex = tile.index onClicked: root.activate(tile.index) } } } } // Clipboard history and emoji open the full launcher window. Row { id: modes anchors.right: parent.right anchors.rightMargin: 12 anchors.verticalCenter: parent.verticalCenter spacing: 4 Repeater { model: [ { mode: "clipboard", glyph: "󰅌", fallback: "C", name: "Clipboard history" }, { mode: "emoji", glyph: "󰞅", fallback: ":)", name: "Emoji" } ] Rectangle { id: mode required property var modelData width: 28 height: 28 radius: 14 color: modeArea.containsMouse ? Theme.hover : Theme.fill border.width: 1 border.color: Theme.hairline Accessible.role: Accessible.Button Accessible.name: modelData.name Text { anchors.centerIn: parent text: Icons.available ? mode.modelData.glyph : mode.modelData.fallback font.family: Icons.available ? Icons.family : "" font.pixelSize: 14 color: Theme.text } MouseArea { id: modeArea anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: ShellState.openLauncher(mode.modelData.mode) } } } } }