Browse Source

Rework disabling of setup pages while vehicle is armed

This will make setup pages respond accordingly to armed state
transitions. This will also allow the settings on a page to at least be
visible while they are disabled.
QGC4.4
Jacob Walser 8 years ago
parent
commit
f11f006b1b
  1. 1
      src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml
  2. 44
      src/AutoPilotPlugins/Common/SetupPage.qml
  3. 5
      src/VehicleSetup/FirmwareUpgrade.qml
  4. 42
      src/VehicleSetup/SetupView.qml

1
src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml

@ -22,6 +22,7 @@ import QGroundControl.ScreenTools 1.0
SetupPage { SetupPage {
id: safetyPage id: safetyPage
pageComponent: safetyPageComponent pageComponent: safetyPageComponent
visibleWhileArmed: true
Component { Component {
id: safetyPageComponent id: safetyPageComponent

44
src/AutoPilotPlugins/Common/SetupPage.qml

@ -32,8 +32,51 @@ QGCView {
property real _margins: ScreenTools.defaultFontPixelHeight / 2 property real _margins: ScreenTools.defaultFontPixelHeight / 2
property bool visibleWhileArmed: false
property bool vehicleArmed: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.armed : false
onVehicleArmedChanged: {
if (visibleWhileArmed) {
return
}
if (vehicleArmed) {
disabledWhileArmed.visible = true
setupView.viewPanel.enabled = false
} else {
disabledWhileArmed.visible = false
setupView.viewPanel.enabled = true
}
}
QGCPalette { id: qgcPal; colorGroupEnabled: setupPanel.enabled } QGCPalette { id: qgcPal; colorGroupEnabled: setupPanel.enabled }
// Overlay to display when vehicle is armed and the setup page needs
// to be disabled
Item {
id: disabledWhileArmed
visible: false
z: 9999
anchors.fill: parent
Rectangle {
anchors.fill: parent
color: "black"
opacity: 0.5
}
QGCLabel {
anchors.margins: _defaultTextWidth * 2
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
font.pointSize: ScreenTools.largeFontPointSize
color: "red"
text: "Setup disabled while the vehicle is armed"
}
}
QGCViewPanel { QGCViewPanel {
id: setupPanel id: setupPanel
anchors.fill: parent anchors.fill: parent
@ -68,7 +111,6 @@ QGCView {
id: pageLoader id: pageLoader
anchors.topMargin: _margins anchors.topMargin: _margins
anchors.top: headingColumn.bottom anchors.top: headingColumn.bottom
} }
} }
} }

5
src/VehicleSetup/FirmwareUpgrade.qml

@ -21,7 +21,7 @@ import QGroundControl.Palette 1.0
import QGroundControl.Controllers 1.0 import QGroundControl.Controllers 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
QGCView { SetupPage {
id: qgcView id: qgcView
viewPanel: panel viewPanel: panel
@ -30,7 +30,8 @@ QGCView {
// a better way to hightlight them, or use less hightlights. // a better way to hightlight them, or use less hightlights.
// User visible strings // User visible strings
readonly property string title: "FIRMWARE" pageName: "Firmware"
readonly property string highlightPrefix: "<font color=\"" + qgcPal.warningText + "\">" readonly property string highlightPrefix: "<font color=\"" + qgcPal.warningText + "\">"
readonly property string highlightSuffix: "</font>" readonly property string highlightSuffix: "</font>"
readonly property string welcomeText: qsTr("%1 can upgrade the firmware on Pixhawk devices, SiK Radios and PX4 Flow Smart Cameras.").arg(QGroundControl.appName) readonly property string welcomeText: qsTr("%1 can upgrade the firmware on Pixhawk devices, SiK Radios and PX4 Flow Smart Cameras.").arg(QGroundControl.appName)

42
src/VehicleSetup/SetupView.qml

@ -56,23 +56,13 @@ Rectangle {
function showFirmwarePanel() function showFirmwarePanel()
{ {
if (!ScreenTools.isMobile) { if (!ScreenTools.isMobile) {
if (QGroundControl.multiVehicleManager.activeVehicleAvailable && QGroundControl.multiVehicleManager.activeVehicle.armed) { panelLoader.setSource("FirmwareUpgrade.qml")
_messagePanelText = _armedVehicleText
panelLoader.setSourceComponent(messagePanelComponent)
} else {
panelLoader.setSource("FirmwareUpgrade.qml")
}
} }
} }
function showJoystickPanel() function showJoystickPanel()
{ {
if (QGroundControl.multiVehicleManager.activeVehicleAvailable && QGroundControl.multiVehicleManager.activeVehicle.armed) { panelLoader.setSource("JoystickConfig.qml")
_messagePanelText = _armedVehicleText
panelLoader.setSourceComponent(messagePanelComponent)
} else {
panelLoader.setSource("JoystickConfig.qml")
}
} }
function showParametersPanel() function showParametersPanel()
@ -87,24 +77,19 @@ Rectangle {
function showVehicleComponentPanel(vehicleComponent) function showVehicleComponentPanel(vehicleComponent)
{ {
if (QGroundControl.multiVehicleManager.activeVehicle.armed && !vehicleComponent.allowSetupWhileArmed) { var autopilotPlugin = QGroundControl.multiVehicleManager.activeVehicle.autopilot
_messagePanelText = _armedVehicleText var prereq = autopilotPlugin.prerequisiteSetup(vehicleComponent)
if (prereq !== "") {
//-- TODO: This cannot be translated when built this way.
_messagePanelText = prereq + " setup must be completed prior to " + vehicleComponent.name + " setup."
panelLoader.setSourceComponent(messagePanelComponent) panelLoader.setSourceComponent(messagePanelComponent)
} else { } else {
var autopilotPlugin = QGroundControl.multiVehicleManager.activeVehicle.autopilot panelLoader.setSource(vehicleComponent.setupSource, vehicleComponent)
var prereq = autopilotPlugin.prerequisiteSetup(vehicleComponent) for(var i = 0; i < componentRepeater.count; i++) {
if (prereq !== "") { var obj = componentRepeater.itemAt(i);
//-- TODO: This cannot be trasnlated when built this way. if (obj.text === vehicleComponent.name) {
_messagePanelText = prereq + " setup must be completed prior to " + vehicleComponent.name + " setup." obj.checked = true;
panelLoader.setSourceComponent(messagePanelComponent) break;
} else {
panelLoader.setSource(vehicleComponent.setupSource, vehicleComponent)
for(var i = 0; i < componentRepeater.count; i++) {
var obj = componentRepeater.itemAt(i);
if (obj.text === vehicleComponent.name) {
obj.checked = true;
break;
}
} }
} }
} }
@ -170,6 +155,7 @@ Rectangle {
} }
} }
} }
Component { Component {
id: missingParametersVehicleSummaryComponent id: missingParametersVehicleSummaryComponent

Loading…
Cancel
Save