Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -428,7 +432,8 @@ ApplicationWindow {
host: host,
port: port,
type: type,
active: true
active: true,
sourceIndexOffset: 0
})

updateOutputList()
Expand Down Expand Up @@ -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
Expand Down
Loading