@ -22,7 +22,7 @@ import QGroundControl.FactControls 1.0
Item {
Item {
width: availableWidth
width: availableWidth
height: ( activeVehicle . supportsJSButton ? buttonCol.height : buttonFlow . height ) + ( ScreenTools . defaultFontPixelHeight * 2 )
height: ( activeVehicle . supportsJSButton ? buttonCol.height : flowColumn . height ) + ( ScreenTools . defaultFontPixelHeight * 2 )
Connections {
Connections {
target: _activeJoystick
target: _activeJoystick
onRawButtonPressedChanged: {
onRawButtonPressedChanged: {
@ -34,66 +34,76 @@ Item {
}
}
}
}
}
}
Flow {
ColumnLayout {
id: buttonFlow
id: flowColumn
width: parent . width
y: ScreenTools . defaultFontPixelHeight / 2
spacing: ScreenTools . defaultFontPixelWidth
width: parent . width
visible: ! activeVehicle . supportsJSButton
spacing: ScreenTools . defaultFontPixelHeight / 2
anchors.centerIn: parent
QGCLabel {
Repeater {
Layout.preferredWidth: parent . width
id: buttonActionRepeater
wrapMode: Text . WordWrap
model: _activeJoystick ? Math . min ( _activeJoystick . totalButtonCount , _maxButtons ) : [ ]
text: qsTr ( "Assigning the same action to multiple buttons requires the press of all those buttons for the action to be taken. This is useful to prevent accidental button presses for critical actions like Arm or Emergency Stop." )
Row {
}
spacing: ScreenTools . defaultFontPixelWidth
Flow {
property bool pressed
id: buttonFlow
property var currentAssignableAction: _activeJoystick ? _activeJoystick . assignableActions . get ( buttonActionCombo . currentIndex ) : null
Layout.preferredWidth: parent . width
Rectangle {
spacing: ScreenTools . defaultFontPixelWidth
anchors.verticalCenter: parent . verticalCenter
visible: ! activeVehicle . supportsJSButton
width: ScreenTools . defaultFontPixelHeight * 1.5
Repeater {
height: width
id: buttonActionRepeater
border.width: 1
model: _activeJoystick ? Math . min ( _activeJoystick . totalButtonCount , _maxButtons ) : [ ]
border.color: qgcPal . text
Row {
color: pressed ? qgcPal.buttonHighlight : qgcPal . button
spacing: ScreenTools . defaultFontPixelWidth
QGCLabel {
property bool pressed
anchors.fill: parent
property var currentAssignableAction: _activeJoystick ? _activeJoystick . assignableActions . get ( buttonActionCombo . currentIndex ) : null
color: pressed ? qgcPal.buttonHighlightText : qgcPal . buttonText
Rectangle {
horizontalAlignment: Text . AlignHCenter
anchors.verticalCenter: parent . verticalCenter
verticalAlignment: Text . AlignVCenter
width: ScreenTools . defaultFontPixelHeight * 1.5
text: modelData
height: width
}
border.width: 1
}
border.color: qgcPal . text
QGCComboBox {
color: pressed ? qgcPal.buttonHighlight : qgcPal . button
id: buttonActionCombo
QGCLabel {
width: ScreenTools . defaultFontPixelWidth * 26
anchors.fill: parent
model: _activeJoystick ? _activeJoystick . assignableActionTitles : [ ]
color: pressed ? qgcPal.buttonHighlightText : qgcPal . buttonText
onActivated: {
horizontalAlignment: Text . AlignHCenter
_activeJoystick . setButtonAction ( modelData , textAt ( index ) )
verticalAlignment: Text . AlignVCenter
}
text: modelData
Component.onCompleted: {
if ( _activeJoystick ) {
var i = find ( _activeJoystick . buttonActions [ modelData ] )
if ( i < 0 ) i = 0
currentIndex = i
}
}
}
}
}
QGCComboBox {
QGCCheckBox {
id: buttonActionCombo
id: repeatCheck
width: ScreenTools . defaultFontPixelWidth * 26
text: qsTr ( "Repeat" )
model: _activeJoystick ? _activeJoystick . assignableActionTitles : [ ]
enabled: currentAssignableAction && _activeJoystick . calibrated && currentAssignableAction . canRepeat
onActivated: {
onClicked: {
_activeJoystick . setButtonAction ( modelData , textAt ( index ) )
_activeJoystick . setButtonRepeat ( modelData , checked )
}
Component.onCompleted: {
if ( _activeJoystick ) {
var i = find ( _activeJoystick . buttonActions [ modelData ] )
if ( i < 0 ) i = 0
currentIndex = i
}
}
}
}
Component.onCompleted: {
QGCCheckBox {
if ( _activeJoystick ) {
id: repeatCheck
checked = _activeJoystick . getButtonRepeat ( modelData )
text: qsTr ( "Repeat" )
enabled: currentAssignableAction && _activeJoystick . calibrated && currentAssignableAction . canRepeat
onClicked: {
_activeJoystick . setButtonRepeat ( modelData , checked )
}
Component.onCompleted: {
if ( _activeJoystick ) {
checked = _activeJoystick . getButtonRepeat ( modelData )
}
}
}
anchors.verticalCenter: parent . verticalCenter
}
Item {
width: ScreenTools . defaultFontPixelWidth * 2
height: 1
}
}
anchors.verticalCenter: parent . verticalCenter
}
Item {
width: ScreenTools . defaultFontPixelWidth * 2
height: 1
}
}
}
}
}
}