Commit f4b62d90 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #3906 from DonLakeFlyer/JoystickConfig

Joystick config: Fix scrolling
parents 3f63baf5 fcf77a69
...@@ -25,6 +25,8 @@ QGCView { ...@@ -25,6 +25,8 @@ QGCView {
viewPanel: setupPanel viewPanel: setupPanel
property alias pageComponent: pageLoader.sourceComponent property alias pageComponent: pageLoader.sourceComponent
property string pageName: vehicleComponent ? vehicleComponent.name : ""
property string pageDescription: vehicleComponent ? vehicleComponent.description : ""
property real availableWidth: width - pageLoader.x property real availableWidth: width - pageLoader.x
property real availableHeight: height - pageLoader.y property real availableHeight: height - pageLoader.y
...@@ -49,7 +51,7 @@ QGCView { ...@@ -49,7 +51,7 @@ QGCView {
QGCLabel { QGCLabel {
font.pointSize: ScreenTools.largeFontPointSize font.pointSize: ScreenTools.largeFontPointSize
text: vehicleComponent.name + " " + qsTr("Setup") text: pageName + " " + qsTr("Setup")
visible: !ScreenTools.isShortScreen visible: !ScreenTools.isShortScreen
} }
...@@ -57,7 +59,7 @@ QGCView { ...@@ -57,7 +59,7 @@ QGCView {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
text: vehicleComponent.description text: pageDescription
visible: !ScreenTools.isShortScreen visible: !ScreenTools.isShortScreen
} }
} }
......
...@@ -21,688 +21,679 @@ import QGroundControl.FactSystem 1.0 ...@@ -21,688 +21,679 @@ import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0 import QGroundControl.FactControls 1.0
/// Joystick Config /// Joystick Config
QGCView { SetupPage {
id: rootQGCView id: joystickPage
viewPanel: panel pageComponent: pageComponent
pageName: qsTr("Joystick")
QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } pageDescription: qsTr("Joystick Setup is used to configure a calibrate joysticks.")
readonly property string dialogTitle: qsTr("Joystick Config") Component {
readonly property real labelToMonitorMargin: defaultTextWidth * 3 id: pageComponent
property bool controllerCompleted: false
property bool controllerAndViewReady: false Item {
width: availableWidth
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle height: Math.max(leftColumn.height, rightColumn.height)
property var _activeJoystick: joystickManager.activeJoystick
property bool controllerCompleted: false
JoystickConfigController { property bool controllerAndViewReady: false
id: controller
factPanel: panel readonly property real labelToMonitorMargin: defaultTextWidth * 3
statusText: statusText
cancelButton: cancelButton property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
nextButton: nextButton property var _activeJoystick: joystickManager.activeJoystick
skipButton: skipButton
JoystickConfigController {
Component.onCompleted: { id: controller
controllerCompleted = true factPanel: joystickPage.viewPanel
if (rootQGCView.completedSignalled) { statusText: statusText
controllerAndViewReady = true cancelButton: cancelButton
controller.start() nextButton: nextButton
skipButton: skipButton
Component.onCompleted: {
controllerCompleted = true
if (joystickPage.completedSignalled) {
controllerAndViewReady = true
controller.start()
}
}
} }
}
}
onCompleted: { Component.onCompleted: {
if (controllerCompleted) { if (controllerCompleted) {
controllerAndViewReady = true controllerAndViewReady = true
controller.start() controller.start()
} }
} }
QGCViewPanel { // Live axis monitor control component
id: panel Component {
anchors.fill: parent id: axisMonitorDisplayComponent
// Live axis monitor control component Item {
Component { property int axisValue: 0
id: axisMonitorDisplayComponent
Item {
property int axisValue: 0
property int __lastAxisValue: 0
readonly property int __axisValueMaxJitter: 100
property color __barColor: qgcPal.windowShade
property int __lastAxisValue: 0 // Bar
readonly property int __axisValueMaxJitter: 100 Rectangle {
property color __barColor: qgcPal.windowShade id: bar
anchors.verticalCenter: parent.verticalCenter
width: parent.width
height: parent.height / 2
color: __barColor
}
// Bar // Center point
Rectangle { Rectangle {
id: bar anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter width: defaultTextWidth / 2
width: parent.width height: parent.height
height: parent.height / 2 color: qgcPal.window
color: __barColor }
}
// Center point // Indicator
Rectangle { Rectangle {
anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter
width: defaultTextWidth / 2 width: parent.height * 0.75
height: parent.height height: width
color: qgcPal.window x: (reversed ? (parent.width - _indicatorPosition) : _indicatorPosition) - (width / 2)
} radius: width / 2
color: qgcPal.text
visible: mapped
property real _percentAxisValue: ((axisValue + 32768.0) / (32768.0 * 2))
property real _indicatorPosition: parent.width * _percentAxisValue
}
// Indicator QGCLabel {
Rectangle { anchors.fill: parent
anchors.verticalCenter: parent.verticalCenter horizontalAlignment: Text.AlignHCenter
width: parent.height * 0.75 verticalAlignment: Text.AlignVCenter
height: width text: qsTr("Not Mapped")
x: (reversed ? (parent.width - _indicatorPosition) : _indicatorPosition) - (width / 2) visible: !mapped
radius: width / 2 }
color: qgcPal.text
visible: mapped
property real _percentAxisValue: ((axisValue + 32768.0) / (32768.0 * 2))
property real _indicatorPosition: parent.width * _percentAxisValue
}
QGCLabel { ColorAnimation {
anchors.fill: parent id: barAnimation
horizontalAlignment: Text.AlignHCenter target: bar
verticalAlignment: Text.AlignVCenter property: "color"
text: qsTr("Not Mapped") from: "yellow"
visible: !mapped to: __barColor
} duration: 1500
}
ColorAnimation { /*
id: barAnimation // Axis value debugger
target: bar QGCLabel {
property: "color" anchors.fill: parent
from: "yellow" text: axisValue
to: __barColor }
duration: 1500 */
} }
} // Component - axisMonitorDisplayComponent
/* // Main view Qml starts here
// Axis value debugger
QGCLabel { // Left side column
anchors.fill: parent Column {
text: axisValue id: leftColumn
} anchors.rightMargin: ScreenTools.defaultFontPixelWidth
*/ anchors.left: parent.left
} anchors.right: rightColumn.left
} // Component - axisMonitorDisplayComponent spacing: 10
// Main view Qml starts here // Attitude Controls
Column {
width: parent.width
spacing: 5
QGCLabel { QGCLabel { text: qsTr("Attitude Controls") }
id: header
font.pointSize: ScreenTools.mediumFontPointSize
text: qsTr("JOYSTICK")
}
Item { Item {
id: spacer width: parent.width
anchors.top: header.bottom height: defaultTextHeight * 2
width: parent.width
height: 10
}
// Left side column
Column {
id: leftColumn
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.top: spacer.bottom
anchors.left: parent.left
anchors.right: rightColumn.left
spacing: 10
// Attitude Controls
Column {
width: parent.width
spacing: 5
QGCLabel { text: qsTr("Attitude Controls") } QGCLabel {
id: rollLabel
width: defaultTextWidth * 10
text: qsTr("Roll")
}
Item { Loader {
width: parent.width id: rollLoader
height: defaultTextHeight * 2 anchors.left: rollLabel.right
anchors.right: parent.right
height: ScreenTools.defaultFontPixelHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
property bool mapped: controller.rollAxisMapped
property bool reversed: controller.rollAxisReversed
}
QGCLabel { Connections {
id: rollLabel target: controller
width: defaultTextWidth * 10
text: qsTr("Roll")
}
Loader { onRollAxisValueChanged: rollLoader.item.axisValue = value
id: rollLoader }
anchors.left: rollLabel.right
anchors.right: parent.right
height: rootQGCView.defaultTextHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property real defaultTextWidth: rootQGCView.defaultTextWidth
property bool mapped: controller.rollAxisMapped
property bool reversed: controller.rollAxisReversed
} }
Connections { Item {
target: controller width: parent.width
height: defaultTextHeight * 2
onRollAxisValueChanged: rollLoader.item.axisValue = value QGCLabel {
} id: pitchLabel
} width: defaultTextWidth * 10
text: qsTr("Pitch")
}
Item { Loader {
width: parent.width id: pitchLoader
height: defaultTextHeight * 2 anchors.left: pitchLabel.right
anchors.right: parent.right
height: ScreenTools.defaultFontPixelHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
property bool mapped: controller.pitchAxisMapped
property bool reversed: controller.pitchAxisReversed
}
QGCLabel { Connections {
id: pitchLabel target: controller
width: defaultTextWidth * 10
text: qsTr("Pitch")
}
Loader { onPitchAxisValueChanged: pitchLoader.item.axisValue = value
id: pitchLoader }
anchors.left: pitchLabel.right
anchors.right: parent.right
height: rootQGCView.defaultTextHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property real defaultTextWidth: rootQGCView.defaultTextWidth
property bool mapped: controller.pitchAxisMapped
property bool reversed: controller.pitchAxisReversed
} }
Connections { Item {
target: controller width: parent.width
height: defaultTextHeight * 2
onPitchAxisValueChanged: pitchLoader.item.axisValue = value QGCLabel {
} id: yawLabel
} width: defaultTextWidth * 10
text: qsTr("Yaw")
}
Item { Loader {
width: parent.width id: yawLoader
height: defaultTextHeight * 2 anchors.left: yawLabel.right
anchors.right: parent.right
height: ScreenTools.defaultFontPixelHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
property bool mapped: controller.yawAxisMapped
property bool reversed: controller.yawAxisReversed
}
QGCLabel { Connections {
id: yawLabel target: controller
width: defaultTextWidth * 10
text: qsTr("Yaw")
}
Loader { onYawAxisValueChanged: yawLoader.item.axisValue = value
id: yawLoader }
anchors.left: yawLabel.right
anchors.right: parent.right
height: rootQGCView.defaultTextHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property real defaultTextWidth: rootQGCView.defaultTextWidth
property bool mapped: controller.yawAxisMapped
property bool reversed: controller.yawAxisReversed
} }
Connections { Item {
target: controller width: parent.width
height: defaultTextHeight * 2
onYawAxisValueChanged: yawLoader.item.axisValue = value QGCLabel {
} id: throttleLabel
} width: defaultTextWidth * 10
text: qsTr("Throttle")
}
Item { Loader {
width: parent.width id: throttleLoader
height: defaultTextHeight * 2 anchors.left: throttleLabel.right
anchors.right: parent.right
height: ScreenTools.defaultFontPixelHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
property bool mapped: controller.throttleAxisMapped
property bool reversed: controller.throttleAxisReversed
}
QGCLabel { Connections {
id: throttleLabel target: controller
width: defaultTextWidth * 10
text: qsTr("Throttle")
}
Loader { onThrottleAxisValueChanged: throttleLoader.item.axisValue = value
id: throttleLoader }
anchors.left: throttleLabel.right
anchors.right: parent.right
height: rootQGCView.defaultTextHeight
width: 100
sourceComponent: axisMonitorDisplayComponent
property real defaultTextWidth: rootQGCView.defaultTextWidth
property bool mapped: controller.throttleAxisMapped
property bool reversed: controller.throttleAxisReversed
} }
} // Column - Attitude Control labels
Connections { // Command Buttons
target: controller Row {
spacing: 10
QGCButton {
id: skipButton
text: qsTr("Skip")
onThrottleAxisValueChanged: throttleLoader.item.axisValue = value onClicked: controller.skipButtonClicked()
} }
}
} // Column - Attitude Control labels
// Command Buttons QGCButton {
Row { id: cancelButton
spacing: 10 text: qsTr("Cancel")
QGCButton { onClicked: controller.cancelButtonClicked()
id: skipButton }
text: qsTr("Skip")
onClicked: controller.skipButtonClicked() QGCButton {
} id: nextButton
primary: true
text: qsTr("Calibrate")
QGCButton { onClicked: controller.nextButtonClicked()
id: cancelButton }
text: qsTr("Cancel") } // Row - Buttons
onClicked: controller.cancelButtonClicked() // Status Text
QGCLabel {
id: statusText
width: parent.width
wrapMode: Text.WordWrap
} }
QGCButton { Rectangle {
id: nextButton width: parent.width
primary: true height: 1
text: qsTr("Calibrate") border.color: qgcPal.text
border.width: 1
onClicked: controller.nextButtonClicked()
} }
} // Row - Buttons
// Status Text // Settings
QGCLabel { Row {
id: statusText width: parent.width
width: parent.width spacing: ScreenTools.defaultFontPixelWidth
wrapMode: Text.WordWrap
}
Rectangle {
width: parent.width
height: 1
border.color: qgcPal.text
border.width: 1
}
// Settings
Row {
width: parent.width
spacing: ScreenTools.defaultFontPixelWidth
// Left column settings
Column {
width: parent.width / 2
spacing: ScreenTools.defaultFontPixelHeight
QGCLabel { text: qsTr("Additional Joystick settings:") }
// Left column settings
Column { Column {
width: parent.width width: parent.width / 2
spacing: ScreenTools.defaultFontPixelHeight spacing: ScreenTools.defaultFontPixelHeight
QGCLabel { text: qsTr("Additional Joystick settings:") }
QGCCheckBox { Column {
enabled: checked || _activeJoystick.calibrated width: parent.width
text: _activeJoystick.calibrated ? qsTr("Enable joystick input") : qsTr("Enable not allowed (Calibrate First)") spacing: ScreenTools.defaultFontPixelHeight
checked: _activeVehicle.joystickEnabled
onClicked: _activeVehicle.joystickEnabled = checked
}
Row { QGCCheckBox {
width: parent.width enabled: checked || _activeJoystick.calibrated
spacing: ScreenTools.defaultFontPixelWidth text: _activeJoystick.calibrated ? qsTr("Enable joystick input") : qsTr("Enable not allowed (Calibrate First)")
checked: _activeVehicle.joystickEnabled
QGCLabel { onClicked: _activeVehicle.joystickEnabled = checked
id: activeJoystickLabel
anchors.baseline: joystickCombo.baseline
text: qsTr("Active joystick:")
} }
QGCComboBox { Row {
id: joystickCombo width: parent.width
width: parent.width - activeJoystickLabel.width - parent.spacing spacing: ScreenTools.defaultFontPixelWidth
model: joystickManager.joystickNames
onActivated: joystickManager.activeJoystickName = textAt(index) QGCLabel {
id: activeJoystickLabel
anchors.baseline: joystickCombo.baseline
text: qsTr("Active joystick:")
}
Component.onCompleted: { QGCComboBox {
var index = joystickCombo.find(joystickManager.activeJoystickName) id: joystickCombo
if (index == -1) { width: parent.width - activeJoystickLabel.width - parent.spacing
console.warn(qsTr("Active joystick name not in combo"), joystickManager.activeJoystickName) model: joystickManager.joystickNames
} else {
joystickCombo.currentIndex = index onActivated: joystickManager.activeJoystickName = textAt(index)
Component.onCompleted: {
var index = joystickCombo.find(joystickManager.activeJoystickName)
if (index == -1) {
console.warn(qsTr("Active joystick name not in combo"), joystickManager.activeJoystickName)
} else {
joystickCombo.currentIndex = index
}
} }
} }
} }
}
Column { Column {
spacing: ScreenTools.defaultFontPixelHeight / 3 spacing: ScreenTools.defaultFontPixelHeight / 3
visible: _activeVehicle.supportsThrottleModeCenterZero visible: _activeVehicle.supportsThrottleModeCenterZero
ExclusiveGroup { id: throttleModeExclusiveGroup } ExclusiveGroup { id: throttleModeExclusiveGroup }
QGCRadioButton { QGCRadioButton {
exclusiveGroup: throttleModeExclusiveGroup exclusiveGroup: throttleModeExclusiveGroup
text: qsTr("Center stick is zero throttle") text: qsTr("Center stick is zero throttle")
checked: _activeJoystick.throttleMode == 0 checked: _activeJoystick.throttleMode == 0
onClicked: _activeJoystick.throttleMode = 0 onClicked: _activeJoystick.throttleMode = 0
} }
QGCRadioButton { QGCRadioButton {
exclusiveGroup: throttleModeExclusiveGroup exclusiveGroup: throttleModeExclusiveGroup
text: qsTr("Full down stick is zero throttle") text: qsTr("Full down stick is zero throttle")
checked: _activeJoystick.throttleMode == 1 checked: _activeJoystick.throttleMode == 1
onClicked: _activeJoystick.throttleMode = 1 onClicked: _activeJoystick.throttleMode = 1
}
} }
}
Column { Column {
spacing: ScreenTools.defaultFontPixelHeight / 3 spacing: ScreenTools.defaultFontPixelHeight / 3
QGCCheckBox { QGCCheckBox {
id: exponential id: exponential
checked: _activeJoystick.exponential checked: _activeJoystick.exponential
text: qsTr("Use exponential curve on roll, pitch, yaw") text: qsTr("Use exponential curve on roll, pitch, yaw")
onClicked: _activeJoystick.exponential = checked onClicked: _activeJoystick.exponential = checked
}
} }
}
QGCCheckBox { QGCCheckBox {
id: advancedSettings id: advancedSettings
checked: _activeVehicle.joystickMode != 0 checked: _activeVehicle.joystickMode != 0
text: qsTr("Advanced settings (careful!)") text: qsTr("Advanced settings (careful!)")
onClicked: { onClicked: {
if (!checked) { if (!checked) {
_activeVehicle.joystickMode = 0 _activeVehicle.joystickMode = 0
}
} }
} }
}
Row { Row {
width: parent.width width: parent.width
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
visible: advancedSettings.checked visible: advancedSettings.checked
QGCLabel { QGCLabel {
id: joystickModeLabel id: joystickModeLabel
anchors.baseline: joystickModeCombo.baseline anchors.baseline: joystickModeCombo.baseline
text: qsTr("Joystick mode:") text: qsTr("Joystick mode:")
} }
QGCComboBox { QGCComboBox {
id: joystickModeCombo id: joystickModeCombo
currentIndex: _activeVehicle.joystickMode currentIndex: _activeVehicle.joystickMode
width: ScreenTools.defaultFontPixelWidth * 20 width: ScreenTools.defaultFontPixelWidth * 20
model: _activeVehicle.joystickModes model: _activeVehicle.joystickModes
onActivated: _activeVehicle.joystickMode = index onActivated: _activeVehicle.joystickMode = index
}
} }
} }
} } // Column - left column
} // Column - left column
// Right column settings // Right column settings
Column { Column {
width: parent.width / 2 width: parent.width / 2
spacing: ScreenTools.defaultFontPixelHeight spacing: ScreenTools.defaultFontPixelHeight
Connections { Connections {
target: _activeJoystick target: _activeJoystick
onRawButtonPressedChanged: { onRawButtonPressedChanged: {
if (buttonActionRepeater.itemAt(index)) { if (buttonActionRepeater.itemAt(index)) {
buttonActionRepeater.itemAt(index).pressed = pressed buttonActionRepeater.itemAt(index).pressed = pressed
} }
if (jsButtonActionRepeater.itemAt(index)) { if (jsButtonActionRepeater.itemAt(index)) {
jsButtonActionRepeater.itemAt(index).pressed = pressed jsButtonActionRepeater.itemAt(index).pressed = pressed
}
} }
} }
}
QGCLabel { text: qsTr("Button actions:") } QGCLabel { text: qsTr("Button actions:") }
Column { Column {
width: parent.width width: parent.width
spacing: ScreenTools.defaultFontPixelHeight / 3 spacing: ScreenTools.defaultFontPixelHeight / 3
QGCLabel { QGCLabel {
visible: _activeVehicle.manualControlReservedButtonCount != 0 visible: _activeVehicle.manualControlReservedButtonCount != 0
text: qsTr("Buttons 0-%1 reserved for firmware use").arg(reservedButtonCount) text: qsTr("Buttons 0-%1 reserved for firmware use").arg(reservedButtonCount)
property int reservedButtonCount: _activeVehicle.manualControlReservedButtonCount == -1 ? _activeJoystick.totalButtonCount : _activeVehicle.manualControlReservedButtonCount property int reservedButtonCount: _activeVehicle.manualControlReservedButtonCount == -1 ? _activeJoystick.totalButtonCount : _activeVehicle.manualControlReservedButtonCount
} }
Repeater { Repeater {
id: buttonActionRepeater id: buttonActionRepeater
model: _activeJoystick.totalButtonCount model: _activeJoystick.totalButtonCount
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
visible: (_activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount) && !_activeVehicle.supportsJSButton visible: (_activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount) && !_activeVehicle.supportsJSButton
property bool pressed property bool pressed
QGCCheckBox { QGCCheckBox {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
checked: _activeJoystick.buttonActions[modelData] != "" checked: _activeJoystick.buttonActions[modelData] != ""
onClicked: _activeJoystick.setButtonAction(modelData, checked ? buttonActionCombo.textAt(buttonActionCombo.currentIndex) : "") onClicked: _activeJoystick.setButtonAction(modelData, checked ? buttonActionCombo.textAt(buttonActionCombo.currentIndex) : "")
} }
Rectangle { Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: ScreenTools.defaultFontPixelHeight * 1.5 width: ScreenTools.defaultFontPixelHeight * 1.5
height: width height: width
border.width: 1 border.width: 1
border.color: qgcPal.text border.color: qgcPal.text
color: pressed ? qgcPal.buttonHighlight : qgcPal.button color: pressed ? qgcPal.buttonHighlight : qgcPal.button
QGCLabel { QGCLabel {
anchors.fill: parent anchors.fill: parent
color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
text: modelData text: modelData
}
} }
}
QGCComboBox { QGCComboBox {
id: buttonActionCombo id: buttonActionCombo
width: ScreenTools.defaultFontPixelWidth * 20 width: ScreenTools.defaultFontPixelWidth * 20
model: _activeJoystick.actions model: _activeJoystick.actions
onActivated: _activeJoystick.setButtonAction(modelData, textAt(index)) onActivated: _activeJoystick.setButtonAction(modelData, textAt(index))
Component.onCompleted: currentIndex = find(_activeJoystick.buttonActions[modelData]) Component.onCompleted: currentIndex = find(_activeJoystick.buttonActions[modelData])
}
} }
} } // Repeater
} // Repeater
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: _activeVehicle.supportsJSButton
QGCLabel {
horizontalAlignment: Text.AlignHCenter
width: ScreenTools.defaultFontPixelHeight * 1.5
text: qsTr("#")
}
QGCLabel {
width: ScreenTools.defaultFontPixelWidth * 15
text: qsTr("Function: ")
}
QGCLabel {
width: ScreenTools.defaultFontPixelWidth * 15
text: qsTr("Shift Function: ")
}
} // Row
Repeater {
id: jsButtonActionRepeater
model: _activeJoystick.totalButtonCount
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
visible: _activeVehicle.supportsJSButton visible: _activeVehicle.supportsJSButton
property bool pressed QGCLabel {
horizontalAlignment: Text.AlignHCenter
Rectangle { width: ScreenTools.defaultFontPixelHeight * 1.5
anchors.verticalCenter: parent.verticalCenter text: qsTr("#")
width: ScreenTools.defaultFontPixelHeight * 1.5
height: width
border.width: 1
border.color: qgcPal.text
color: pressed ? qgcPal.buttonHighlight : qgcPal.button
QGCLabel {
anchors.fill: parent
color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: modelData
}
} }
FactComboBox { QGCLabel {
id: mainJSButtonActionCombo width: ScreenTools.defaultFontPixelWidth * 15
width: ScreenTools.defaultFontPixelWidth * 15 text: qsTr("Function: ")
fact: controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null;
indexModel: false
} }
FactComboBox { QGCLabel {
id: shiftJSButtonActionCombo width: ScreenTools.defaultFontPixelWidth * 15
width: ScreenTools.defaultFontPixelWidth * 15 text: qsTr("Shift Function: ")
fact: controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null;
indexModel: false
} }
} // Row } // Row
} // Repeater
} // Column
} // Column - right setting column
} // Row - Settings
} // Column - Left Main Column
// Right side column
Column {
id: rightColumn
anchors.top: parent.top
anchors.right: parent.right
width: defaultTextWidth * 35
spacing: 10
Image {
//width: parent.width
height: defaultTextHeight * 15
fillMode: Image.PreserveAspectFit
smooth: true
source: controller.imageHelp
}
// Axis monitor Repeater {
id: jsButtonActionRepeater
model: _activeJoystick.totalButtonCount
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: _activeVehicle.supportsJSButton
property bool pressed
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: ScreenTools.defaultFontPixelHeight * 1.5
height: width
border.width: 1
border.color: qgcPal.text
color: pressed ? qgcPal.buttonHighlight : qgcPal.button
QGCLabel {
anchors.fill: parent
color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: modelData
}
}
FactComboBox {
id: mainJSButtonActionCombo
width: ScreenTools.defaultFontPixelWidth * 15
fact: controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null;
indexModel: false
}
FactComboBox {
id: shiftJSButtonActionCombo
width: ScreenTools.defaultFontPixelWidth * 15
fact: controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null;
indexModel: false
}
} // Row
} // Repeater
} // Column
} // Column - right setting column
} // Row - Settings
} // Column - Left Main Column
// Right side column
Column { Column {
width: parent.width id: rightColumn
spacing: 5 anchors.top: parent.top
anchors.right: parent.right
width: defaultTextWidth * 35
spacing: 10
Image {
//width: parent.width
height: defaultTextHeight * 15
fillMode: Image.PreserveAspectFit
smooth: true
source: controller.imageHelp
}
QGCLabel { text: qsTr("Axis Monitor") } // Axis monitor
Column {
width: parent.width
spacing: 5
Connections { QGCLabel { text: qsTr("Axis Monitor") }
target: controller
onAxisValueChanged: { Connections {
if (axisMonitorRepeater.itemAt(axis)) { target: controller
axisMonitorRepeater.itemAt(axis).loader.item.axisValue = value
onAxisValueChanged: {
if (axisMonitorRepeater.itemAt(axis)) {
axisMonitorRepeater.itemAt(axis).loader.item.axisValue = value
}
} }
} }
}
Repeater { Repeater {
id: axisMonitorRepeater id: axisMonitorRepeater
model: _activeJoystick.axisCount model: _activeJoystick.axisCount
width: parent.width width: parent.width
Row { Row {
spacing: 5 spacing: 5
// Need this to get to loader from Connections above // Need this to get to loader from Connections above
property Item loader: theLoader property Item loader: theLoader
QGCLabel { QGCLabel {
id: axisLabel id: axisLabel
text: modelData text: modelData
} }
Loader { Loader {
id: theLoader id: theLoader
anchors.verticalCenter: axisLabel.verticalCenter anchors.verticalCenter: axisLabel.verticalCenter
height: rootQGCView.defaultTextHeight height: ScreenTools.defaultFontPixelHeight
width: 200 width: 200
sourceComponent: axisMonitorDisplayComponent sourceComponent: axisMonitorDisplayComponent
property real defaultTextWidth: rootQGCView.defaultTextWidth property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
property bool mapped: true property bool mapped: true
readonly property bool reversed: false readonly property bool reversed: false
}
} }
} }
} } // Column - Axis Monitor
} // Column - Axis Monitor
// Button monitor // Button monitor
Column { Column {
width: parent.width width: parent.width
spacing: ScreenTools.defaultFontPixelHeight spacing: ScreenTools.defaultFontPixelHeight
QGCLabel { text: qsTr("Button Monitor") } QGCLabel { text: qsTr("Button Monitor") }
Connections { Connections {
target: _activeJoystick target: _activeJoystick
onRawButtonPressedChanged: { onRawButtonPressedChanged: {
if (buttonMonitorRepeater.itemAt(index)) { if (buttonMonitorRepeater.itemAt(index)) {
buttonMonitorRepeater.itemAt(index).pressed = pressed buttonMonitorRepeater.itemAt(index).pressed = pressed
}
} }
} }
}
Row { Flow {
spacing: -1 width: parent.width
spacing: -1
Repeater { Repeater {
id: buttonMonitorRepeater id: buttonMonitorRepeater
model: _activeJoystick.totalButtonCount model: _activeJoystick.totalButtonCount
Rectangle { Rectangle {
width: ScreenTools.defaultFontPixelHeight * 1.2 width: ScreenTools.defaultFontPixelHeight * 1.2
height: width height: width
border.width: 1 border.width: 1
border.color: qgcPal.text border.color: qgcPal.text
color: pressed ? qgcPal.buttonHighlight : qgcPal.button color: pressed ? qgcPal.buttonHighlight : qgcPal.button
property bool pressed property bool pressed
QGCLabel { QGCLabel {
anchors.fill: parent anchors.fill: parent
color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
text: modelData text: modelData
}
} }
} } // Repeater
} // Repeater } // Row
} // Row } // Column - Axis Monitor
} // Column - Axis Monitor } // Column - Right Column
} // Column - Right Column } // Item
} // QGCViewPanel } // Component - pageComponent
} } // SetupPage
...@@ -45,14 +45,14 @@ Rectangle { ...@@ -45,14 +45,14 @@ Rectangle {
{ {
if (_fullParameterVehicleAvailable) { if (_fullParameterVehicleAvailable) {
if (QGroundControl.multiVehicleManager.activeVehicle.autopilot.vehicleComponents.length == 0) { if (QGroundControl.multiVehicleManager.activeVehicle.autopilot.vehicleComponents.length == 0) {
panelLoader.sourceComponent = noComponentsVehicleSummaryComponent panelLoader.setSourceComponent(noComponentsVehicleSummaryComponent)
} else { } else {
panelLoader.source = "VehicleSummary.qml"; panelLoader.setSource("VehicleSummary.qml")
} }
} else if (QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable) { } else if (QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable) {
panelLoader.sourceComponent = missingParametersVehicleSummaryComponent panelLoader.setSourceComponent(missingParametersVehicleSummaryComponent)
} else { } else {
panelLoader.sourceComponent = disconnectedVehicleSummaryComponent panelLoader.setSourceComponent(disconnectedVehicleSummaryComponent)
} }
} }
...@@ -61,9 +61,9 @@ Rectangle { ...@@ -61,9 +61,9 @@ Rectangle {
if (!ScreenTools.isMobile) { if (!ScreenTools.isMobile) {
if (QGroundControl.multiVehicleManager.activeVehicleAvailable && QGroundControl.multiVehicleManager.activeVehicle.armed) { if (QGroundControl.multiVehicleManager.activeVehicleAvailable && QGroundControl.multiVehicleManager.activeVehicle.armed) {
_messagePanelText = _armedVehicleText _messagePanelText = _armedVehicleText
panelLoader.sourceComponent = messagePanelComponent panelLoader.setSourceComponent(messagePanelComponent)
} else { } else {
panelLoader.source = "FirmwareUpgrade.qml"; panelLoader.setSource("FirmwareUpgrade.qml")
} }
} }
} }
...@@ -72,34 +72,33 @@ Rectangle { ...@@ -72,34 +72,33 @@ Rectangle {
{ {
if (QGroundControl.multiVehicleManager.activeVehicleAvailable && QGroundControl.multiVehicleManager.activeVehicle.armed) { if (QGroundControl.multiVehicleManager.activeVehicleAvailable && QGroundControl.multiVehicleManager.activeVehicle.armed) {
_messagePanelText = _armedVehicleText _messagePanelText = _armedVehicleText
panelLoader.sourceComponent = messagePanelComponent panelLoader.setSourceComponent(messagePanelComponent)
} else { } else {
panelLoader.source = "JoystickConfig.qml"; panelLoader.setSource("JoystickConfig.qml")
} }
} }
function showParametersPanel() function showParametersPanel()
{ {
panelLoader.source = "SetupParameterEditor.qml"; panelLoader.setSource("SetupParameterEditor.qml")
} }
function showPX4FlowPanel() function showPX4FlowPanel()
{ {
panelLoader.source = "PX4FlowSensor.qml"; panelLoader.setSource("PX4FlowSensor.qml")
} }
function showVehicleComponentPanel(vehicleComponent) function showVehicleComponentPanel(vehicleComponent)
{ {
if (QGroundControl.multiVehicleManager.activeVehicle.armed && !vehicleComponent.allowSetupWhileArmed) { if (QGroundControl.multiVehicleManager.activeVehicle.armed && !vehicleComponent.allowSetupWhileArmed) {
_messagePanelText = _armedVehicleText _messagePanelText = _armedVehicleText
panelLoader.sourceComponent = messagePanelComponent panelLoader.setSourceComponent(messagePanelComponent)
} else { } else {
if (vehicleComponent.prerequisiteSetup != "") { if (vehicleComponent.prerequisiteSetup != "") {
_messagePanelText = vehicleComponent.prerequisiteSetup + " setup must be completed prior to " + vehicleComponent.name + " setup." _messagePanelText = vehicleComponent.prerequisiteSetup + " setup must be completed prior to " + vehicleComponent.name + " setup."
panelLoader.sourceComponent = messagePanelComponent panelLoader.setSourceComponent(messagePanelComponent)
} else { } else {
panelLoader.vehicleComponent = vehicleComponent panelLoader.setSource(vehicleComponent.setupSource, vehicleComponent)
panelLoader.source = vehicleComponent.setupSource
for(var i = 0; i < componentRepeater.count; i++) { for(var i = 0; i < componentRepeater.count; i++) {
var obj = componentRepeater.itemAt(i); var obj = componentRepeater.itemAt(i);
if (obj.text === vehicleComponent.name) { if (obj.text === vehicleComponent.name) {
...@@ -350,6 +349,16 @@ Rectangle { ...@@ -350,6 +349,16 @@ Rectangle {
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
function setSource(source, vehicleComponent) {
panelLoader.vehicleComponent = vehicleComponent
panelLoader.source = source
}
function setSourceComponent(sourceComponent, vehicleComponent) {
panelLoader.vehicleComponent = vehicleComponent
panelLoader.sourceComponent = sourceComponent
}
property var vehicleComponent property var vehicleComponent
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment