Skip to content

Commit

Permalink
qmlui: implement custom feedback configuration dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Nov 16, 2024
1 parent 6049716 commit b23b6af
Show file tree
Hide file tree
Showing 9 changed files with 645 additions and 132 deletions.
99 changes: 39 additions & 60 deletions qmlui/qml/ExternalControlDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ import "."

Column
{
id: itemRoot
width: parent.width

property var dObjRef: null
property var widgetObjRef: null
property bool invalid: false
property int controlID
property alias inputModel: controlsCombo.model
Expand All @@ -36,8 +37,8 @@ Column
property string uniName
property string chName
property bool customFeedback: false
property int lowerFb: 0
property int upperFb: 255

signal requestCustomFeedbackPopup()

GridLayout
{
Expand All @@ -52,57 +53,35 @@ Column
height: UISettings.listItemHeight
label: qsTr("Control")
}

CustomComboBox
{
id: controlsCombo
Layout.fillWidth: true
Layout.columnSpan: 2
height: UISettings.listItemHeight
currValue: controlID
onValueChanged:
{
controlID = value
dObjRef.updateInputSourceControlID(universe, channel, controlID)
widgetObjRef.updateInputSourceControlID(universe, channel, controlID)
}
}

// row 2
RobotoText
{
height: UISettings.listItemHeight
label: qsTr("Universe")
}
RobotoText
{
id: uniNameBox
Layout.fillWidth: true
height: UISettings.listItemHeight
color: UISettings.bgLight
label: uniName

SequentialAnimation on color
{
PropertyAnimation { to: "red"; duration: 1000 }
PropertyAnimation { to: UISettings.bgLight; duration: 1000 }
running: invalid
loops: Animation.Infinite
}
}
IconButton
{
width: UISettings.iconSizeMedium
height: width
checkable: true
checked: invalid
imgSource: "qrc:/inputoutput.svg"
imgSource: "qrc:/wizard.svg"
tooltip: qsTr("Activate auto detection")

onToggled:
{
if (checked == true)
{
if (invalid === false &&
virtualConsole.enableInputSourceAutoDetection(dObjRef, controlID, universe, channel) === true)
virtualConsole.enableInputSourceAutoDetection(widgetObjRef, controlID, universe, channel) === true)
invalid = true
else
checked = false
Expand All @@ -117,19 +96,20 @@ Column
}
}

// row 3
// row 2
RobotoText
{
height: UISettings.listItemHeight
label: qsTr("Channel")
label: qsTr("Universe")
}

RobotoText
{
id: chNameBox
id: uniNameBox
Layout.fillWidth: true
height: UISettings.listItemHeight
color: UISettings.bgLight
label: chName
label: uniName

SequentialAnimation on color
{
Expand All @@ -139,53 +119,52 @@ Column
loops: Animation.Infinite
}
}

IconButton
{
width: UISettings.iconSizeMedium
height: width
imgSource: "qrc:/remove.svg"
tooltip: qsTr("Remove this input source")

onClicked: virtualConsole.deleteInputSource(dObjRef, controlID, universe, channel)
onClicked: virtualConsole.deleteInputSource(widgetObjRef, controlID, universe, channel)
}

// row 3
RobotoText
{
Layout.columnSpan: 3
Layout.fillWidth: true
height: UISettings.listItemHeight
visible: customFeedback
label: qsTr("Custom feedback")
color: UISettings.bgMedium
label: qsTr("Channel")
}

Row
RobotoText
{
id: cfRow
Layout.columnSpan: 3
id: chNameBox
Layout.fillWidth: true
spacing: 5
visible: customFeedback
height: UISettings.listItemHeight
color: UISettings.bgLight
label: chName

RobotoText { id: cfLower; height: UISettings.listItemHeight; label: qsTr("Lower") }
CustomSpinBox
SequentialAnimation on color
{
id: lowerSpin
width: (cfRow.width - cfLower.width - cfUpper.width - 20) / 2
from: 0
to: 255
value: lowerFb
onValueChanged: if (dObjRef) dObjRef.updateInputSourceRange(universe, channel, value, upperSpin.value)
PropertyAnimation { to: "red"; duration: 1000 }
PropertyAnimation { to: UISettings.bgLight; duration: 1000 }
running: invalid
loops: Animation.Infinite
}
RobotoText { id: cfUpper; height: UISettings.listItemHeight; label: qsTr("Upper") }
CustomSpinBox
}

IconButton
{
visible: customFeedback
width: UISettings.iconSizeMedium
height: width
imgSource: "qrc:/inputoutput.svg"
tooltip: qsTr("Custom feedback selection")

onClicked:
{
id: upperSpin
width: (cfRow.width - cfLower.width - cfUpper.width - 20) / 2
from: 0
to: 255
value: upperFb
onValueChanged: if (dObjRef) dObjRef.updateInputSourceRange(universe, channel, lowerSpin.value, value)
itemRoot.requestCustomFeedbackPopup()
}
}
} // end of GridLayout
Expand Down
22 changes: 19 additions & 3 deletions qmlui/qml/ExternalControls.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ Column
* an input sources list */
property var objRef: null

PopupCustomFeedback
{
id: cfbPopup
}

Rectangle
{
color: UISettings.bgMedium
Expand Down Expand Up @@ -134,11 +139,12 @@ Column
delegate:
Loader
{
id: extSrcListLoader
width: sourcesListView.width
source: modelData.type === VCWidget.Controller ? "qrc:/ExternalControlDelegate.qml" : "qrc:/KeyboardSequenceDelegate.qml"
onLoaded:
{
item.dObjRef = objRef
item.widgetObjRef = objRef
item.inputModel = objRef.externalControlsList
item.controlID = modelData.id

Expand All @@ -152,14 +158,24 @@ Column
item.uniName = modelData.uniString
item.chName = modelData.chString
item.customFeedback = modelData.customFeedback
item.lowerFb = modelData.lower
item.upperFb = modelData.upper
}
else if (modelData.type === VCWidget.Keyboard)
{
item.sequence = modelData.keySequence
}
}

Connections
{
target: extSrcListLoader.item
function onRequestCustomFeedbackPopup()
{
cfbPopup.widgetObjRef = item.widgetObjRef
cfbPopup.universe = item.universe
cfbPopup.channel = item.channel
cfbPopup.open()
}
}
}
}
}
10 changes: 5 additions & 5 deletions qmlui/qml/KeyboardSequenceDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Column
{
width: parent.width

property var dObjRef: null
property var widgetObjRef: null
property int controlID
property alias inputModel: controlsCombo.model
property string sequence
Expand All @@ -54,11 +54,11 @@ Column
currValue: controlID
onValueChanged:
{
if (dObjRef && value != controlID)
if (widgetObjRef && value != controlID)
{
console.log("Key control changed " + value)
controlID = value
virtualConsole.updateKeySequenceControlID(dObjRef, controlID, sequence)
virtualConsole.updateKeySequenceControlID(widgetObjRef, controlID, sequence)
}
}
}
Expand Down Expand Up @@ -98,7 +98,7 @@ Column
if (checked == true)
{
if (invalid === false &&
virtualConsole.enableKeyAutoDetection(dObjRef, controlID, sequence) === true)
virtualConsole.enableKeyAutoDetection(widgetObjRef, controlID, sequence) === true)
invalid = true
else
checked = false
Expand All @@ -118,7 +118,7 @@ Column
imgSource: "qrc:/remove.svg"
tooltip: qsTr("Remove this keyboard combination")

onClicked: virtualConsole.deleteKeySequence(dObjRef, controlID, sequence)
onClicked: virtualConsole.deleteKeySequence(widgetObjRef, controlID, sequence)
}
}
}
Loading

0 comments on commit b23b6af

Please sign in to comment.