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
|
from: 3
|
||||||
to: 100
|
to: 100
|
||||||
stepSize: 1
|
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 {
|
PC3.Label {
|
||||||
@@ -109,8 +120,19 @@ ColumnLayout {
|
|||||||
from: 143
|
from: 143
|
||||||
to: 344
|
to: 344
|
||||||
stepSize: 1
|
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 {
|
PC3.Label {
|
||||||
|
|||||||
@@ -24,23 +24,36 @@ PlasmoidItem {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try reading shared CLI config
|
// Try reading shared CLI config via local file XHR
|
||||||
var xhr = new XMLHttpRequest()
|
var homePath = Qt.resolvedUrl("file://" + "/home/" + Qt.application.arguments[0]).toString()
|
||||||
var configPath = StandardPaths.writableLocation(StandardPaths.GenericConfigLocation) + "/../elgato-cli/config.json"
|
// Use direct path since StandardPaths may not be available
|
||||||
// Use home dir approach
|
var configPaths = [
|
||||||
try {
|
"file:///home/faye/.config/elgato-cli/config.json",
|
||||||
xhr.open("GET", "file://" + StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.config/elgato-cli/config.json", false)
|
"file://" + (typeof StandardPaths !== 'undefined' ?
|
||||||
xhr.send()
|
StandardPaths.writableLocation(StandardPaths.HomeLocation) :
|
||||||
if (xhr.status === 200 || xhr.readyState === XMLHttpRequest.DONE) {
|
"/home/faye") + "/.config/elgato-cli/config.json"
|
||||||
var config = JSON.parse(xhr.responseText)
|
]
|
||||||
if (config.host) {
|
|
||||||
root.lightHost = config.host
|
for (var i = 0; i < configPaths.length; i++) {
|
||||||
root.lightPort = config.port || 9123
|
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() {
|
function baseUrl() {
|
||||||
|
|||||||
Reference in New Issue
Block a user