From e20c465cd276c2c80c253f1b4c201c8e56f1e980 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Thu, 14 Aug 2025 16:15:32 +0800 Subject: perf: delayed heavy processing seems stupid but it actually allows the UI thread to get priority and render first, giving a more smooth expereince --- services/Clip.qml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'services') diff --git a/services/Clip.qml b/services/Clip.qml index 1bf78d0..b83c6d8 100644 --- a/services/Clip.qml +++ b/services/Clip.qml @@ -87,8 +87,15 @@ Searchable { running: true command: ["cliphist", "-preview-width", 9 ** 9, "-max-items", 9 ** 9, "list"] stdout: StdioCollector { + property bool pending: false onStreamFinished: () => { - _clipHist = this.text.split(/\r?\n/); + pending = true; + Qt.callLater(() => { + if (pending) { + pending = false; + _clipHist = this.text.split(/\r?\n/); + } + }); } } } @@ -98,8 +105,15 @@ Searchable { running: true command: ["sh", Quickshell.shellDir + "/utils/cliphist-img.sh"] stdout: StdioCollector { + property bool pending: false onStreamFinished: () => { - _clipImg = this.text.split(/\r?\n/); + pending = true; + Qt.callLater(() => { + if (pending) { + pending = false; + _clipImg = this.text.split(/\r?\n/); + } + }); } } } @@ -122,7 +136,6 @@ Searchable { stdout: SplitParser { onRead: line => { - console.log('h'); _update(); } } -- cgit v1.2.3