The launcher gains an emoji mode like Clipboard History: >emoji switches in place without closing or animating, and glassmxrph emoji toggles it. Emoji show as a grid instead of named rows; the selected or hovered emoji's name is the section label. Search requires every term and ranks name matches before keyword matches; Enter copies with wl-copy. assets/emoji.tsv comes from Unicode 17 emoji-test.txt without skin-tone variants, with keywords from the rofi emopicker list (scripts/emoji-data). The test driver caps snapshot results, since IPC replies have a size limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
112 lines
4.1 KiB
QML
112 lines
4.1 KiB
QML
import QtQuick
|
|
import QtTest
|
|
import Quickshell.Io
|
|
import "../launcher"
|
|
import "../core"
|
|
import "../theme"
|
|
|
|
Item {
|
|
id: root
|
|
parent: LauncherState.window ? LauncherState.window.contentItem : null
|
|
function search() {
|
|
return input.findChild(LauncherState.window.contentItem, "launcherSearch");
|
|
}
|
|
TestCase {
|
|
id: input
|
|
name: "LauncherInputDriver"
|
|
when: false
|
|
}
|
|
// The panel grows to fit results; wait for it to settle before pointing.
|
|
function settle(): void {
|
|
const panel = input.findChild(LauncherState.window.contentItem, "launcherSurface");
|
|
let last = -1;
|
|
for (let i = 0; i < 40 && panel.height !== last; i++) {
|
|
last = panel.height;
|
|
input.wait(Math.max(50, Theme.duration / 2));
|
|
}
|
|
}
|
|
IpcHandler {
|
|
target: "launcherTest"
|
|
function query(text: string): void {
|
|
const field = root.search();
|
|
field.text = text;
|
|
field.forceActiveFocus();
|
|
}
|
|
function key(key: int): void {
|
|
input.keyClick(key);
|
|
}
|
|
function typeAscii(text: string): void {
|
|
for (let i = 0; i < text.length; i++)
|
|
input.keyClick(text.charAt(i).toUpperCase().charCodeAt(0));
|
|
}
|
|
function snapshot(): string {
|
|
const w = LauncherState.window, panel = input.findChild(w.contentItem, "launcherSurface");
|
|
return JSON.stringify({
|
|
activeMonitor: ScreenService.active ? ScreenService.active.name : "",
|
|
opened: ShellState.launcherOpen,
|
|
mode: ShellState.launcherMode,
|
|
screen: w.screen.name,
|
|
screenWidth: w.width,
|
|
screenHeight: w.height,
|
|
x: panel.x,
|
|
y: panel.y,
|
|
width: panel.width,
|
|
height: panel.height,
|
|
visible: w.visible,
|
|
query: root.search().text,
|
|
focused: root.search().activeFocus,
|
|
selected: w.selectedIndex,
|
|
// IPC replies have a size limit; the emoji grid holds ~1900 results.
|
|
resultCount: w.results.length,
|
|
results: w.results.slice(0, 200).map(r => ({
|
|
id: r.id,
|
|
title: r.title,
|
|
command: !!r.command,
|
|
image: !!(r.clip && r.clip.image)
|
|
})),
|
|
error: w.launchError
|
|
});
|
|
}
|
|
function click(index: int): bool {
|
|
root.settle();
|
|
const list = input.findChild(LauncherState.window.contentItem, "launcherResults");
|
|
list.positionViewAtIndex(index, ListView.Contain);
|
|
const row = list.itemAtIndex(index);
|
|
if (!row)
|
|
return false;
|
|
input.mouseClick(row, row.width / 2, row.height / 2);
|
|
return true;
|
|
}
|
|
function hover(index: int): bool {
|
|
root.settle();
|
|
const list = input.findChild(LauncherState.window.contentItem, "launcherResults");
|
|
const row = list.itemAtIndex(index);
|
|
if (!row)
|
|
return false;
|
|
input.mouseMove(row, row.width / 2, row.height / 2);
|
|
return true;
|
|
}
|
|
function outside(): void {
|
|
input.mouseClick(LauncherState.window.contentItem, 5, 5);
|
|
}
|
|
function browse(): void {
|
|
LauncherState.window.toggleBrowse();
|
|
}
|
|
function screenshot(path: string): bool {
|
|
return input.findChild(LauncherState.window.contentItem, "launcherSurface").grabToImage(result => result.saveToFile(path));
|
|
}
|
|
function extension(add: bool): bool {
|
|
if (!add) {
|
|
CommandRegistry.unregisterCommand("fixture");
|
|
return true;
|
|
}
|
|
return CommandRegistry.registerCommand({
|
|
id: "fixture",
|
|
title: "Fixture command",
|
|
description: "Test extension",
|
|
run: () => ShellState.openSettings("about")
|
|
});
|
|
}
|
|
}
|
|
}
|