From 588d78a19cac279b240588f47c26442d5abf3a12 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 23 Oct 2026 17:54:25 +0200 Subject: companion: editable per-app lines in a settings page Her per-app lines were hardcoded in Lines.js under app:. They now live in Prefs.companionApps once edited and fall back to Lines.js until then, read live by Companion.qml so a save needs no restart. The new Companion phrases page does full CRUD on apps and their phrases, with a draft, SaveBar and Reset to the built-in set, mirroring Ask presets. Companion settings move out of Desktop into their own Companion group. --- desktop/Prefs.qml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'desktop/Prefs.qml') diff --git a/desktop/Prefs.qml b/desktop/Prefs.qml index 80515a4..f7e841b 100644 --- a/desktop/Prefs.qml +++ b/desktop/Prefs.qml @@ -75,6 +75,21 @@ Singleton { root.write(Object.assign({}, root.doc, { companionBlushFile: p })); } + // The companion's app lines as saved: a map of lowercased window class + // to phrases, or null for the defaults in companion/Lines.js. The + // Companion phrases page edits it. + property var companionApps: null + function setCompanionApps(map) { + root.companionApps = map; + root.write(Object.assign({}, root.doc, { companionApps: map })); + } + function resetCompanionApps() { + root.companionApps = null; + const d = Object.assign({}, root.doc); + delete d.companionApps; + root.write(d); + } + // The settings window's sidebar width, dragged by its edge. readonly property int sidebarMin: 160 readonly property int sidebarMax: 420 @@ -137,6 +152,8 @@ Singleton { const sk = parsed.companionSkirtless; root.companionSkirtless = Number.isInteger(sk) && sk >= 0 ? sk : 60; root.companionBlushFile = typeof parsed.companionBlushFile === "string" ? parsed.companionBlushFile : ""; + const ca = parsed.companionApps; + root.companionApps = ca && typeof ca === "object" && !Array.isArray(ca) ? ca : null; root.ready = true; } @@ -152,6 +169,6 @@ Singleton { onFileChanged: reload() onLoaded: root.reparse() // Missing file: the defaults, and nothing written. - onLoadFailed: { root.doc = {}; root.pinnedIp = ""; root.presets = null; root.settingsSidebar = 200; root.assistantModel = ""; root.companion = true; root.companionBlushFile = ""; root.companionSkirtless = 60; root.ready = true; } + onLoadFailed: { root.doc = {}; root.pinnedIp = ""; root.presets = null; root.settingsSidebar = 200; root.assistantModel = ""; root.companion = true; root.companionBlushFile = ""; root.companionSkirtless = 60; root.companionApps = null; root.ready = true; } } } -- cgit v1.2.3