diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml b/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml index 752951d0df72ce63401ac637baf06266b364e72e..4b3d2328fcccc0a9bbc37b64851fd0a0a33615b6 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml +++ b/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml @@ -22,7 +22,6 @@ import QGroundControl.ScreenTools 1.0 SetupPage { id: safetyPage pageComponent: safetyPageComponent - visibleWhileArmed: true Component { id: safetyPageComponent diff --git a/src/AutoPilotPlugins/Common/SetupPage.qml b/src/AutoPilotPlugins/Common/SetupPage.qml index a13b4a0c515871f66761716175cf7d6a9443062a..a2912e368a4de630873568b4028d8779386e2427 100644 --- a/src/AutoPilotPlugins/Common/SetupPage.qml +++ b/src/AutoPilotPlugins/Common/SetupPage.qml @@ -21,8 +21,9 @@ import QGroundControl.Controllers 1.0 /// Base view control for all Setup pages QGCView { - id: setupView - viewPanel: setupPanel + id: setupView + viewPanel: setupPanel + enabled: !_shouldDisableWhenArmed property alias pageComponent: pageLoader.sourceComponent property string pageName: vehicleComponent ? vehicleComponent.name : "" @@ -30,53 +31,15 @@ QGCView { property real availableWidth: width - pageLoader.x 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 } - // 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 { id: setupPanel anchors.fill: parent @@ -88,13 +51,13 @@ QGCView { clip: true Column { - id: headingColumn - width: setupPanel.width - spacing: _margins + id: headingColumn + width: setupPanel.width + spacing: _margins QGCLabel { font.pointSize: ScreenTools.largeFontPointSize - text: pageName + " " + qsTr("Setup") + text: _shouldDisableWhenArmed ? _pageTitle + "" + qsTr(" (Disabled while the vehicle is armed)") + "" : _pageTitle visible: !ScreenTools.isShortScreen } @@ -112,6 +75,14 @@ QGCView { anchors.topMargin: _margins 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 + } } } } diff --git a/src/AutoPilotPlugins/PX4/PowerComponent.qml b/src/AutoPilotPlugins/PX4/PowerComponent.qml index e7b05cb1c6e68703e2339bf35b2401b4a2105f00..91419392fd0b78dd43eb87efb7cbd5d6298327ce 100644 --- a/src/AutoPilotPlugins/PX4/PowerComponent.qml +++ b/src/AutoPilotPlugins/PX4/PowerComponent.qml @@ -43,24 +43,24 @@ SetupPage { readonly property string highlightPrefix: "" readonly property string highlightSuffix: "" + 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 { id: innerColumn anchors.horizontalCenter: parent.horizontalCenter 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) { ctx.save(); diff --git a/src/VehicleSetup/SetupView.qml b/src/VehicleSetup/SetupView.qml index a1bdf64547a49d8b3a7566d00764790cfba3a1d5..1fb0418e5932cd0c319861f9b6ecae543f6d623a 100644 --- a/src/VehicleSetup/SetupView.qml +++ b/src/VehicleSetup/SetupView.qml @@ -34,6 +34,7 @@ Rectangle { readonly property real _buttonWidth: _defaultTextWidth * 18 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 bool _fullParameterVehicleAvailable: QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable && !QGroundControl.multiVehicleManager.activeVehicle.parameterManager.missingParameters property var _corePlugin: QGroundControl.corePlugin @@ -41,7 +42,7 @@ Rectangle { function showSummaryPanel() { if (_fullParameterVehicleAvailable) { - if (QGroundControl.multiVehicleManager.activeVehicle.autopilot.vehicleComponents.length == 0) { + if (QGroundControl.multiVehicleManager.activeVehicle.autopilot.vehicleComponents.length === 0) { panelLoader.setSourceComponent(noComponentsVehicleSummaryComponent) } else { panelLoader.setSource("VehicleSummary.qml") @@ -80,8 +81,7 @@ Rectangle { var autopilotPlugin = QGroundControl.multiVehicleManager.activeVehicle.autopilot 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." + _messagePanelText = qsTr("%1 setup must be completed prior to %2 setup.").arg(prereq).arg(vehicleComponent.name) panelLoader.setSourceComponent(messagePanelComponent) } else { panelLoader.setSource(vehicleComponent.setupSource, vehicleComponent) @@ -272,7 +272,7 @@ Rectangle { setupIndicator: true setupComplete: joystickManager.activeJoystick ? joystickManager.activeJoystick.calibrated : false exclusiveGroup: setupButtonGroup - visible: _fullParameterVehicleAvailable && joystickManager.joysticks.length != 0 + visible: _fullParameterVehicleAvailable && joystickManager.joysticks.length !== 0 text: qsTr("Joystick") Layout.fillWidth: true @@ -289,7 +289,7 @@ Rectangle { setupComplete: modelData.setupComplete exclusiveGroup: setupButtonGroup text: modelData.name - visible: modelData.setupSource.toString() != "" + visible: modelData.setupSource.toString() !== "" Layout.fillWidth: true onClicked: showVehicleComponentPanel(modelData)