import QtQuick import Quickshell import Quickshell.Io import "../../../features/notifications" as NotificationFeature import "../../.." as N Scope { id: root readonly property string sample: "-fixture π\n" + "notification ".repeat(4000) + "end\n" property string received: "" property int notices: 0 Component.onCompleted: { const server = Array.from(service.data).find(x => x.trackedNotifications !== undefined); server.notification.connect(() => root.notices++); } N.Theme { id: nuguTheme } NotificationFeature.NotificationToasts { theme: nuguTheme notificationService: service primaryScreenName: Quickshell.screens.length > 0 ? Quickshell.screens[0].name : "" } NotificationFeature.Notifications { id: service } Process { id: reader command: ["wl-paste", "--no-newline"] stdout: StdioCollector { onStreamFinished: root.received = text } } IpcHandler { target: "uiTest" function snapshot(): string { return JSON.stringify({ notices: root.notices }); } function facts(): string { const server = Array.from(service.data).find(x => x.trackedNotifications !== undefined); return JSON.stringify({ state: service.stateObject(), native: Array.from(server.trackedNotifications.values).map(n => ({ id: n.id, resident: n.resident })) }); } function intent(name: string, id: string): void { if (name === "dnd") service.toggleDnd(); if (name === "toast") service.dismissToast(id); if (name === "expire") service.expireToast(id); if (name === "all") service.discardAllNotifications(); if (name === "close") service.runAction(id, "close"); if (name === "action") service.runAction(id, "default"); if (name === "reply") service.sendReply(id, "synthetic reply"); if (name === "read") service.markAllRead(); } function copy(): void { service.notifications = [ { id: "fixture", body: root.sample } ]; service.runAction("fixture", "copy-body"); } function read(): void { root.received = ""; reader.running = true; } function result(): string { return JSON.stringify({ matches: root.received === root.sample, length: root.received.length }); } } }