repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
quickshell/nuguland/features/clipboard/fixtures/services/Clipboard.qml
Rawimport QtQuick
Item {
// Inputs the registry forwards to the production service.
property var surfaces: null
property var niriService: null
property bool privateMode: false
property int copyCount: 0
property int pinCount: 0
property int pasteCount: 0
property int deleteCount: 0
property int externalUpdates: 0
property int vaultPauses: 0
property var lastAction: ({})
signal vaultCapturePaused
property var rows: [
{
"id": "clip-needle",
"title": "needle document",
"kind": "text",
"age": "now",
"icon": "",
"pinned": false,
"isImage": false,
"swatch": ""
},
{
"id": "clip-other",
"title": "other document",
"kind": "text",
"age": "1m",
"icon": "",
"pinned": false,
"isImage": false,
"swatch": ""
}
]
// Adversarial history: what production can hold when a path or id was copied.
property bool machineRows: false
readonly property var machineRowData: [
{
// An image pasted into pi: its temp file is long deleted.
"id": "clip-temp-image",
"title": "/tmp/pi-clipboard-23965d8a-47d6-45ce-9d1a-f83c6b805220.png",
"kind": "image",
"age": "2m",
"icon": "\uF03E",
"pinned": false,
"isImage": true,
// No thumbnail: loading a deleted file only logs a warning; the icon shows instead.
"imagePath": "",
"swatch": ""
},
{
// A prompt whose first line starts with that path.
"id": "clip-temp-prompt",
"title": "/tmp/pi-clipboard-0f4e8a12-9b7c-4d3e-8a6f-1c2d3e4f5a6b.png what is in this picture?",
"kind": "text",
"age": "3m",
"icon": "\uF0F6",
"pinned": false,
"isImage": false,
"swatch": ""
},
{
"id": "clip-file-uri",
"title": "file:///home/test/Documents/report.pdf",
"kind": "path",
"age": "4m",
"icon": "\uF15B",
"pinned": false,
"isImage": false,
"swatch": ""
},
{
"id": "clip-uuid",
"title": "23965d8a-47d6-45ce-9d1a-f83c6b805220",
"kind": "text",
"age": "5m",
"icon": "\uF0F6",
"pinned": false,
"isImage": false,
"swatch": ""
}
]
function setMachineRows(enabled) {
machineRows = !!enabled;
}
function viewRows(query) {
const needle = String(query || "").toLowerCase();
return rows.concat(machineRows ? machineRowData : []).filter(row => needle.length === 0 || String(row.title).toLowerCase().indexOf(needle) >= 0);
}
function copy(id) {
copyCount++;
}
function paste(id) {
pasteCount++;
}
function togglePin(id) {
const wanted = String(id);
rows = rows.map(row => row.id === wanted ? Object.assign({}, row, {
"pinned": !row.pinned
}) : row);
pinCount++;
}
function deleteRow(id) {
const wanted = String(id);
rows = rows.filter(row => row.id !== wanted);
deleteCount++;
}
function setPrivateMode(enabled) {
privateMode = !!enabled;
}
function pauseForVaultCopy(timeoutSeconds) {
vaultPauses++;
vaultCapturePaused();
}
function resumeAfterVaultCopy() {
}
// Fixture surface: the paste progress the production service reports.
function pasteOutcome(pending) {
lastAction = {
"kind": "paste",
"pending": pending,
// An app id, as niri reports it.
"target": pending ? "dev.fixture.Editor" : "",
"error": ""
};
}
function fixtureState() {
return {
"privateMode": privateMode,
"rows": rows.length,
"pinned": rows.filter(row => row.pinned).length,
"copies": copyCount,
"pins": pinCount,
"pastes": pasteCount,
"deletes": deleteCount,
"externalUpdates": externalUpdates
};
}
function externalUpdate() {
externalUpdates++;
rows = rows.concat([
{
"id": `clip-external-${externalUpdates}`,
"title": "needle external update",
"kind": "text",
"age": "now",
"icon": "",
"pinned": false,
"isImage": false,
"swatch": ""
}
]);
}
}