diff --git a/custom-example/res/CustomFlyView.qml b/custom-example/res/CustomFlyView.qml index 3ec772414e9baca2cfb0a2ecc73babf3dcb86b22..90760fa58bf758fe7d0b9bf9e1ed0eb08afec139 100644 --- a/custom-example/res/CustomFlyView.qml +++ b/custom-example/res/CustomFlyView.qml @@ -605,12 +605,11 @@ Item { } //------------------------------------------------------------------------- //-- Object Avoidance - Rectangle { + Item { visible: activeVehicle && activeVehicle.objectAvoidance.available && activeVehicle.objectAvoidance.enabled anchors.centerIn: parent width: parent.width * 0.5 height: parent.height * 0.5 - color: Qt.rgba(0,0,0,0.25) Repeater { model: activeVehicle && activeVehicle.objectAvoidance.gridSize > 0 ? activeVehicle.objectAvoidance.gridSize : [] Rectangle { diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.cc b/src/AutoPilotPlugins/PX4/SafetyComponent.cc index 047b7a3cabb542bdce2613f8d4a60500a195c5aa..06224bfe3a9ca68121dcce9285e0dd316b3bff7a 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.cc +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.cc @@ -27,7 +27,7 @@ QString SafetyComponent::name(void) const QString SafetyComponent::description(void) const { - return tr("Safety Setup is used to setup triggers for Return to Land as well as the settings for Return to Land itself."); + return QString(); } QString SafetyComponent::iconResource(void) const diff --git a/src/AutoPilotPlugins/PX4/SafetyComponent.qml b/src/AutoPilotPlugins/PX4/SafetyComponent.qml index c40ace809950b026f4dc5390f79f300760e9df49..ac096ca2fda5af26d874ef8533d3bfdbe83ca20f 100644 --- a/src/AutoPilotPlugins/PX4/SafetyComponent.qml +++ b/src/AutoPilotPlugins/PX4/SafetyComponent.qml @@ -170,12 +170,11 @@ SetupPage { enabled: _collisionPrevention Layout.minimumWidth:_editFieldWidth Layout.fillWidth: true - Component.onCompleted: { - currentIndex = _collisionPrevention ? (_collisionPrevention.value > 0 ? 1 : 0) : 0 - } + currentIndex: _collisionPrevention ? (_collisionPrevention.rawValue > 0 ? 1 : 0) : 0 onActivated: { if(_collisionPrevention) { _collisionPrevention.value = index > 0 ? 5 : -1 + console.log('Collision prevention enabled: ' + _collisionPrevention.value) } } } @@ -186,14 +185,10 @@ SetupPage { } QGCComboBox { model: [qsTr("Disabled"), qsTr("Enabled")] - enabled: _objectAvoidance + enabled: _objectAvoidance && _collisionPrevention.rawValue > 0 Layout.minimumWidth:_editFieldWidth Layout.fillWidth: true - Component.onCompleted: { - if(_objectAvoidance) { - currentIndex = _objectAvoidance.value === 0 ? 0 : 1 - } - } + currentIndex: _objectAvoidance ? (_objectAvoidance.value === 0 ? 0 : 1) : 0 onActivated: { if(_objectAvoidance) { _objectAvoidance.value = index > 0 ? 1 : 0 @@ -208,25 +203,26 @@ SetupPage { } QGCSlider { width: _editFieldWidth - enabled: _collisionPrevention + enabled: _collisionPrevention && _collisionPrevention.rawValue > 0 Layout.minimumWidth:_editFieldWidth Layout.minimumHeight: ScreenTools.defaultFontPixelHeight * 2 Layout.fillWidth: true Layout.fillHeight: true - maximumValue: 1 - minimumValue: 15 + maximumValue: 15 + minimumValue: 0 stepSize: 1 displayValue: true updateValueWhileDragging: false Layout.alignment: Qt.AlignVCenter - Component.onCompleted: { - if(_collisionPrevention && _collisionPrevention.value > 0) { - value = _collisionPrevention.value - } - } + //-- Looking at raw value on purpose. I don't know how to handle the + // slider range when not using metric system. + value: (_collisionPrevention && _collisionPrevention.rawValue > 0) ? _collisionPrevention.rawValue : 0 onValueChanged: { if(_collisionPrevention) { - _collisionPrevention.value = value + //-- Negative means disabled + if(_collisionPrevention.rawValue >= 0) { + _collisionPrevention.rawValue = value + } } } }