Unverified Commit ff622752 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #6037 from mavlink/handleSettingsWhileArmed

Handle settings when armed
parents f4cf5aae f328b2ea
...@@ -22,7 +22,6 @@ import QGroundControl.ScreenTools 1.0 ...@@ -22,7 +22,6 @@ import QGroundControl.ScreenTools 1.0
SetupPage { SetupPage {
id: safetyPage id: safetyPage
pageComponent: safetyPageComponent pageComponent: safetyPageComponent
visibleWhileArmed: true
Component { Component {
id: safetyPageComponent id: safetyPageComponent
......
...@@ -21,8 +21,9 @@ import QGroundControl.Controllers 1.0 ...@@ -21,8 +21,9 @@ import QGroundControl.Controllers 1.0
/// Base view control for all Setup pages /// Base view control for all Setup pages
QGCView { QGCView {
id: setupView id: setupView
viewPanel: setupPanel viewPanel: setupPanel
enabled: !_shouldDisableWhenArmed
property alias pageComponent: pageLoader.sourceComponent property alias pageComponent: pageLoader.sourceComponent
property string pageName: vehicleComponent ? vehicleComponent.name : "" property string pageName: vehicleComponent ? vehicleComponent.name : ""
...@@ -30,53 +31,15 @@ QGCView { ...@@ -30,53 +31,15 @@ QGCView {
property real availableWidth: width - pageLoader.x property real availableWidth: width - pageLoader.x
property real availableHeight: height - pageLoader.y property real availableHeight: height - pageLoader.y
property real _margins: ScreenTools.defaultFontPixelHeight / 2 property bool _vehicleArmed: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.armed : false
property bool _shouldDisableWhenArmed: _vehicleArmed ? (vehicleComponent ? !vehicleComponent.allowSetupWhileArmed : false) : false
property bool visibleWhileArmed: false property real _margins: ScreenTools.defaultFontPixelHeight * 0.5
property string _pageTitle: qsTr("%1 Setup").arg(pageName)
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
...@@ -88,13 +51,13 @@ QGCView { ...@@ -88,13 +51,13 @@ QGCView {
clip: true clip: true
Column { Column {
id: headingColumn id: headingColumn
width: setupPanel.width width: setupPanel.width
spacing: _margins spacing: _margins
QGCLabel { QGCLabel {
font.pointSize: ScreenTools.largeFontPointSize font.pointSize: ScreenTools.largeFontPointSize
text: pageName + " " + qsTr("Setup") text: _shouldDisableWhenArmed ? _pageTitle + "<font color=\"red\">" + qsTr(" (Disabled while the vehicle is armed)") + "</font>" : _pageTitle
visible: !ScreenTools.isShortScreen visible: !ScreenTools.isShortScreen
} }
...@@ -112,6 +75,14 @@ QGCView { ...@@ -112,6 +75,14 @@ QGCView {
anchors.topMargin: _margins anchors.topMargin: _margins
anchors.top: headingColumn.bottom anchors.top: headingColumn.bottom
} }
// Overlay to display when vehicle is armed and this setup page needs
// to be disabled
Rectangle {
visible: _shouldDisableWhenArmed
anchors.fill: pageLoader
color: "black"
opacity: 0.5
}
} }
} }
} }
...@@ -43,24 +43,24 @@ SetupPage { ...@@ -43,24 +43,24 @@ SetupPage {
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>"
function getBatteryImage()
{
switch(battNumCells.value) {
case 1: return "/qmlimages/PowerComponentBattery_01cell.svg";
case 2: return "/qmlimages/PowerComponentBattery_02cell.svg"
case 3: return "/qmlimages/PowerComponentBattery_03cell.svg"
case 4: return "/qmlimages/PowerComponentBattery_04cell.svg"
case 5: return "/qmlimages/PowerComponentBattery_05cell.svg"
case 6: return "/qmlimages/PowerComponentBattery_06cell.svg"
default: return "/qmlimages/PowerComponentBattery_01cell.svg";
}
}
ColumnLayout { ColumnLayout {
id: innerColumn id: innerColumn
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
spacing: ScreenTools.defaultFontPixelHeight spacing: ScreenTools.defaultFontPixelHeight
function getBatteryImage()
{
switch(battNumCells.value) {
case 1: return "/qmlimages/PowerComponentBattery_01cell.svg";
case 2: return "/qmlimages/PowerComponentBattery_02cell.svg"
case 3: return "/qmlimages/PowerComponentBattery_03cell.svg"
case 4: return "/qmlimages/PowerComponentBattery_04cell.svg"
case 5: return "/qmlimages/PowerComponentBattery_05cell.svg"
case 6: return "/qmlimages/PowerComponentBattery_06cell.svg"
default: return "/qmlimages/PowerComponentBattery_01cell.svg";
}
}
function drawArrowhead(ctx, x, y, radians) function drawArrowhead(ctx, x, y, radians)
{ {
ctx.save(); ctx.save();
......
...@@ -34,6 +34,7 @@ Rectangle { ...@@ -34,6 +34,7 @@ Rectangle {
readonly property real _buttonWidth: _defaultTextWidth * 18 readonly property real _buttonWidth: _defaultTextWidth * 18
readonly property string _armedVehicleText: qsTr("This operation cannot be performed while the vehicle is armed.") readonly property string _armedVehicleText: qsTr("This operation cannot be performed while the vehicle is armed.")
property bool _vehicleArmed: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.armed : false
property string _messagePanelText: qsTr("missing message panel text") property string _messagePanelText: qsTr("missing message panel text")
property bool _fullParameterVehicleAvailable: QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable && !QGroundControl.multiVehicleManager.activeVehicle.parameterManager.missingParameters property bool _fullParameterVehicleAvailable: QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable && !QGroundControl.multiVehicleManager.activeVehicle.parameterManager.missingParameters
property var _corePlugin: QGroundControl.corePlugin property var _corePlugin: QGroundControl.corePlugin
...@@ -41,7 +42,7 @@ Rectangle { ...@@ -41,7 +42,7 @@ Rectangle {
function showSummaryPanel() function showSummaryPanel()
{ {
if (_fullParameterVehicleAvailable) { if (_fullParameterVehicleAvailable) {
if (QGroundControl.multiVehicleManager.activeVehicle.autopilot.vehicleComponents.length == 0) { if (QGroundControl.multiVehicleManager.activeVehicle.autopilot.vehicleComponents.length === 0) {
panelLoader.setSourceComponent(noComponentsVehicleSummaryComponent) panelLoader.setSourceComponent(noComponentsVehicleSummaryComponent)
} else { } else {
panelLoader.setSource("VehicleSummary.qml") panelLoader.setSource("VehicleSummary.qml")
...@@ -80,8 +81,7 @@ Rectangle { ...@@ -80,8 +81,7 @@ Rectangle {
var autopilotPlugin = QGroundControl.multiVehicleManager.activeVehicle.autopilot var autopilotPlugin = QGroundControl.multiVehicleManager.activeVehicle.autopilot
var prereq = autopilotPlugin.prerequisiteSetup(vehicleComponent) var prereq = autopilotPlugin.prerequisiteSetup(vehicleComponent)
if (prereq !== "") { if (prereq !== "") {
//-- TODO: This cannot be translated when built this way. _messagePanelText = qsTr("%1 setup must be completed prior to %2 setup.").arg(prereq).arg(vehicleComponent.name)
_messagePanelText = prereq + " setup must be completed prior to " + vehicleComponent.name + " setup."
panelLoader.setSourceComponent(messagePanelComponent) panelLoader.setSourceComponent(messagePanelComponent)
} else { } else {
panelLoader.setSource(vehicleComponent.setupSource, vehicleComponent) panelLoader.setSource(vehicleComponent.setupSource, vehicleComponent)
...@@ -272,7 +272,7 @@ Rectangle { ...@@ -272,7 +272,7 @@ Rectangle {
setupIndicator: true setupIndicator: true
setupComplete: joystickManager.activeJoystick ? joystickManager.activeJoystick.calibrated : false setupComplete: joystickManager.activeJoystick ? joystickManager.activeJoystick.calibrated : false
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
visible: _fullParameterVehicleAvailable && joystickManager.joysticks.length != 0 visible: _fullParameterVehicleAvailable && joystickManager.joysticks.length !== 0
text: qsTr("Joystick") text: qsTr("Joystick")
Layout.fillWidth: true Layout.fillWidth: true
...@@ -289,7 +289,7 @@ Rectangle { ...@@ -289,7 +289,7 @@ Rectangle {
setupComplete: modelData.setupComplete setupComplete: modelData.setupComplete
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
text: modelData.name text: modelData.name
visible: modelData.setupSource.toString() != "" visible: modelData.setupSource.toString() !== ""
Layout.fillWidth: true Layout.fillWidth: true
onClicked: showVehicleComponentPanel(modelData) onClicked: showVehicleComponentPanel(modelData)
......
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