pragma Singleton import QtQuick import Quickshell // Clipboard history from cliphist, for the launcher's clipboard mode. The // list is read only while the launcher opens; the last result stays cached so // switching into clipboard mode shows entries immediately. Singleton { id: root // Newest first: {id, text, image?, thumb?}. property var entries: [] property string error: "" property bool loaded: false readonly property bool loading: lister.running function refresh() { lister.start({ op: "list" }); } // Space-separated terms, all required; recency order is kept like rofi. function filter(query) { const terms = query.toLowerCase().split(/\s+/).filter(t => t); if (!terms.length) return entries; return entries.filter(e => { const text = e.text.toLowerCase(); return terms.every(t => text.includes(t)); }); } function copy(entry) { return entry && actions.start({ op: "copy", id: entry.id }); } function remove(entry) { if (!entry) return false; // Optimistic: the row leaves at once; the helper returns the new list. entries = entries.filter(e => e.id !== entry.id); return actions.start({ op: "delete", id: entry.id }); } ProviderJob { id: lister helper: "helpers/clipboard.py" onFinished: (request, result) => root.apply(result) } ProviderJob { id: actions helper: "helpers/clipboard.py" onFinished: (request, result) => root.apply(result) } function apply(result) { if (!result.ok) { error = result.error || "Clipboard history is unavailable"; return; } error = ""; if (result.entries) { entries = result.entries; loaded = true; } } }