From 337fdf13dc53f1d510e8b703f3d4e11674581849 Mon Sep 17 00:00:00 2001 From: Tina Schellander Date: Sat, 7 Feb 2026 11:44:14 +0100 Subject: [PATCH] Fix plasmoid slider dragging and config loading - Use conditional Binding to sync slider values only when not dragging - Send value to light once on release instead of every pixel - Improve shared config file loading with multiple path fallbacks --- .../contents/ui/FullRepresentation.qml | 30 ++++++++++++-- .../at.sub-net.elgato/contents/ui/main.qml | 41 ++++++++++++------- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/plasmoid/at.sub-net.elgato/contents/ui/FullRepresentation.qml b/plasmoid/at.sub-net.elgato/contents/ui/FullRepresentation.qml index 1c08899..f97364c 100644 --- a/plasmoid/at.sub-net.elgato/contents/ui/FullRepresentation.qml +++ b/plasmoid/at.sub-net.elgato/contents/ui/FullRepresentation.qml @@ -82,8 +82,19 @@ ColumnLayout { from: 3 to: 100 stepSize: 1 - value: root.lightBrightness - onMoved: root.setBrightness(Math.round(value)) + + // Sync from light state only when not dragging + Binding on value { + value: root.lightBrightness + when: !brightnessSlider.pressed + } + + onPressedChanged: { + if (!pressed) { + // Send final value on release + root.setBrightness(Math.round(value)) + } + } } PC3.Label { @@ -109,8 +120,19 @@ ColumnLayout { from: 143 to: 344 stepSize: 1 - value: root.lightTemperature - onMoved: root.setTemperature(Math.round(value)) + + // Sync from light state only when not dragging + Binding on value { + value: root.lightTemperature + when: !temperatureSlider.pressed + } + + onPressedChanged: { + if (!pressed) { + // Send final value on release + root.setTemperature(Math.round(value)) + } + } } PC3.Label { diff --git a/plasmoid/at.sub-net.elgato/contents/ui/main.qml b/plasmoid/at.sub-net.elgato/contents/ui/main.qml index fd41c63..68c5160 100644 --- a/plasmoid/at.sub-net.elgato/contents/ui/main.qml +++ b/plasmoid/at.sub-net.elgato/contents/ui/main.qml @@ -24,23 +24,36 @@ PlasmoidItem { return } - // Try reading shared CLI config - var xhr = new XMLHttpRequest() - var configPath = StandardPaths.writableLocation(StandardPaths.GenericConfigLocation) + "/../elgato-cli/config.json" - // Use home dir approach - try { - xhr.open("GET", "file://" + StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.config/elgato-cli/config.json", false) - xhr.send() - if (xhr.status === 200 || xhr.readyState === XMLHttpRequest.DONE) { - var config = JSON.parse(xhr.responseText) - if (config.host) { - root.lightHost = config.host - root.lightPort = config.port || 9123 + // Try reading shared CLI config via local file XHR + var homePath = Qt.resolvedUrl("file://" + "/home/" + Qt.application.arguments[0]).toString() + // Use direct path since StandardPaths may not be available + var configPaths = [ + "file:///home/faye/.config/elgato-cli/config.json", + "file://" + (typeof StandardPaths !== 'undefined' ? + StandardPaths.writableLocation(StandardPaths.HomeLocation) : + "/home/faye") + "/.config/elgato-cli/config.json" + ] + + for (var i = 0; i < configPaths.length; i++) { + try { + var xhr = new XMLHttpRequest() + xhr.open("GET", configPaths[i], false) + xhr.send() + if (xhr.responseText && xhr.responseText.length > 0) { + var config = JSON.parse(xhr.responseText) + if (config.host) { + root.lightHost = config.host + root.lightPort = config.port || 9123 + console.log("Elgato: loaded config from", configPaths[i], + "host:", config.host) + return + } } + } catch (e) { + console.log("Elgato: Could not read config from", configPaths[i], e) } - } catch (e) { - console.log("Elgato: Could not read shared config:", e) } + console.log("Elgato: No config found, use widget settings or run 'elgato discover'") } function baseUrl() {