diff --git a/qml/Main.qml b/qml/Main.qml index 6f2ea19..8e47fb9 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -44,11 +44,15 @@ ApplicationWindow { const savedOutputs = JSON.parse(appSettings.savedOutputDevices) for (let output of savedOutputs) { createOutputDevice(output.name, output.host, output.port, output.type) - // Restore active state after creation + // Restore active state and source index offset after creation + const lastIdx = outputDevices.length - 1 + if (output.sourceIndexOffset) { + outputDevices[lastIdx].sourceIndexOffset = output.sourceIndexOffset + } if (output.active === false) { - outputDevices[outputDevices.length - 1].active = false - updateOutputList() + outputDevices[lastIdx].active = false } + updateOutputList() } } catch (e) { console.log("Could not restore saved outputs:", e) @@ -57,7 +61,7 @@ ApplicationWindow { function saveOutputDevices() { const toSave = outputDevices.map(function(d) { - return { name: d.name, host: d.host, port: d.port, type: d.type, active: d.active } + return { name: d.name, host: d.host, port: d.port, type: d.type, active: d.active, sourceIndexOffset: d.sourceIndexOffset || 0 } }) appSettings.savedOutputDevices = JSON.stringify(toSave) } @@ -109,7 +113,7 @@ ApplicationWindow { // Route to all active outputs for (let output of outputDevices) { if (output.active) { - const mapped = mapControlGRISMessage(command, sourceIndex, value, output.type) + const mapped = mapControlGRISMessage(command, sourceIndex + (output.sourceIndexOffset || 0), value, output.type) if (mapped && mapped.length > 0) { // Send each mapped message to output device for (let msg of mapped) { @@ -428,7 +432,8 @@ ApplicationWindow { host: host, port: port, type: type, - active: true + active: true, + sourceIndexOffset: 0 }) updateOutputList() @@ -769,7 +774,34 @@ ApplicationWindow { elide: Text.ElideRight font.pixelSize: Math.min(11, window.height * 0.018) } - + + Label { + text: "Offset:" + color: "#aaaaaa" + font.pixelSize: Math.min(11, window.height * 0.018) + } + + TextField { + Layout.preferredWidth: 50 + Layout.preferredHeight: 25 + text: model.sourceIndexOffset !== undefined ? model.sourceIndexOffset : "0" + color: acceptableInput ? "#ffffff" : "#f00" + font.pixelSize: Math.min(11, window.height * 0.018) + horizontalAlignment: Text.AlignHCenter + validator: IntValidator { bottom: 0; top: 9999; } + + background: Rectangle { + color: "#2a2a2a" + border.color: parent.focus ? "#5a5a5a" : "#4a4a4a" + radius: 2 + } + + onTextEdited: { + outputDevices[index].sourceIndexOffset = parseInt(text) || 0 + saveOutputDevices() + } + } + Button { Layout.preferredWidth: Math.max(60, Math.min(80, window.width * 0.08)) Layout.preferredHeight: 25