From 065b728af61eefe41c55638a262ddf06bc9752fc Mon Sep 17 00:00:00 2001 From: mx Date: Sat, 14 Nov 2026 15:19:04 +0100 Subject: [PATCH] Put the whole launcher inside the notch, the pocket-dots way The launcher's contents (search, results, app grid, commands, clipboard history and emoji) move into LauncherView, which the launcher window hosts normally and the notch hosts in notch mode. In the notch it is one more face of the same shape: the search sits in the band beside the clock, sized to the band so it never clips, and the notch springs wider and then down to fit whatever is below (springs as on pocket-dots, scaled by the notch speed settings). The bar window grows tall only while it is open, with input still masked to the shapes. The separate window, the hand-over between them and the compact search are gone. Co-Authored-By: Claude Opus 5.5 --- quickshell/bar/Bar.qml | 15 +- quickshell/core/ShellState.qml | 19 +- quickshell/launcher/Launcher.qml | 710 ++------------------------- quickshell/launcher/LauncherView.qml | 618 +++++++++++++++++++++++ quickshell/launcher/NotchSearch.qml | 143 ------ quickshell/launcher/qmldir | 2 +- quickshell/notch/NotchPill.qml | 83 +++- 7 files changed, 720 insertions(+), 870 deletions(-) create mode 100644 quickshell/launcher/LauncherView.qml delete mode 100644 quickshell/launcher/NotchSearch.qml diff --git a/quickshell/bar/Bar.qml b/quickshell/bar/Bar.qml index 6ae8558..dacd656 100644 --- a/quickshell/bar/Bar.qml +++ b/quickshell/bar/Bar.qml @@ -19,7 +19,10 @@ PanelWindow { readonly property int outerMargin: BarDrawers.margin // The window reaches below the bar (input is masked to the bar) so the // HyprGlass layer edge is not on the bar's bottom edge, where drawers join. - implicitHeight: BarDrawers.bottom + BarDrawers.overhang + // While the launcher is open in the notch, the window is tall enough for + // it to grow down; input stays masked to the shapes. + readonly property bool tall: notch && (notchPill.searching || notchPill.height > BarDrawers.bottom + 1) + implicitHeight: tall ? Math.ceil(BarDrawers.bottom + notchPill.maxBodyHeight + 40) : BarDrawers.bottom + BarDrawers.overhang // Notch mode splits the bar into a left island, the centre notch and a // right island; only those take input. readonly property bool notch: ShellState.notchMode @@ -36,12 +39,8 @@ PanelWindow { WlrLayershell.namespace: "glassMxrph-bar" // The notch's search takes the keyboard while it is open on this screen; // a click anywhere else closes it. - readonly property bool searching: notch && ShellState.notchSearch && ScreenService.current(ShellState.launcherScreen) === screen - // Holds the keyboard for as long as the launcher is open here. The launcher - // window's own claim (overlay layer) wins while it is up; when it hands - // back, the keyboard returns here without asking again. - readonly property bool typing: notch && ShellState.notchLauncher && ScreenService.current(ShellState.launcherScreen) === screen - WlrLayershell.keyboardFocus: typing ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None + readonly property bool searching: notch && ShellState.notchLauncher && ScreenService.current(ShellState.launcherScreen) === screen + WlrLayershell.keyboardFocus: searching ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None // The grab starts once the bar holds the keyboard; started together with // the focus change, Hyprland clears it at once and the search closes. property bool grabbing: false @@ -140,6 +139,6 @@ PanelWindow { width: implicitWidth height: implicitHeight // The open notch window draws over this spot on its own screen. - visible: root.notch && !(ShellState.notchWindow && ShellState.notchWindow.visible && ShellState.notchWindow.screen === root.screen) && !(ShellState.launcherWindow && ShellState.launcherWindow.covering && ShellState.launcherWindow.screen === root.screen) && !(ShellState.wallpaperWindow && ShellState.wallpaperWindow.visible && ShellState.wallpaperWindow.screen === root.screen) + visible: root.notch && !(ShellState.notchWindow && ShellState.notchWindow.visible && ShellState.notchWindow.screen === root.screen) && !(ShellState.wallpaperWindow && ShellState.wallpaperWindow.visible && ShellState.wallpaperWindow.screen === root.screen) } } diff --git a/quickshell/core/ShellState.qml b/quickshell/core/ShellState.qml index 7f34223..06a64ab 100644 --- a/quickshell/core/ShellState.qml +++ b/quickshell/core/ShellState.qml @@ -71,7 +71,6 @@ Singleton { readonly property real notchPillWidth: MediaService.playing ? 236 : 128 property var notchScreen: null property var notchWindow: null - property var launcherWindow: null // "main" is the three-column panel; "computer" is the full Performance view. property string notchView: "main" function openNotch() { @@ -129,22 +128,8 @@ Singleton { // "emoji" is the Emoji Picker. // Changing it on an open launcher switches in place. property string launcherMode: "apps" - // Notch mode opens the launcher in the notch pill itself, the way a - // notification widens it. While the search is empty it stays there - // (notchSearch); typing or browsing hands over to the launcher window, - // which grows down from the widened pill. Both share the query. - property string launcherQuery: "" - property bool launcherBrowse: false - readonly property bool notchLauncher: notchMode && launcherOpen && launcherMode === "apps" - readonly property bool notchSearch: notchLauncher && launcherQuery === "" && !launcherBrowse - onLauncherOpenChanged: { - launcherQuery = ""; - launcherBrowse = false; - } - onLauncherModeChanged: { - launcherQuery = ""; - launcherBrowse = false; - } + // Notch mode opens the launcher inside the notch itself (every mode). + readonly property bool notchLauncher: notchMode && launcherOpen function activeScreen() { return ScreenService.active; } diff --git a/quickshell/launcher/Launcher.qml b/quickshell/launcher/Launcher.qml index 5bbe7e9..1581841 100644 --- a/quickshell/launcher/Launcher.qml +++ b/quickshell/launcher/Launcher.qml @@ -1,15 +1,11 @@ pragma ComponentBehavior: Bound import QtQuick -import QtQuick.Controls -import QtQuick.Layouts import Quickshell import Quickshell.Wayland import "../components" -import "../services" import "../theme" import "../core" - // Spotlight-style launcher: opens as a single search bar in the upper third. // Typing shows ranked results below it; the magnifying glass (or ↓ in an // empty bar) browses every application as an icon grid; > lists commands. @@ -17,6 +13,8 @@ import "../core" // in the same bar, newest first, without closing the window to switch. // Emoji mode (>emoji, `glassmxrph emoji`) shows a searchable emoji grid the // same way; the selected emoji's name is the section label. +// The contents are LauncherView; in notch mode the notch hosts that instead +// and this window stays closed. // Runtime selects the concrete Wayland layer implementation. // qmllint disable uncreatable-type PanelWindow { @@ -29,243 +27,23 @@ PanelWindow { left: true right: true } - visible: root.open || panel.opacity > 0.01 || (notch && progress > 0.001) + readonly property bool open: ShellState.launcherOpen && !ShellState.notchMode + visible: open || panel.opacity > 0.01 color: Theme.transparent exclusionMode: ExclusionMode.Ignore WlrLayershell.namespace: "glassMxrph-launcher" WlrLayershell.layer: WlrLayer.Overlay - WlrLayershell.keyboardFocus: root.open ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None - readonly property var options: ConfigService.ready ? ConfigService.data.launcher : ({ - width: 680, - maxResults: 50, - showDescriptions: true - }) - readonly property string query: search.text.trim() - readonly property bool clipboardMode: ShellState.launcherMode === "clipboard" - readonly property bool emojiMode: ShellState.launcherMode === "emoji" - readonly property bool commandMode: !clipboardMode && !emojiMode && query.startsWith(">") - property bool browsing: false - readonly property bool showList: clipboardMode || !emojiMode && query !== "" - readonly property bool showGrid: !showList && !emojiMode && browsing - // Arrow keys move through whichever grid is showing. - readonly property int columns: emojiMode ? emojiColumns : showGrid ? gridColumns : 1 - readonly property var allApps: ApplicationsService.launchable.map(entry => ({ - id: entry.id, - title: entry.name, - description: entry.genericName || entry.comment || entry.id, - entry: entry - })) - readonly property var clipboardResults: clipboardMode && root.open ? ClipboardService.filter(query).map(e => ({ - id: e.id, - title: e.text.replace(/\s+/g, " ").trim(), - description: "", - clip: e - })) : [] - readonly property var emojiResults: emojiMode && root.open ? EmojiService.filter(query).map(e => ({ - id: e.emoji, - title: e.name, - description: "", - glyph: e - })) : [] - readonly property var results: clipboardMode ? clipboardResults : emojiMode ? emojiResults : showList ? (commandMode ? commands.results : apps.results) : showGrid ? allApps : [] - property int selectedIndex: 0 - property string launchError: "" + WlrLayershell.keyboardFocus: open ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None + readonly property var options: view.options // Room is kept for the mode pills on the right of the bar. readonly property int pillSize: 48 readonly property real pillsWidth: 2 * pillSize + 2 * 10 - readonly property real targetWidth: Math.min(options.width + lead, root.width - 40 - (notch ? 0 : 2 * pillsWidth)) - // Notch mode keeps the collapsed notch's time and media at the left end of - // the search bar, as a notification does; the search opens to its right. - readonly property real lead: notch ? ShellState.notchPillWidth : 0 - // A hovered mode pill names itself in the empty search bar. - property string pillHover: "" - readonly property int barHeight: 60 - // Notch mode: the launcher drops out of the notch at the top edge. The - // panel's top corners sit above the screen and concave ears join it there. - readonly property bool notch: ShellState.notchMode - // Notch mode searches apps inside the notch itself (NotchSearch); this - // window only opens there for clipboard history and emoji. - // Read from the plain properties, not ShellState.notchSearch, so it never - // reads a stale value mid-update and maps for a frame. - readonly property bool open: ShellState.launcherOpen && !(ShellState.notchMode && ShellState.launcherMode === "apps" && ShellState.launcherQuery === "" && !ShellState.launcherBrowse) - onOpenChanged: reset() - // Notch mode morphs the collapsed notch into the launcher, as the notch - // panel does: solid shape throughout, width leading the height a little, - // contents fading in once it is mostly open and out first. - property real progress: root.open ? 1 : 0 - Behavior on progress { - enabled: root.notch - NumberAnimation { - id: morph - duration: root.open ? Theme.notchOpenDuration * 2 : Theme.notchCloseDuration * 1.3 - easing.type: Easing.BezierSpline - easing.bezierCurve: root.open ? [0.2, 0, 0, 1, 1, 1] : [0.3, 0, 0.8, 0.15, 1, 1] - } - } - readonly property bool settled: root.open && !morph.running - readonly property real wp: Math.min(1, progress * 1.15) - readonly property real contentOpacity: Math.max(0, Math.min(1, (progress - 0.55) / 0.4)) - // Open height, held while closing so clearing the results does not jump it. - property real heldHeight: barHeight + bodyHeight - Binding on heldHeight { - when: root.open - value: root.barHeight + root.bodyHeight - restoreMode: Binding.RestoreNone - } - Behavior on heldHeight { - enabled: root.notch && root.settled && !root.snapping - NumberAnimation { - duration: Theme.duration - easing.type: Easing.OutCubic - } - } - // Pills sit inside the search bar in notch mode, smaller. - readonly property int notchPill: 36 - readonly property real maxBodyHeight: Math.min(460, root.height * 0.78 - barHeight - (notch ? 0 : root.height * 0.22)) - // Clipboard mode shows the latest five rows; the rest scroll. - readonly property real clipboardRows: 5 * 48 - 2 - // Emoji mode shows six rows of the grid; the rest scroll. - readonly property int emojiCell: 52 - readonly property int emojiColumns: Math.max(1, Math.floor((targetWidth - 24) / emojiCell)) - readonly property real emojiRows: 6 * emojiCell - readonly property real bodyHeight: emojiMode ? Math.min(maxBodyHeight, Math.max(84, Math.min(emojiGrid.contentHeight, emojiRows) + 42)) : showList ? Math.min(maxBodyHeight, Math.max(84, (clipboardMode ? Math.min(list.contentHeight, clipboardRows) : list.contentHeight) + 46 + (launchError ? 22 : 0))) : showGrid ? Math.min(maxBodyHeight, grid.contentHeight + 46) : 0 - // Mode switches resize without animating, so >clipboard lands in place. - property bool snapping: false - // Frames drawn since the window was mapped. The bar's notch pill stays up - // until the launcher has drawn over it, so opening never shows a gap, and - // comes back just before the launcher shrinks home and unmaps. - property int drawnFrames: 0 - onVisibleChanged: if (!visible) - drawnFrames = 0 - FrameAnimation { - running: root.notch && root.visible && root.drawnFrames < 3 - onTriggered: root.drawnFrames++ - } - readonly property bool covering: visible && drawnFrames >= 3 && (root.open || progress > 0.02) - Timer { - id: unsnap - interval: 120 - onTriggered: root.snapping = false - } - readonly property int gridColumns: Math.max(1, Math.floor((targetWidth - 24) / 112)) - onResultsChanged: { - selectedIndex = 0; - list.contentY = 0; - grid.contentY = 0; - emojiGrid.contentY = 0; - emojiGrid.hovered = ""; - } - function select(offset) { - if (!results.length) - return; - selectedIndex = Math.max(0, Math.min(results.length - 1, selectedIndex + offset)); - if (emojiMode) - emojiGrid.positionViewAtIndex(selectedIndex, GridView.Contain); - else if (showGrid) - grid.positionViewAtIndex(selectedIndex, GridView.Contain); - else - list.positionViewAtIndex(selectedIndex, ListView.Contain); - } - function activate(index) { - const result = results[index]; - if (!result) - return; - if (result.clip) { - ClipboardService.copy(result.clip); - ShellState.launcherOpen = false; - } else if (result.glyph) { - EmojiService.copy(result.glyph); - ShellState.launcherOpen = false; - } else 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; - } - // Fresh state each time the window opens. - // Fresh state each time the window opens; from the notch's search it - // carries on with what was typed there. - function reset() { - if (!open) - return; - fromNotch = notch && ShellState.launcherMode === "apps"; - search.text = fromNotch ? ShellState.launcherQuery : ""; - browsing = fromNotch && ShellState.launcherBrowse; - launchError = ""; - selectedIndex = 0; - ClipboardService.refresh(); - if (emojiMode) - EmojiService.load(); - Qt.callLater(() => { - search.forceActiveFocus(); - search.cursorPosition = search.text.length; - }); - } - // Opened from the notch's search: it starts at the widened notch's size - // with the bar already showing, and only grows down. - property bool fromNotch: false - readonly property bool compact: notch && fromNotch && ShellState.notchLauncher - // Typing and browsing are shared with the notch's search; emptying both - // hands back to it. - readonly property bool sharing: notch && open && ShellState.launcherMode === "apps" - onBrowsingChanged: if (sharing) - ShellState.launcherBrowse = browsing + readonly property real targetWidth: Math.min(options.width, root.width - 40 - 2 * pillsWidth) function toggleBrowse() { - if (clipboardMode || emojiMode) { - ShellState.launcherMode = "apps"; - return; - } - browsing = !browsing; - if (browsing) - search.clear(); - selectedIndex = 0; - search.forceActiveFocus(); - } - Component.onCompleted: { - LauncherState.window = root; - ShellState.launcherWindow = root; - } - Component.onDestruction: { - LauncherState.window = null; - ShellState.launcherWindow = null; - } - Connections { - target: ShellState - // Keys typed in the notch before this window has the keyboard. - function onLauncherQueryChanged() { - if (root.open && !search.activeFocus && search.text !== ShellState.launcherQuery) - search.text = ShellState.launcherQuery; - } - function onLauncherModeChanged() { - if (root.emojiMode) - EmojiService.load(); - if (!root.open) - return; - root.snapping = true; - unsnap.restart(); - search.text = ""; - root.browsing = false; - root.launchError = ""; - root.selectedIndex = 0; - search.forceActiveFocus(); - } - } - AppSearch { - id: apps - enabled: root.open && root.showList && !root.commandMode - query: search.text - limit: root.options.maxResults - } - CommandSearch { - id: commands - enabled: root.open && root.commandMode - query: search.text - limit: root.options.maxResults + view.toggleBrowse(); } + Component.onCompleted: LauncherState.window = root + Component.onDestruction: LauncherState.window = null MouseArea { anchors.fill: parent onClicked: ShellState.launcherOpen = false @@ -275,38 +53,24 @@ PanelWindow { Row { id: pills objectName: "launcherPills" - x: root.notch ? panel.x + panel.width - width - 14 : panel.x + panel.width + 10 - y: panel.y + (root.barHeight - (root.notch ? root.notchPill : root.pillSize)) / 2 + x: panel.x + panel.width + 10 + y: panel.y + (view.barHeight - root.pillSize) / 2 z: 1 - spacing: root.notch ? 6 : 10 + spacing: 10 opacity: panel.opacity scale: panel.scale Repeater { - model: [ - { - mode: "clipboard", - label: "Clipboard", - glyph: "󰅌", - fallback: "⎘" - }, - { - mode: "emoji", - label: "Emoji", - glyph: "󰞅", - fallback: "☺" - } - ] + model: view.modes GlassPanel { id: pill required property var modelData readonly property bool active: ShellState.launcherMode === modelData.mode objectName: "launcherPill-" + modelData.mode - width: root.notch ? root.notchPill : root.pillSize + width: root.pillSize height: width radius: width / 2 - color: active ? Theme.accent : root.notch ? (pillArea.containsMouse ? Theme.hover : Theme.fill) : Qt.alpha(Theme.surface, Math.min(1, surfaceOpacity + (pillArea.containsMouse ? 0.18 : 0))) - border.color: root.notch ? Theme.hairline : Theme.border - plain: root.notch + color: active ? Theme.accent : Qt.alpha(Theme.surface, Math.min(1, surfaceOpacity + (pillArea.containsMouse ? 0.18 : 0))) + border.color: Theme.border Accessible.role: Accessible.Button Accessible.name: modelData.label scale: pillArea.pressed ? 0.92 : 1 @@ -320,7 +84,7 @@ PanelWindow { anchors.centerIn: parent text: Icons.available ? pill.modelData.glyph : pill.modelData.fallback font.family: Icons.available ? Icons.family : "" - font.pixelSize: root.notch ? 17 : 21 + font.pixelSize: 21 color: pill.active ? Theme.accentText : Theme.text } MouseArea { @@ -330,461 +94,57 @@ PanelWindow { cursorShape: Qt.PointingHandCursor onContainsMouseChanged: { if (containsMouse) - root.pillHover = pill.modelData.label; - else if (root.pillHover === pill.modelData.label) - root.pillHover = ""; - } - onClicked: { - ShellState.launcherMode = pill.active ? "apps" : pill.modelData.mode; - search.forceActiveFocus(); + view.pillHover = pill.modelData.label; + else if (view.pillHover === pill.modelData.label) + view.pillHover = ""; } + onClicked: view.toggleMode(pill.modelData.mode) } } } } - // Notch mode: the notch's own shape (ears at the top edge) behind the - // panel, which then draws no glass of its own. - DrawerShape { - visible: root.notch - x: panel.x - BarDrawers.ear - y: 0 - bodyWidth: panel.width - bodyHeight: panel.height - ear: BarDrawers.ear - radius: panel.radius - // Docked colour; the open fill only if the launcher follows "glassy when open". - fillColor: root.open ? Theme.notchLauncherFill : Theme.notchFill - Behavior on fillColor { - ColorAnimation { - duration: root.open ? Theme.notchColorDuration : Math.min(Theme.notchColorDuration, Theme.notchCloseDuration) - } - } - } - // The collapsed notch's time and media, fading out as the launcher grows - // out of it and back in as it shrinks home. - NotchGlance { - visible: root.notch - x: Math.round(panel.x + (root.lead - width) / 2) - y: Math.round((BarDrawers.bottom - height) / 2) - } - Rectangle { - visible: root.notch - x: Math.round(panel.x + root.lead) - y: Math.round(BarDrawers.bottom * 0.25) - width: 1 - height: Math.round(BarDrawers.bottom * 0.5) - color: Theme.hairline - opacity: root.compact ? 1 : root.contentOpacity - } GlassPanel { id: panel objectName: "launcherSurface" x: Math.round((root.width - width) / 2) - y: root.notch ? 0 : Math.round(root.height * 0.22) - // Notch mode grows out of the collapsed notch and shrinks back into it. - width: root.compact ? root.targetWidth : root.notch ? ShellState.notchPillWidth + (root.targetWidth - ShellState.notchPillWidth) * root.wp : root.open ? root.targetWidth : Math.min(320, root.targetWidth) - height: root.notch ? BarDrawers.bottom + (root.heldHeight - BarDrawers.bottom) * root.progress : root.barHeight + root.bodyHeight - color: root.notch ? Theme.transparent : Qt.alpha(Theme.surface, surfaceOpacity) - border.width: root.notch ? 0 : 1 - plain: root.notch - radius: Math.min(Theme.radius + 6, root.barHeight / 2) - opacity: root.compact ? 1 : root.notch ? root.contentOpacity : root.open ? 1 : 0 - scale: root.open || root.notch ? 1 : 1 - 0.04 * Theme.intensity + y: Math.round(root.height * 0.22) + width: root.open ? root.targetWidth : Math.min(320, root.targetWidth) + height: view.barHeight + view.bodyHeight + color: Qt.alpha(Theme.surface, surfaceOpacity) + border.width: 1 + radius: Math.min(Theme.radius + 6, view.barHeight / 2) + opacity: root.open ? 1 : 0 + scale: root.open ? 1 : 1 - 0.04 * Theme.intensity clip: true Behavior on width { - enabled: !root.notch NumberAnimation { duration: Theme.duration easing.type: Easing.OutCubic } } Behavior on height { - enabled: !root.notch && !root.snapping + enabled: !view.snapping NumberAnimation { duration: Theme.duration easing.type: Easing.OutCubic } } Behavior on opacity { - enabled: !root.notch NumberAnimation { duration: Theme.duration } } Behavior on scale { - enabled: !root.notch NumberAnimation { duration: Theme.duration easing.type: Easing.OutCubic } } - MouseArea { + LauncherView { + id: view anchors.fill: parent - } // Consume inside clicks without dismissing. - - // Search bar - RowLayout { - id: bar - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - height: root.barHeight - anchors.leftMargin: root.lead + 12 - // Room for the mode pills inside the bar in notch mode. - anchors.rightMargin: root.notch ? 18 + 2 * root.notchPill + 6 + 8 : 18 - spacing: 10 - Rectangle { - objectName: "launcherBrowse" - Layout.preferredWidth: 38 - Layout.preferredHeight: 38 - radius: 12 - color: root.browsing ? Theme.accent : browseArea.containsMouse ? Theme.hover : Theme.transparent - Accessible.role: Accessible.Button - Accessible.name: root.clipboardMode || root.emojiMode ? "Back to search" : root.browsing ? "Hide applications" : "Show all applications" - Behavior on color { - ColorAnimation { - duration: Theme.duration / 2 - } - } - Text { - anchors.centerIn: parent - text: root.commandMode ? ">" : !Icons.available ? (root.clipboardMode ? "⎘" : root.emojiMode ? "☺" : "⌕") : root.clipboardMode ? "󰅌" : root.emojiMode ? "󰇵" : "󰍉" - font.family: Icons.available && !root.commandMode ? Icons.family : "" - color: root.browsing ? Theme.accentText : Theme.textSecondary - font.pixelSize: 20 - } - MouseArea { - id: browseArea - anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - onClicked: root.toggleBrowse() - } - GlassToolTip { - visible: browseArea.containsMouse - delay: 600 - text: root.clipboardMode || root.emojiMode ? "Back to search" : root.browsing ? "Hide applications" : "All applications" - } - } - TextField { - id: search - objectName: "launcherSearch" - Layout.fillWidth: true - Layout.preferredHeight: 40 - placeholderText: root.pillHover || (root.clipboardMode ? "Clipboard History" : root.emojiMode ? "Search emoji" : root.browsing ? "Search applications" : "Search :3") - color: Theme.text - placeholderTextColor: Theme.textSecondary - selectByMouse: true - font.pixelSize: 22 - font.weight: Font.Light - background: Item {} - padding: 0 - maximumLength: 256 - onTextEdited: root.launchError = "" - onTextChanged: if (root.sharing && text !== ShellState.launcherQuery) - ShellState.launcherQuery = text - Keys.onEscapePressed: { - if (text !== "") - clear(); - else if (root.browsing) - root.browsing = false; - else - ShellState.launcherOpen = false; - } - Keys.onDownPressed: { - if (!root.showList && !root.browsing && !root.emojiMode) - root.browsing = true; - else - root.select(root.columns); - } - Keys.onUpPressed: root.select(-root.columns) - Keys.onRightPressed: event => { - if (root.columns > 1 || event.modifiers & Qt.ControlModifier) - root.select(1); - else - event.accepted = false; - } - Keys.onLeftPressed: event => { - if (root.columns > 1 || event.modifiers & Qt.ControlModifier) - root.select(-1); - else - event.accepted = false; - } - // Shift+Delete removes the selected clipboard entry from history. - Keys.onDeletePressed: event => { - if (root.clipboardMode && event.modifiers & Qt.ShiftModifier && root.results[root.selectedIndex]) - ClipboardService.remove(root.results[root.selectedIndex].clip); - else - event.accepted = false; - } - Keys.onTabPressed: root.select(1) - Keys.onBacktabPressed: root.select(-1) - Keys.onReturnPressed: root.activate(root.selectedIndex) - Keys.onEnterPressed: root.activate(root.selectedIndex) - } - } - - // Results (typing) or the application grid (magnifying glass). - Item { - id: body - anchors.left: parent.left - anchors.right: parent.right - anchors.top: bar.bottom - anchors.bottom: parent.bottom - visible: root.bodyHeight > 0 || panel.height > root.barHeight + 1 - Rectangle { - anchors.left: parent.left - anchors.right: parent.right - anchors.leftMargin: 14 - anchors.rightMargin: 14 - height: 1 - color: Theme.border - } - Text { - id: section - x: 22 - y: 12 - text: root.emojiMode ? (emojiGrid.hovered || (root.results[root.selectedIndex] || {}).title || "") : root.clipboardMode ? (!root.results.length ? "" : root.query ? "Matches" : "Recent") : root.showGrid ? "Applications" : root.commandMode ? "Settings" : root.results.length ? "Top hits" : "" - color: Theme.textSecondary - font.pixelSize: 11 - font.weight: Font.DemiBold - } - ListView { - id: list - objectName: "launcherResults" - visible: root.showList - anchors.fill: parent - anchors.topMargin: 32 - anchors.leftMargin: 8 - anchors.rightMargin: 8 - anchors.bottomMargin: root.launchError ? 30 : 8 - clip: true - model: root.showList ? root.results : [] - spacing: 2 - boundsBehavior: Flickable.StopAtBounds - ScrollBar.vertical: ScrollBar {} - delegate: Rectangle { - id: resultRow - required property var modelData - required property int index - readonly property bool selected: root.selectedIndex === index - width: list.width - height: 46 - radius: 10 - color: selected ? Theme.accent : mouse.containsMouse ? Theme.hover : Theme.transparent - RowLayout { - anchors.fill: parent - anchors.leftMargin: 10 - anchors.rightMargin: 12 - spacing: 12 - Item { - readonly property var copied: resultRow.modelData.clip - // Copied images get a wider thumbnail slot. - Layout.preferredWidth: copied && copied.thumb ? 52 : 30 - Layout.preferredHeight: 30 - Image { - id: icon - anchors.fill: parent - source: parent.copied ? (parent.copied.thumb ? "file://" + parent.copied.thumb : "") : resultRow.modelData.entry ? ApplicationsService.icon(resultRow.modelData.entry) : "" - sourceSize: parent.copied ? Qt.size(104, 60) : Qt.size(60, 60) - fillMode: Image.PreserveAspectFit - asynchronous: !!parent.copied - } - Text { - anchors.centerIn: parent - visible: icon.source.toString() === "" || icon.status === Image.Error - text: parent.copied ? (Icons.available ? (parent.copied.image ? "󰋩" : "󰅍") : "¶") : resultRow.modelData.command ? "⚙" : resultRow.modelData.title.slice(0, 2).toUpperCase() - font.family: parent.copied && Icons.available ? Icons.family : "" - color: resultRow.selected ? Theme.accentText : Theme.textSecondary - font.pixelSize: parent.copied ? 18 : 16 - } - } - Text { - text: resultRow.modelData.title - // Clipboard text is shown as is, never as markup. - textFormat: Text.PlainText - Layout.fillWidth: !!resultRow.modelData.clip - elide: Text.ElideRight - color: resultRow.selected ? Theme.accentText : Theme.text - font.pixelSize: 14 - font.weight: Font.Medium - } - Text { - visible: root.options.showDescriptions && !resultRow.modelData.clip - text: "— " + resultRow.modelData.description - Layout.fillWidth: true - elide: Text.ElideRight - color: resultRow.selected ? Qt.alpha(Theme.accentText, 0.75) : Theme.textSecondary - font.pixelSize: 12 - } - Item { - visible: !root.options.showDescriptions && !resultRow.modelData.clip - Layout.fillWidth: true - } - Text { - text: resultRow.modelData.clip ? (resultRow.modelData.clip.image ? "Image" : "Text") : resultRow.modelData.command ? resultRow.modelData.kind : "Application" - color: resultRow.selected ? Qt.alpha(Theme.accentText, 0.75) : Theme.textSecondary - font.pixelSize: 11 - } - } - MouseArea { - id: mouse - anchors.fill: parent - hoverEnabled: true - // Hover highlights locally; only keys change keyboard selection. - // Layout/scroll movement under a stationary pointer must not steal it. - onClicked: root.activate(resultRow.index) - } - Accessible.role: Accessible.Button - Accessible.name: modelData.title - Accessible.onPressAction: root.activate(index) - } - } - GridView { - id: grid - objectName: "launcherApps" - visible: root.showGrid - anchors.fill: parent - anchors.topMargin: 32 - anchors.leftMargin: 12 - anchors.rightMargin: 12 - anchors.bottomMargin: 10 - clip: true - model: root.showGrid ? root.results : [] - cellWidth: Math.floor(width / root.gridColumns) - cellHeight: 100 - boundsBehavior: Flickable.StopAtBounds - ScrollBar.vertical: ScrollBar {} - delegate: Item { - id: tile - required property var modelData - required property int index - readonly property bool selected: root.selectedIndex === index - width: grid.cellWidth - height: grid.cellHeight - Rectangle { - anchors.fill: parent - anchors.margins: 4 - radius: 14 - color: tile.selected ? Qt.alpha(Theme.accent, 0.35) : tileArea.containsMouse ? Theme.hover : Theme.transparent - border.width: tile.selected ? 1 : 0 - border.color: Theme.accentVivid - } - Column { - anchors.centerIn: parent - spacing: 6 - Image { - id: tileIcon - anchors.horizontalCenter: parent.horizontalCenter - width: 52 - height: 52 - source: ApplicationsService.icon(tile.modelData.entry) - sourceSize: Qt.size(104, 104) - fillMode: Image.PreserveAspectFit - asynchronous: true - Text { - anchors.centerIn: parent - visible: tileIcon.source.toString() === "" || tileIcon.status === Image.Error - text: tile.modelData.title.slice(0, 2).toUpperCase() - color: Theme.textSecondary - font.pixelSize: 18 - } - } - Text { - anchors.horizontalCenter: parent.horizontalCenter - width: grid.cellWidth - 12 - horizontalAlignment: Text.AlignHCenter - text: tile.modelData.title - elide: Text.ElideRight - color: Theme.text - font.pixelSize: 11 - } - } - MouseArea { - id: tileArea - anchors.fill: parent - hoverEnabled: true - onClicked: root.activate(tile.index) - } - Accessible.role: Accessible.Button - Accessible.name: modelData.title - Accessible.onPressAction: root.activate(index) - } - } - GridView { - id: emojiGrid - objectName: "launcherEmoji" - // Name of the emoji under the pointer, shown instead of the selection's. - property string hovered: "" - visible: root.emojiMode - anchors.fill: parent - anchors.topMargin: 32 - anchors.leftMargin: 12 - anchors.rightMargin: 12 - anchors.bottomMargin: 10 - clip: true - model: root.emojiMode ? root.results : [] - cellWidth: Math.floor(width / root.emojiColumns) - cellHeight: root.emojiCell - boundsBehavior: Flickable.StopAtBounds - ScrollBar.vertical: ScrollBar {} - delegate: Item { - id: glyph - required property var modelData - required property int index - readonly property bool selected: root.selectedIndex === index - width: emojiGrid.cellWidth - height: emojiGrid.cellHeight - Rectangle { - anchors.fill: parent - anchors.margins: 3 - radius: 12 - color: glyph.selected ? Qt.alpha(Theme.accent, 0.35) : glyphArea.containsMouse ? Theme.hover : Theme.transparent - border.width: glyph.selected ? 1 : 0 - border.color: Theme.accentVivid - } - Text { - anchors.centerIn: parent - text: glyph.modelData.id - textFormat: Text.PlainText - font.pixelSize: 28 - } - MouseArea { - id: glyphArea - anchors.fill: parent - hoverEnabled: true - onContainsMouseChanged: { - if (containsMouse) - emojiGrid.hovered = glyph.modelData.title; - else if (emojiGrid.hovered === glyph.modelData.title) - emojiGrid.hovered = ""; - } - onClicked: root.activate(glyph.index) - } - Accessible.role: Accessible.Button - Accessible.name: modelData.title - Accessible.onPressAction: root.activate(index) - } - } - Text { - anchors.centerIn: parent - anchors.verticalCenterOffset: 12 - visible: (root.showList || root.emojiMode) && root.results.length === 0 - text: root.emojiMode ? (EmojiService.loaded ? "No matching emoji" : "Loading…") : root.clipboardMode ? (ClipboardService.error || (root.query ? "No matches" : ClipboardService.loaded ? "Clipboard history is empty" : "Loading…")) : root.commandMode ? "No matching settings" : "No results" - color: Theme.textSecondary - font.pixelSize: 13 - } - Text { - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - anchors.margins: 12 - visible: !!root.launchError - elide: Text.ElideRight - text: root.launchError - color: Theme.urgent - font.pixelSize: 12 - } + active: root.open + maxBodyHeight: Math.min(460, root.height * 0.78 - barHeight - root.height * 0.22) } } } diff --git a/quickshell/launcher/LauncherView.qml b/quickshell/launcher/LauncherView.qml new file mode 100644 index 0000000..e56cc4c --- /dev/null +++ b/quickshell/launcher/LauncherView.qml @@ -0,0 +1,618 @@ +pragma ComponentBehavior: Bound +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import "../components" +import "../services" +import "../theme" +import "../core" + +// Everything the launcher shows and does, without a window: the search bar, +// ranked results, the application grid (magnifying glass, or ↓ in an empty +// bar), commands (>), Clipboard History and the Emoji Picker. The launcher +// window hosts it normally; in notch mode the notch hosts it, so every mode +// lives in the one launcher either way. +// +// The host sizes it: width is the launcher's width, and the host gives it +// barHeight + bodyHeight of height. maxBodyHeight caps the body. +Item { + id: root + // Whether the launcher is showing here; it resets each time it opens. + property bool active: false + // Notch layout: a shorter bar in the notch's band, with room on the left + // (barInset) for the notch's clock, and the mode pills inside the bar. + property bool notch: false + property real band: 60 + property real barInset: 0 + property real maxBodyHeight: 460 + + readonly property var options: ConfigService.ready ? ConfigService.data.launcher : ({ + width: 680, + maxResults: 50, + showDescriptions: true + }) + readonly property string query: search.text.trim() + readonly property bool clipboardMode: ShellState.launcherMode === "clipboard" + readonly property bool emojiMode: ShellState.launcherMode === "emoji" + readonly property bool commandMode: !clipboardMode && !emojiMode && query.startsWith(">") + property bool browsing: false + readonly property bool showList: clipboardMode || !emojiMode && query !== "" + readonly property bool showGrid: !showList && !emojiMode && browsing + // Arrow keys move through whichever grid is showing. + readonly property int columns: emojiMode ? emojiColumns : showGrid ? gridColumns : 1 + readonly property var allApps: ApplicationsService.launchable.map(entry => ({ + id: entry.id, + title: entry.name, + description: entry.genericName || entry.comment || entry.id, + entry: entry + })) + readonly property var clipboardResults: clipboardMode && active ? ClipboardService.filter(query).map(e => ({ + id: e.id, + title: e.text.replace(/\s+/g, " ").trim(), + description: "", + clip: e + })) : [] + readonly property var emojiResults: emojiMode && active ? EmojiService.filter(query).map(e => ({ + id: e.emoji, + title: e.name, + description: "", + glyph: e + })) : [] + readonly property var results: clipboardMode ? clipboardResults : emojiMode ? emojiResults : showList ? (commandMode ? commands.results : apps.results) : showGrid ? allApps : [] + property int selectedIndex: 0 + property string launchError: "" + // A hovered mode pill names itself in the empty search bar. + property string pillHover: "" + + readonly property real barHeight: notch ? band : 60 + // Controls in the bar scale down to fit a short notch band. + readonly property real buttonSize: notch ? Math.min(34, band - 8) : 38 + readonly property real pillSize: notch ? Math.min(32, band - 10) : 36 + readonly property int fontSize: notch ? Math.max(13, Math.min(20, Math.round(band * 0.45))) : 22 + // Clipboard mode shows the latest five rows; the rest scroll. + readonly property real clipboardRows: 5 * 48 - 2 + // Emoji mode shows six rows of the grid; the rest scroll. + readonly property int emojiCell: 52 + readonly property int emojiColumns: Math.max(1, Math.floor((width - 24) / emojiCell)) + readonly property real emojiRows: 6 * emojiCell + readonly property int gridColumns: Math.max(1, Math.floor((width - 24) / 112)) + readonly property real bodyHeight: emojiMode ? Math.min(maxBodyHeight, Math.max(84, Math.min(emojiGrid.contentHeight, emojiRows) + 42)) : showList ? Math.min(maxBodyHeight, Math.max(84, (clipboardMode ? Math.min(list.contentHeight, clipboardRows) : list.contentHeight) + 46 + (launchError ? 22 : 0))) : showGrid ? Math.min(maxBodyHeight, grid.contentHeight + 46) : 0 + // Mode switches resize without animating, so >clipboard lands in place. + property bool snapping: false + Timer { + id: unsnap + interval: 120 + onTriggered: root.snapping = false + } + onResultsChanged: { + selectedIndex = 0; + list.contentY = 0; + grid.contentY = 0; + emojiGrid.contentY = 0; + emojiGrid.hovered = ""; + } + onActiveChanged: reset() + function select(offset) { + if (!results.length) + return; + selectedIndex = Math.max(0, Math.min(results.length - 1, selectedIndex + offset)); + if (emojiMode) + emojiGrid.positionViewAtIndex(selectedIndex, GridView.Contain); + else if (showGrid) + grid.positionViewAtIndex(selectedIndex, GridView.Contain); + else + list.positionViewAtIndex(selectedIndex, ListView.Contain); + } + function activate(index) { + const result = results[index]; + if (!result) + return; + if (result.clip) { + ClipboardService.copy(result.clip); + ShellState.launcherOpen = false; + } else if (result.glyph) { + EmojiService.copy(result.glyph); + ShellState.launcherOpen = false; + } else 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; + } + // Fresh state each time it opens. + function reset() { + if (!active) + return; + search.text = ""; + browsing = false; + launchError = ""; + selectedIndex = 0; + ClipboardService.refresh(); + if (emojiMode) + EmojiService.load(); + Qt.callLater(() => search.forceActiveFocus()); + } + function focusSearch() { + search.forceActiveFocus(); + } + function toggleBrowse() { + if (clipboardMode || emojiMode) { + ShellState.launcherMode = "apps"; + return; + } + browsing = !browsing; + if (browsing) + search.clear(); + selectedIndex = 0; + search.forceActiveFocus(); + } + // A mode pill: toggles its mode; the active one is filled. + function toggleMode(mode) { + ShellState.launcherMode = ShellState.launcherMode === mode ? "apps" : mode; + search.forceActiveFocus(); + } + readonly property var modes: [ + { + mode: "clipboard", + label: "Clipboard", + glyph: "󰅌", + fallback: "⎘" + }, + { + mode: "emoji", + label: "Emoji", + glyph: "󰞅", + fallback: "☺" + } + ] + Connections { + target: ShellState + function onLauncherModeChanged() { + if (root.emojiMode) + EmojiService.load(); + if (!root.active) + return; + root.snapping = true; + unsnap.restart(); + search.text = ""; + root.browsing = false; + root.launchError = ""; + root.selectedIndex = 0; + search.forceActiveFocus(); + } + } + AppSearch { + id: apps + enabled: root.active && root.showList && !root.commandMode + query: search.text + limit: root.options.maxResults + } + CommandSearch { + id: commands + enabled: root.active && root.commandMode + query: search.text + limit: root.options.maxResults + } + MouseArea { + anchors.fill: parent + } // Consume inside clicks without dismissing. + + // Search bar + RowLayout { + id: bar + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + height: root.barHeight + anchors.leftMargin: root.barInset + 12 + anchors.rightMargin: root.notch ? 14 : 18 + spacing: 10 + Rectangle { + objectName: "launcherBrowse" + Layout.preferredWidth: root.buttonSize + Layout.preferredHeight: root.buttonSize + radius: root.buttonSize * 0.32 + color: root.browsing ? Theme.accent : browseArea.containsMouse ? Theme.hover : Theme.transparent + Accessible.role: Accessible.Button + Accessible.name: root.clipboardMode || root.emojiMode ? "Back to search" : root.browsing ? "Hide applications" : "Show all applications" + Behavior on color { + ColorAnimation { + duration: Theme.duration / 2 + } + } + Text { + anchors.centerIn: parent + text: root.commandMode ? ">" : !Icons.available ? (root.clipboardMode ? "⎘" : root.emojiMode ? "☺" : "⌕") : root.clipboardMode ? "󰅌" : root.emojiMode ? "󰇵" : "󰍉" + font.family: Icons.available && !root.commandMode ? Icons.family : "" + color: root.browsing ? Theme.accentText : Theme.textSecondary + font.pixelSize: Math.round(root.buttonSize * 0.53) + } + MouseArea { + id: browseArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: root.toggleBrowse() + } + GlassToolTip { + visible: browseArea.containsMouse + delay: 600 + text: root.clipboardMode || root.emojiMode ? "Back to search" : root.browsing ? "Hide applications" : "All applications" + } + } + TextField { + id: search + objectName: "launcherSearch" + Layout.fillWidth: true + Layout.preferredHeight: Math.min(40, root.barHeight - 4) + placeholderText: root.pillHover || (root.clipboardMode ? "Clipboard History" : root.emojiMode ? "Search emoji" : root.browsing ? "Search applications" : "Search :3") + color: Theme.text + placeholderTextColor: Theme.textSecondary + selectByMouse: true + font.pixelSize: root.fontSize + font.weight: Font.Light + background: Item {} + padding: 0 + verticalAlignment: TextInput.AlignVCenter + maximumLength: 256 + onTextEdited: root.launchError = "" + Keys.onEscapePressed: { + if (text !== "") + clear(); + else if (root.browsing) + root.browsing = false; + else + ShellState.launcherOpen = false; + } + Keys.onDownPressed: { + if (!root.showList && !root.browsing && !root.emojiMode) + root.browsing = true; + else + root.select(root.columns); + } + Keys.onUpPressed: root.select(-root.columns) + Keys.onRightPressed: event => { + if (root.columns > 1 || event.modifiers & Qt.ControlModifier) + root.select(1); + else + event.accepted = false; + } + Keys.onLeftPressed: event => { + if (root.columns > 1 || event.modifiers & Qt.ControlModifier) + root.select(-1); + else + event.accepted = false; + } + // Shift+Delete removes the selected clipboard entry from history. + Keys.onDeletePressed: event => { + if (root.clipboardMode && event.modifiers & Qt.ShiftModifier && root.results[root.selectedIndex]) + ClipboardService.remove(root.results[root.selectedIndex].clip); + else + event.accepted = false; + } + Keys.onTabPressed: root.select(1) + Keys.onBacktabPressed: root.select(-1) + Keys.onReturnPressed: root.activate(root.selectedIndex) + Keys.onEnterPressed: root.activate(root.selectedIndex) + } + // In the notch the mode pills sit in the bar; the window puts its own + // beside the panel. + Row { + id: pills + objectName: "launcherPills" + visible: root.notch + spacing: 6 + Repeater { + model: root.notch ? root.modes : [] + GlassPanel { + id: pill + required property var modelData + readonly property bool active: ShellState.launcherMode === modelData.mode + objectName: "launcherPill-" + modelData.mode + width: root.pillSize + height: width + radius: width / 2 + color: active ? Theme.accent : pillArea.containsMouse ? Theme.hover : Theme.fill + border.color: Theme.hairline + plain: true + Accessible.role: Accessible.Button + Accessible.name: modelData.label + scale: pillArea.pressed ? 0.92 : 1 + Behavior on scale { + NumberAnimation { + duration: Theme.duration / 2 + easing.type: Easing.OutCubic + } + } + Text { + anchors.centerIn: parent + text: Icons.available ? pill.modelData.glyph : pill.modelData.fallback + font.family: Icons.available ? Icons.family : "" + font.pixelSize: Math.round(root.pillSize * 0.47) + color: pill.active ? Theme.accentText : 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: root.toggleMode(pill.modelData.mode) + } + } + } + } + } + + // Results (typing) or the application grid (magnifying glass). + Item { + id: body + anchors.left: parent.left + anchors.right: parent.right + anchors.top: bar.bottom + anchors.bottom: parent.bottom + visible: root.bodyHeight > 0 || root.height > root.barHeight + 1 + Rectangle { + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: 14 + anchors.rightMargin: 14 + height: 1 + color: root.notch ? Theme.hairline : Theme.border + } + Text { + id: section + x: 22 + y: 12 + text: root.emojiMode ? (emojiGrid.hovered || (root.results[root.selectedIndex] || {}).title || "") : root.clipboardMode ? (!root.results.length ? "" : root.query ? "Matches" : "Recent") : root.showGrid ? "Applications" : root.commandMode ? "Settings" : root.results.length ? "Top hits" : "" + color: Theme.textSecondary + font.pixelSize: 11 + font.weight: Font.DemiBold + } + ListView { + id: list + objectName: "launcherResults" + visible: root.showList + anchors.fill: parent + anchors.topMargin: 32 + anchors.leftMargin: 8 + anchors.rightMargin: 8 + anchors.bottomMargin: root.launchError ? 30 : 8 + clip: true + model: root.showList ? root.results : [] + spacing: 2 + boundsBehavior: Flickable.StopAtBounds + ScrollBar.vertical: ScrollBar {} + delegate: Rectangle { + id: resultRow + required property var modelData + required property int index + readonly property bool selected: root.selectedIndex === index + width: list.width + height: 46 + radius: 10 + color: selected ? Theme.accent : mouse.containsMouse ? Theme.hover : Theme.transparent + RowLayout { + anchors.fill: parent + anchors.leftMargin: 10 + anchors.rightMargin: 12 + spacing: 12 + Item { + readonly property var copied: resultRow.modelData.clip + // Copied images get a wider thumbnail slot. + Layout.preferredWidth: copied && copied.thumb ? 52 : 30 + Layout.preferredHeight: 30 + Image { + id: icon + anchors.fill: parent + source: parent.copied ? (parent.copied.thumb ? "file://" + parent.copied.thumb : "") : resultRow.modelData.entry ? ApplicationsService.icon(resultRow.modelData.entry) : "" + sourceSize: parent.copied ? Qt.size(104, 60) : Qt.size(60, 60) + fillMode: Image.PreserveAspectFit + asynchronous: !!parent.copied + } + Text { + anchors.centerIn: parent + visible: icon.source.toString() === "" || icon.status === Image.Error + text: parent.copied ? (Icons.available ? (parent.copied.image ? "󰋩" : "󰅍") : "¶") : resultRow.modelData.command ? "⚙" : resultRow.modelData.title.slice(0, 2).toUpperCase() + font.family: parent.copied && Icons.available ? Icons.family : "" + color: resultRow.selected ? Theme.accentText : Theme.textSecondary + font.pixelSize: parent.copied ? 18 : 16 + } + } + Text { + text: resultRow.modelData.title + // Clipboard text is shown as is, never as markup. + textFormat: Text.PlainText + Layout.fillWidth: !!resultRow.modelData.clip + elide: Text.ElideRight + color: resultRow.selected ? Theme.accentText : Theme.text + font.pixelSize: 14 + font.weight: Font.Medium + } + Text { + visible: root.options.showDescriptions && !resultRow.modelData.clip + text: "— " + resultRow.modelData.description + Layout.fillWidth: true + elide: Text.ElideRight + color: resultRow.selected ? Qt.alpha(Theme.accentText, 0.75) : Theme.textSecondary + font.pixelSize: 12 + } + Item { + visible: !root.options.showDescriptions && !resultRow.modelData.clip + Layout.fillWidth: true + } + Text { + text: resultRow.modelData.clip ? (resultRow.modelData.clip.image ? "Image" : "Text") : resultRow.modelData.command ? resultRow.modelData.kind : "Application" + color: resultRow.selected ? Qt.alpha(Theme.accentText, 0.75) : Theme.textSecondary + font.pixelSize: 11 + } + } + MouseArea { + id: mouse + anchors.fill: parent + hoverEnabled: true + // Hover highlights locally; only keys change keyboard selection. + // Layout/scroll movement under a stationary pointer must not steal it. + onClicked: root.activate(resultRow.index) + } + Accessible.role: Accessible.Button + Accessible.name: modelData.title + Accessible.onPressAction: root.activate(index) + } + } + GridView { + id: grid + objectName: "launcherApps" + visible: root.showGrid + anchors.fill: parent + anchors.topMargin: 32 + anchors.leftMargin: 12 + anchors.rightMargin: 12 + anchors.bottomMargin: 10 + clip: true + model: root.showGrid ? root.results : [] + cellWidth: Math.floor(width / root.gridColumns) + cellHeight: 100 + boundsBehavior: Flickable.StopAtBounds + ScrollBar.vertical: ScrollBar {} + delegate: Item { + id: tile + required property var modelData + required property int index + readonly property bool selected: root.selectedIndex === index + width: grid.cellWidth + height: grid.cellHeight + Rectangle { + anchors.fill: parent + anchors.margins: 4 + radius: 14 + color: tile.selected ? Qt.alpha(Theme.accent, 0.35) : tileArea.containsMouse ? Theme.hover : Theme.transparent + border.width: tile.selected ? 1 : 0 + border.color: Theme.accentVivid + } + Column { + anchors.centerIn: parent + spacing: 6 + Image { + id: tileIcon + anchors.horizontalCenter: parent.horizontalCenter + width: 52 + height: 52 + source: ApplicationsService.icon(tile.modelData.entry) + sourceSize: Qt.size(104, 104) + fillMode: Image.PreserveAspectFit + asynchronous: true + Text { + anchors.centerIn: parent + visible: tileIcon.source.toString() === "" || tileIcon.status === Image.Error + text: tile.modelData.title.slice(0, 2).toUpperCase() + color: Theme.textSecondary + font.pixelSize: 18 + } + } + Text { + anchors.horizontalCenter: parent.horizontalCenter + width: grid.cellWidth - 12 + horizontalAlignment: Text.AlignHCenter + text: tile.modelData.title + elide: Text.ElideRight + color: Theme.text + font.pixelSize: 11 + } + } + MouseArea { + id: tileArea + anchors.fill: parent + hoverEnabled: true + onClicked: root.activate(tile.index) + } + Accessible.role: Accessible.Button + Accessible.name: modelData.title + Accessible.onPressAction: root.activate(index) + } + } + GridView { + id: emojiGrid + objectName: "launcherEmoji" + // Name of the emoji under the pointer, shown instead of the selection's. + property string hovered: "" + visible: root.emojiMode + anchors.fill: parent + anchors.topMargin: 32 + anchors.leftMargin: 12 + anchors.rightMargin: 12 + anchors.bottomMargin: 10 + clip: true + model: root.emojiMode ? root.results : [] + cellWidth: Math.floor(width / root.emojiColumns) + cellHeight: root.emojiCell + boundsBehavior: Flickable.StopAtBounds + ScrollBar.vertical: ScrollBar {} + delegate: Item { + id: glyph + required property var modelData + required property int index + readonly property bool selected: root.selectedIndex === index + width: emojiGrid.cellWidth + height: emojiGrid.cellHeight + Rectangle { + anchors.fill: parent + anchors.margins: 3 + radius: 12 + color: glyph.selected ? Qt.alpha(Theme.accent, 0.35) : glyphArea.containsMouse ? Theme.hover : Theme.transparent + border.width: glyph.selected ? 1 : 0 + border.color: Theme.accentVivid + } + Text { + anchors.centerIn: parent + text: glyph.modelData.id + textFormat: Text.PlainText + font.pixelSize: 28 + } + MouseArea { + id: glyphArea + anchors.fill: parent + hoverEnabled: true + onContainsMouseChanged: { + if (containsMouse) + emojiGrid.hovered = glyph.modelData.title; + else if (emojiGrid.hovered === glyph.modelData.title) + emojiGrid.hovered = ""; + } + onClicked: root.activate(glyph.index) + } + Accessible.role: Accessible.Button + Accessible.name: modelData.title + Accessible.onPressAction: root.activate(index) + } + } + Text { + anchors.centerIn: parent + anchors.verticalCenterOffset: 12 + visible: (root.showList || root.emojiMode) && root.results.length === 0 + text: root.emojiMode ? (EmojiService.loaded ? "No matching emoji" : "Loading…") : root.clipboardMode ? (ClipboardService.error || (root.query ? "No matches" : ClipboardService.loaded ? "Clipboard history is empty" : "Loading…")) : root.commandMode ? "No matching settings" : "No results" + color: Theme.textSecondary + font.pixelSize: 13 + } + Text { + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.margins: 12 + visible: !!root.launchError + elide: Text.ElideRight + text: root.launchError + color: Theme.urgent + font.pixelSize: 12 + } + } +} diff --git a/quickshell/launcher/NotchSearch.qml b/quickshell/launcher/NotchSearch.qml deleted file mode 100644 index 34a81c0..0000000 --- a/quickshell/launcher/NotchSearch.qml +++ /dev/null @@ -1,143 +0,0 @@ -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) - } - } - } - } -} diff --git a/quickshell/launcher/qmldir b/quickshell/launcher/qmldir index 0c81257..2d14e9c 100644 --- a/quickshell/launcher/qmldir +++ b/quickshell/launcher/qmldir @@ -3,4 +3,4 @@ singleton LauncherState 1.0 LauncherState.qml AppSearch 1.0 AppSearch.qml CommandSearch 1.0 CommandSearch.qml Launcher 1.0 Launcher.qml -NotchSearch 1.0 NotchSearch.qml +LauncherView 1.0 LauncherView.qml diff --git a/quickshell/notch/NotchPill.qml b/quickshell/notch/NotchPill.qml index 46c4e8b..676e184 100644 --- a/quickshell/notch/NotchPill.qml +++ b/quickshell/notch/NotchPill.qml @@ -10,7 +10,9 @@ import "../theme" // concave ears, showing the time, plus cover art and a small visualizer while // audio plays. Clicking it opens the notch panel. A new notification widens // it: the clock and media keep the left end, the banner takes the right. The -// launcher opens the same way, with the search where the banner would be. +// launcher opens the same way, as one more face of the notch (the pocket-dots +// way): its search sits in the band beside the clock, and the notch grows +// down to fit the results, clipboard history or emoji below it. Item { id: root property var barScreen @@ -26,23 +28,36 @@ Item { if (latest) notice = latest; } - // Wide while the launcher is open here, also under the launcher window - // once a search grows it down. readonly property bool searching: ShellState.notchLauncher && ScreenService.current(ShellState.launcherScreen) === barScreen readonly property bool showing: !!latest && owner && visible && !searching // Holds the last banner while the notch closes around it. property var notice: null readonly property int noticeWidth: 340 - // The launcher window's width, so it can take over at the same size. readonly property int searchWidth: ConfigService.ready ? ConfigService.data.launcher.width : 680 + readonly property real band: BarDrawers.bottom readonly property real bodyWidth: ShellState.notchPillWidth + (searching ? searchWidth : showing ? noticeWidth : 0) + // The launcher's results hang below the band. + readonly property real bodyHeight: band + (searching ? launcher.bodyHeight : 0) + // Tallest the launcher may grow; the bar window reserves this while open. + readonly property real maxBodyHeight: Math.min(460, (barScreen ? barScreen.height : 1080) * 0.6) implicitWidth: bodyWidth + 2 * BarDrawers.ear - implicitHeight: BarDrawers.bottom + implicitHeight: bodyHeight + // Springs, as on pocket-dots: the width arrives quickly and stays, the + // height follows with a little slack, so the notch widens and then drops. + // The notch speed settings stiffen or soften them. + readonly property real springScale: Theme.duration / (searching || showing ? Theme.notchOpenDuration : Theme.notchCloseDuration) Behavior on implicitWidth { - NumberAnimation { - duration: Theme.notchDuration * 1.6 - easing.type: Easing.BezierSpline - easing.bezierCurve: [0.2, 0, 0, 1, 1, 1] + SpringAnimation { + spring: 5.2 * root.springScale + damping: 0.58 + epsilon: 0.25 + } + } + Behavior on implicitHeight { + SpringAnimation { + spring: 3.1 * root.springScale + damping: 0.34 + epsilon: 0.25 } } Demand { @@ -55,14 +70,19 @@ Item { bodyHeight: root.height ear: BarDrawers.ear radius: Math.min(Theme.radius, root.height / 2) - fillColor: Theme.notchFill + fillColor: root.searching ? Theme.notchLauncherFill : Theme.notchFill + Behavior on fillColor { + ColorAnimation { + duration: root.searching ? Theme.notchColorDuration : Math.min(Theme.notchColorDuration, Theme.notchCloseDuration) + } + } } // The pill's own width at the left end; its contents stay centred there. Item { id: lead x: BarDrawers.ear width: ShellState.notchPillWidth - height: root.height + height: root.band } NotchGlance { anchors.centerIn: lead @@ -93,7 +113,7 @@ Item { objectName: "notchNotice" x: lead.x + lead.width width: Math.max(0, root.width - BarDrawers.ear - x) - height: root.height + height: root.band clip: true visible: width > 1 opacity: root.showing ? 1 : 0 @@ -211,31 +231,42 @@ Item { } } Item { - objectName: "notchSearch" - x: lead.x + lead.width - width: Math.max(0, root.width - BarDrawers.ear - x) + objectName: "notchLauncher" + x: BarDrawers.ear + width: Math.max(0, root.width - 2 * BarDrawers.ear) height: root.height clip: true + // Comes in once the notch has started to widen, and leaves first. opacity: root.searching ? 1 : 0 visible: width > 1 && opacity > 0 Behavior on opacity { - NumberAnimation { - duration: root.searching ? Theme.notchDuration * 1.6 : Theme.notchDuration * 0.6 - easing.type: Easing.OutCubic + SequentialAnimation { + PauseAnimation { + duration: root.searching ? Theme.notchOpenDuration * 0.5 : 0 + } + NumberAnimation { + duration: root.searching ? Theme.notchOpenDuration : Theme.notchCloseDuration * 0.5 + easing.type: root.searching ? Easing.OutCubic : Easing.InQuad + } } } Rectangle { - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter + x: ShellState.notchPillWidth + y: root.band * 0.25 width: 1 - height: parent.height * 0.5 + height: root.band * 0.5 color: Theme.hairline } - // Laid out at full width so it does not reflow while the notch grows. - NotchSearch { - width: root.searchWidth - height: parent.height - active: root.searching && ShellState.notchSearch + // Laid out at full size so it does not reflow while the notch grows. + LauncherView { + id: launcher + width: ShellState.notchPillWidth + root.searchWidth + height: Math.max(root.band, parent.height) + notch: true + band: root.band + barInset: ShellState.notchPillWidth + maxBodyHeight: root.maxBodyHeight + active: root.searching } } // 0 (critical) stays until dismissed. Each banner's time counts from its