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
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user