diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 91be3ffb18b39269825427a6795867b6cead19d6..c557bbefa6309f1c183598bb1afdbf48dfe7f928 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -123,6 +123,7 @@ src/QmlControls/QGCMenuSeparator.qml src/QmlControls/QGCMouseArea.qml src/QmlControls/QGCMovableItem.qml + src/QmlControls/QGCOptionsComboBox.qml src/QmlControls/QGCPipable.qml src/QmlControls/QGCRadioButton.qml src/QmlControls/QGCSlider.qml diff --git a/src/FactSystem/FactControls/FactCheckBox.qml b/src/FactSystem/FactControls/FactCheckBox.qml index 7ed1757ff41f3b91ae45ceb556f4dfead05365b9..f9d10f044e4af8973008a5061e9e42f3e962064d 100644 --- a/src/FactSystem/FactControls/FactCheckBox.qml +++ b/src/FactSystem/FactControls/FactCheckBox.qml @@ -7,14 +7,20 @@ import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 QGCCheckBox { + checkedState: isFactChecked() + property Fact fact: Fact { } + property variant checkedValue: 1 property variant uncheckedValue: 0 - checkedState: fact ? - (fact.typeIsBool ? - (fact.value === false ? Qt.Unchecked : Qt.Checked) : - (fact.value === 0 ? Qt.Unchecked : Qt.Checked)) : - Qt.Unchecked + + Binding on checkedState { + value: fact ? + (fact.typeIsBool ? + (fact.value === false ? Qt.Unchecked : Qt.Checked) : + (fact.value === 0 ? Qt.Unchecked : Qt.Checked)) : + Qt.Unchecked + } onClicked: fact.value = (checked ? checkedValue : uncheckedValue) } diff --git a/src/FirmwarePlugin/APM/MavCmdInfoCommon.json b/src/FirmwarePlugin/APM/MavCmdInfoCommon.json index 8f35edd874a2e3d8fb3b56e2b613ea50aaa716a2..f5db22fca1e562043c05c57ace837a7c3ce76905 100644 --- a/src/FirmwarePlugin/APM/MavCmdInfoCommon.json +++ b/src/FirmwarePlugin/APM/MavCmdInfoCommon.json @@ -42,6 +42,7 @@ { "id": 22, "comment": "MAV_CMD_NAV_TAKEOFF", + "description": "Take off from the ground and ascend to specified altitude.", "specifiesCoordinate": false, "specifiesAltitudeOnly": true }, diff --git a/src/MissionManager/TransectStyleComplexItem.cc b/src/MissionManager/TransectStyleComplexItem.cc index 3941016ba9888a25b09b7605d90c356228b38e34..d80fae82082ef0bb6ba7b5f8753a6fee3462329c 100644 --- a/src/MissionManager/TransectStyleComplexItem.cc +++ b/src/MissionManager/TransectStyleComplexItem.cc @@ -102,6 +102,8 @@ TransectStyleComplexItem::TransectStyleComplexItem(Vehicle* vehicle, bool flyVie connect(&_cameraCalc, &CameraCalc::distanceToSurfaceRelativeChanged, this, &TransectStyleComplexItem::coordinateHasRelativeAltitudeChanged); connect(&_cameraCalc, &CameraCalc::distanceToSurfaceRelativeChanged, this, &TransectStyleComplexItem::exitCoordinateHasRelativeAltitudeChanged); + connect(&_hoverAndCaptureFact, &Fact::rawValueChanged, this, &TransectStyleComplexItem::_handleHoverAndCaptureEnabled); + connect(this, &TransectStyleComplexItem::visualTransectPointsChanged, this, &TransectStyleComplexItem::complexDistanceChanged); connect(this, &TransectStyleComplexItem::visualTransectPointsChanged, this, &TransectStyleComplexItem::greatestDistanceToChanged); @@ -769,3 +771,11 @@ void TransectStyleComplexItem::_followTerrainChanged(bool followTerrain) _hoverAndCaptureFact.setRawValue(false); } } + +void TransectStyleComplexItem::_handleHoverAndCaptureEnabled(QVariant enabled) +{ + if (enabled.toBool() && _cameraTriggerInTurnAroundFact.rawValue().toBool()) { + qDebug() << "_handleHoverAndCaptureEnabled"; + _cameraTriggerInTurnAroundFact.setRawValue(false); + } +} diff --git a/src/MissionManager/TransectStyleComplexItem.h b/src/MissionManager/TransectStyleComplexItem.h index 6e82ac134aaa7cb525a2ee227edb3dadc580c488..12871f71e3372db860de6bbcaecaf9caf280ed8d 100644 --- a/src/MissionManager/TransectStyleComplexItem.h +++ b/src/MissionManager/TransectStyleComplexItem.h @@ -205,6 +205,7 @@ protected: private slots: void _reallyQueryTransectsPathHeightInfo(void); void _followTerrainChanged (bool followTerrain); + void _handleHoverAndCaptureEnabled (QVariant enabled); private: void _queryTransectsPathHeightInfo (void); diff --git a/src/PlanView/PlanView.qml b/src/PlanView/PlanView.qml index b8dce7330adc8efeab9feb18d7cc2d17f9dff0c9..a1fe01407d22cb16b2ea5e0ef5a6f55450418526 100644 --- a/src/PlanView/PlanView.qml +++ b/src/PlanView/PlanView.qml @@ -916,6 +916,7 @@ Item { } else { _planMasterController.removeAllFromVehicle() } + _missionController.setCurrentPlanViewIndex(0, true) hideDialog() } } @@ -927,6 +928,7 @@ Item { message: qsTr("Are you sure you want to remove all mission items and clear the mission from the vehicle?") function accept() { _planMasterController.removeAllFromVehicle() + _missionController.setCurrentPlanViewIndex(0, true) hideDialog() } } diff --git a/src/PlanView/SurveyItemEditor.qml b/src/PlanView/SurveyItemEditor.qml index 8a344bfdf44c092061fd4b7b0862c8a599659746..a5644517a177f1c526f12b5646422f319d8211cc 100644 --- a/src/PlanView/SurveyItemEditor.qml +++ b/src/PlanView/SurveyItemEditor.qml @@ -162,7 +162,9 @@ Rectangle { cameraCalc: missionItem.cameraCalc vehicleFlightIsFrontal: true distanceToSurfaceLabel: qsTr("Altitude") - distanceToSurfaceAltitudeMode: missionItem.followTerrain ? QGroundControl.AltitudeModeAboveTerrain : QGroundControl.AltitudeModeRelative + distanceToSurfaceAltitudeMode: missionItem.followTerrain ? + QGroundControl.AltitudeModeAboveTerrain : + missionItem.cameraCalc.distanceToSurfaceRelative frontalDistanceLabel: qsTr("Trigger Dist") sideDistanceLabel: qsTr("Spacing") usingPreset: _usingPreset @@ -235,48 +237,47 @@ Rectangle { } */ - FactCheckBox { - text: qsTr("Hover and capture image") - fact: missionItem.hoverAndCapture - visible: missionItem.hoverAndCaptureAllowed - enabled: !missionItem.followTerrain - onClicked: { - if (checked) { - missionItem.cameraTriggerInTurnAround.rawValue = false + QGCOptionsComboBox { + Layout.fillWidth: true + + model: [ + { + text: qsTr("Hover and capture image"), + fact: missionItem.hoverAndCapture, + enabled: !missionItem.followTerrain, + visible: missionItem.hoverAndCaptureAllowed + }, + { + text: qsTr("Refly at 90 deg offset"), + fact: missionItem.refly90Degrees, + enabled: !missionItem.followTerrain, + visible: true + }, + { + text: qsTr("Images in turnarounds"), + fact: missionItem.cameraTriggerInTurnAround, + enabled: missionItem.hoverAndCaptureAllowed ? !missionItem.hoverAndCapture.rawValue : true, + visible: true + }, + { + text: qsTr("Fly alternate transects"), + fact: missionItem.flyAlternateTransects, + enabled: true, + visible: _vehicle ? (_vehicle.fixedWing || _vehicle.vtol) : false + }, + { + text: qsTr("Relative altitude"), + enabled: missionItem.cameraCalc.isManualCamera && !missionItem.followTerrain, + visible: QGroundControl.corePlugin.options.showMissionAbsoluteAltitude || (!missionItem.cameraCalc.distanceToSurfaceRelative && !missionItem.followTerrain), + checked: missionItem.cameraCalc.distanceToSurfaceRelative } - } - } - - FactCheckBox { - text: qsTr("Refly at 90 deg offset") - fact: missionItem.refly90Degrees - enabled: !missionItem.followTerrain - } - - FactCheckBox { - text: qsTr("Images in turnarounds") - fact: missionItem.cameraTriggerInTurnAround - enabled: missionItem.hoverAndCaptureAllowed ? !missionItem.hoverAndCapture.rawValue : true - } + ] - FactCheckBox { - text: qsTr("Fly alternate transects") - fact: missionItem.flyAlternateTransects - visible: _vehicle ? (_vehicle.fixedWing || _vehicle.vtol) : false - } - - QGCCheckBox { - id: relAlt - Layout.alignment: Qt.AlignLeft - text: qsTr("Relative altitude") - checked: missionItem.cameraCalc.distanceToSurfaceRelative - enabled: missionItem.cameraCalc.isManualCamera && !missionItem.followTerrain - visible: QGroundControl.corePlugin.options.showMissionAbsoluteAltitude || (!missionItem.cameraCalc.distanceToSurfaceRelative && !missionItem.followTerrain) - onClicked: missionItem.cameraCalc.distanceToSurfaceRelative = checked - - Connections { - target: missionItem.cameraCalc - onDistanceToSurfaceRelativeChanged: relAlt.checked = missionItem.cameraCalc.distanceToSurfaceRelative + onItemClicked: { + if (index == 4) { + missionItem.cameraCalc.distanceToSurfaceRelative = !missionItem.cameraCalc.distanceToSurfaceRelative + console.log(missionItem.cameraCalc.distanceToSurfaceRelative) + } } } } diff --git a/src/QmlControls/QGCOptionsComboBox.qml b/src/QmlControls/QGCOptionsComboBox.qml new file mode 100644 index 0000000000000000000000000000000000000000..6a5d6796efd3812e3391369bad30ad2c3eea4c1a --- /dev/null +++ b/src/QmlControls/QGCOptionsComboBox.qml @@ -0,0 +1,169 @@ +/**************************************************************************** + * + * (c) 2009-2019 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + * @file + * @author Gus Grubba + */ + +import QtQuick 2.11 +import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.11 + +import QGroundControl.Controls 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.ScreenTools 1.0 + +ComboBox { + id: control + padding: ScreenTools.comboBoxPadding + + property string labelText: qsTr("Options") + + signal itemClicked(int index) + + property var _controlQGCPal: QGCPalette { colorGroupEnabled: enabled } + property bool _flashChecked + property string _flashText + property bool _showFlash: false + + background: Rectangle { + implicitWidth: ScreenTools.implicitComboBoxWidth + implicitHeight: ScreenTools.implicitComboBoxHeight + color: _controlQGCPal.window + border.width: enabled ? 1 : 0 + border.color: "#999" + } + + /*! Adding the Combobox list item to the theme. */ + + delegate: ItemDelegate { + implicitHeight: modelData.visible ? + (Math.max(background ? background.implicitHeight : 0, Math.max(contentItem.implicitHeight, indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)) : + 0 + width: control.width + checkable: true + enabled: modelData.enabled + text: modelData.text + + property var _checkedValue: 1 + property var _uncheckedValue: 0 + property var _itemQGCPal: QGCPalette { colorGroupEnabled: enabled } + property var _control: control + + Binding on checked { value: modelData.fact ? + (modelData.fact.typeIsBool ? (modelData.fact.value === false ? Qt.Unchecked : Qt.Checked) : (modelData.fact.value === 0 ? Qt.Unchecked : Qt.Checked)) : + modelData.checked } + + + contentItem: RowLayout { + spacing: ScreenTools.defaultFontPixelWidth + + Rectangle { + height: ScreenTools.defaultFontPixelHeight + width: height + border.color: _itemQGCPal.buttonText + border.width: 1 + color: _itemQGCPal.button + + QGCColoredImage { + anchors.centerIn: parent + width: parent.width * 0.75 + height: width + source: "/qmlimages/checkbox-check.svg" + color: _itemQGCPal.buttonText + mipmap: true + fillMode: Image.PreserveAspectFit + sourceSize.height: height + visible: checked + } + } + + Text { + text: modelData.text + color: _itemQGCPal.buttonText + } + + } + + background: Rectangle { + color: _controlQGCPal.button + } + + onClicked: { + if (modelData.fact) { + modelData.fact.value = (checked ? _checkedValue : _uncheckedValue) + } else { + itemClicked(index) + } + _control._flashChecked = checked + _control._flashText = text + _control._showFlash = true + _control.popup.close() + } + } + + /*! This defines the label of the button. */ + contentItem: Item { + implicitWidth: _showFlash ? flash.implicitWidth : text.implicitWidth + implicitHeight: _showFlash ? flash.implicitHeight : text.implicitHeight + + QGCLabel { + id: text + anchors.verticalCenter: parent.verticalCenter + text: labelText + color: _controlQGCPal.text + visible: !_showFlash + } + + RowLayout { + id: flash + anchors.verticalCenter: parent.verticalCenter + spacing: ScreenTools.defaultFontPixelWidth + visible: _showFlash + + onVisibleChanged: { + if (visible) { + flashTimer.restart() + } + } + + Timer { + id: flashTimer + interval: 1500 + repeat: false + running: false + onTriggered: _showFlash = false + } + + Rectangle { + height: ScreenTools.defaultFontPixelHeight + width: height + border.color: _controlQGCPal.buttonText + border.width: 1 + color: _controlQGCPal.window + + QGCColoredImage { + anchors.centerIn: parent + width: parent.width * 0.75 + height: width + source: "/qmlimages/checkbox-check.svg" + color: _controlQGCPal.text + mipmap: true + fillMode: Image.PreserveAspectFit + sourceSize.height: height + visible: _flashChecked + } + } + + Text { + text: _flashText + color: _controlQGCPal.buttonText + } + + } + } +} diff --git a/src/QmlControls/QGroundControl/Controls/qmldir b/src/QmlControls/QGroundControl/Controls/qmldir index b0e8cb7c7154eadd5eea21be4d2d8896dcd225b0..247487ab7abe1cd5a7330c0bd6037dd8eb0edb93 100644 --- a/src/QmlControls/QGroundControl/Controls/qmldir +++ b/src/QmlControls/QGroundControl/Controls/qmldir @@ -58,6 +58,7 @@ QGCMenuItem 1.0 QGCMenuItem.qml QGCMenuSeparator 1.0 QGCMenuSeparator.qml QGCMouseArea 1.0 QGCMouseArea.qml QGCMovableItem 1.0 QGCMovableItem.qml +QGCOptionsComboBox 1.0 QGCOptionsComboBox.qml QGCPipable 1.0 QGCPipable.qml QGCRadioButton 1.0 QGCRadioButton.qml QGCSlider 1.0 QGCSlider.qml