diff --git a/quickshell/launcher/Launcher.qml b/quickshell/launcher/Launcher.qml index d8bb179..9f43497 100644 --- a/quickshell/launcher/Launcher.qml +++ b/quickshell/launcher/Launcher.qml @@ -69,7 +69,12 @@ PanelWindow { readonly property var results: clipboardMode ? clipboardResults : emojiMode ? emojiResults : showList ? (commandMode ? commands.results : apps.results) : showGrid ? allApps : [] property int selectedIndex: 0 property string launchError: "" - readonly property real targetWidth: Math.min(options.width, root.width - 40) + // 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, root.width - 40 - 2 * pillsWidth) + // A hovered mode pill names itself in the empty search bar. + property string pillHover: "" readonly property int barHeight: 60 readonly property real maxBodyHeight: Math.min(460, root.height * 0.78 - barHeight - (root.height * 0.22)) // Clipboard mode shows the latest five rows; the rest scroll. @@ -182,6 +187,75 @@ PanelWindow { anchors.fill: parent onClicked: ShellState.launcherOpen = false } + // Mode pills beside the search bar (macOS Spotlight style): each toggles + // its launcher mode; the active one is filled. + Row { + id: pills + objectName: "launcherPills" + x: panel.x + panel.width + 10 + y: panel.y + (root.barHeight - root.pillSize) / 2 + spacing: 10 + opacity: panel.opacity + scale: panel.scale + Repeater { + model: [ + { + mode: "clipboard", + label: "Clipboard", + glyph: "󰅌", + fallback: "⎘" + }, + { + mode: "emoji", + label: "Emoji", + glyph: "󰞅", + fallback: "☺" + } + ] + GlassPanel { + id: pill + required property var modelData + readonly property bool active: ShellState.launcherMode === modelData.mode + objectName: "launcherPill-" + modelData.mode + width: root.pillSize + height: root.pillSize + radius: width / 2 + color: active ? Theme.accent : Qt.alpha(Theme.surface, Math.min(1, surfaceOpacity + (pillArea.containsMouse ? 0.18 : 0))) + 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: 21 + 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: { + ShellState.launcherMode = pill.active ? "apps" : pill.modelData.mode; + search.forceActiveFocus(); + } + } + } + } + } GlassPanel { id: panel objectName: "launcherSurface" @@ -269,7 +343,7 @@ PanelWindow { objectName: "launcherSearch" Layout.fillWidth: true Layout.preferredHeight: 40 - placeholderText: root.clipboardMode ? "Clipboard History" : root.emojiMode ? "Search emoji" : root.browsing ? "Search applications" : "Search :3" + 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 diff --git a/quickshell/testing/LauncherDriver.qml b/quickshell/testing/LauncherDriver.qml index d113217..f87596a 100644 --- a/quickshell/testing/LauncherDriver.qml +++ b/quickshell/testing/LauncherDriver.qml @@ -92,9 +92,19 @@ Item { function browse(): void { LauncherState.window.toggleBrowse(); } + function pill(mode: string): bool { + const item = input.findChild(LauncherState.window.contentItem, "launcherPill-" + mode); + if (!item || !item.visible) + return false; + input.mouseClick(item, item.width / 2, item.height / 2); + return true; + } function screenshot(path: string): bool { return input.findChild(LauncherState.window.contentItem, "launcherSurface").grabToImage(result => result.saveToFile(path)); } + function pillsShot(path: string): bool { + return input.findChild(LauncherState.window.contentItem, "launcherPills").grabToImage(result => result.saveToFile(path)); + } function extension(add: bool): bool { if (!add) { CommandRegistry.unregisterCommand("fixture"); diff --git a/tests/launcher_runtime.py b/tests/launcher_runtime.py index 3b7367b..ab3d2ca 100644 --- a/tests/launcher_runtime.py +++ b/tests/launcher_runtime.py @@ -61,7 +61,8 @@ Terminal={'true' if suffix=='Terminal' else 'false'} ''') cfg=temp/'config/glassMxrph/config.json';cfg.parent.mkdir(parents=True) # Hermetic: never scan the user's wallpaper folders (and their image formats). - cfg.write_text(json.dumps({'schemaVersion':3,'dock':{'enabled':False},'wallpaper':{'directories':[str(temp)]}})) + # The user's live shell owns the notification bus name; a second server would warn. + cfg.write_text(json.dumps({'schemaVersion':3,'dock':{'enabled':False},'notifications':{'enabled':False},'wallpaper':{'directories':[str(temp)]}})) env=dict(os.environ,XDG_CONFIG_HOME=tmp+'/config',XDG_STATE_HOME=tmp+'/state',XDG_DATA_HOME=tmp+'/data',GLASSMXRPH_LAUNCHER_TESTING='1',QT_QPA_PLATFORMTHEME='',QT_NO_XDG_DESKTOP_PORTAL='1') shell=None try: @@ -114,6 +115,13 @@ Terminal={'true' if suffix=='Terminal' else 'false'} open_launcher();query('>') eventually(lambda:{r['id'] for r in snapshot()['results']}=={'about','appearance','audio','bar','tray','bluetooth','controlcenter','display','dock','launcher','media','metrics','network','notifications','power','wallpaper','widgets','osd','lock','dashboard','plugins','clipboard','emoji'},'all commands registered') time.sleep(.3);assert ipc('launcherTest','screenshot',str(ROOT/'.cache/launcher-preview.png')) + # Mode pills beside the bar switch to clipboard or emoji and back. + assert ipc('launcherTest','pill','clipboard');eventually(lambda:snapshot()['mode']=='clipboard','clipboard pill') + assert ipc('launcherTest','pill','clipboard');eventually(lambda:snapshot()['mode']=='apps','clipboard pill toggles back') + assert ipc('launcherTest','pill','emoji');eventually(lambda:snapshot()['mode']=='emoji' and snapshot()['opened'],'emoji pill') + time.sleep(.4);assert ipc('launcherTest','screenshot',str(ROOT/'.cache/launcher-emoji.png'));assert ipc('launcherTest','pillsShot',str(ROOT/'.cache/launcher-pills.png')) + assert ipc('launcherTest','pill','emoji');eventually(lambda:snapshot()['mode']=='apps','emoji pill toggles back') + query('>') for text,page in [('>metrics','metrics'),('>dock','dock'),('>media','media'),('>tray','tray'),('>display','displays'),('>launcher','launcher'),('>appearance','appearance'),('>bar','bar'),('>network','network'),('>bluetooth','bluetooth'),('>audio','audio'),('>controlcenter','controlcenter'),('>notifications','notifications'),('>power','power'),('>about','about')]: query(text) ipc('launcherTest','key',ENTER)