Round glass pills to the right of the search bar switch the launcher to Clipboard History or the Emoji picker and back, naming themselves in the empty bar on hover. The launcher runtime test now runs without a second notification server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
122 lines
4.6 KiB
QML
122 lines
4.6 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 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");
|
|
return true;
|
|
}
|
|
return CommandRegistry.registerCommand({
|
|
id: "fixture",
|
|
title: "Fixture command",
|
|
description: "Test extension",
|
|
run: () => ShellState.openSettings("about")
|
|
});
|
|
}
|
|
}
|
|
}
|