Fully disable CliphistService when Clipboard is disabled
This commit is contained in:
parent
2ee9e91169
commit
33765861fe
1 changed files with 25 additions and 4 deletions
|
|
@ -12,6 +12,7 @@ Singleton {
|
||||||
// Public API
|
// Public API
|
||||||
property var items: [] // [{id, preview, mime, isImage}]
|
property var items: [] // [{id, preview, mime, isImage}]
|
||||||
property bool loading: false
|
property bool loading: false
|
||||||
|
property bool enabled: Settings.data.appLauncher.enableClipboardHistory
|
||||||
|
|
||||||
// Optional automatic watchers to feed cliphist DB
|
// Optional automatic watchers to feed cliphist DB
|
||||||
property bool autoWatch: true
|
property bool autoWatch: true
|
||||||
|
|
@ -30,14 +31,26 @@ Singleton {
|
||||||
property string _b64CurrentMime: ""
|
property string _b64CurrentMime: ""
|
||||||
property string _b64CurrentId: ""
|
property string _b64CurrentId: ""
|
||||||
|
|
||||||
// Start watchers when the singleton loads
|
// Start/stop watchers when enabled changes
|
||||||
Component.onCompleted: startWatchers()
|
Component.onCompleted: {
|
||||||
|
if (root.enabled) startWatchers()
|
||||||
|
}
|
||||||
|
onEnabledChanged: {
|
||||||
|
if (root.enabled) {
|
||||||
|
startWatchers()
|
||||||
|
} else {
|
||||||
|
stopWatchers()
|
||||||
|
loading = false
|
||||||
|
// Optional: clear items to avoid stale UI
|
||||||
|
items = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fallback: periodically refresh list so UI updates even if not in clip mode
|
// Fallback: periodically refresh list so UI updates even if not in clip mode
|
||||||
Timer {
|
Timer {
|
||||||
interval: 5000
|
interval: 5000
|
||||||
repeat: true
|
repeat: true
|
||||||
running: true
|
running: root.enabled
|
||||||
onTriggered: list()
|
onTriggered: list()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,7 +147,7 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function startWatchers() {
|
function startWatchers() {
|
||||||
if (!autoWatch || watchersStarted) return
|
if (!root.enabled || !autoWatch || watchersStarted) return
|
||||||
watchersStarted = true
|
watchersStarted = true
|
||||||
// Start text watcher
|
// Start text watcher
|
||||||
watchText.command = ["wl-paste", "--type", "text", "--watch", "cliphist", "store"]
|
watchText.command = ["wl-paste", "--type", "text", "--watch", "cliphist", "store"]
|
||||||
|
|
@ -144,7 +157,15 @@ Singleton {
|
||||||
watchImage.running = true
|
watchImage.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stopWatchers() {
|
||||||
|
if (!watchersStarted) return
|
||||||
|
watchText.running = false
|
||||||
|
watchImage.running = false
|
||||||
|
watchersStarted = false
|
||||||
|
}
|
||||||
|
|
||||||
function list(maxPreviewWidth) {
|
function list(maxPreviewWidth) {
|
||||||
|
if (!root.enabled) { return }
|
||||||
if (listProc.running) return
|
if (listProc.running) return
|
||||||
loading = true
|
loading = true
|
||||||
const width = maxPreviewWidth || 100
|
const width = maxPreviewWidth || 100
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue