diff --git a/src/AutoPilotPlugins/APM/APMAirframeComponentController.cc b/src/AutoPilotPlugins/APM/APMAirframeComponentController.cc index 670005397999eda03d4c4cc74c1302c51fad5937..c37baef66a1f2aef0d0f451ff6d1126e2ed8ba8a 100644 --- a/src/AutoPilotPlugins/APM/APMAirframeComponentController.cc +++ b/src/AutoPilotPlugins/APM/APMAirframeComponentController.cc @@ -40,14 +40,17 @@ APMAirframeComponentController::APMAirframeComponentController(void) : } _fillAirFrames(); - Fact* frame; + Fact* frame = NULL; if (parameterExists(FactSystem::defaultComponentId, _oldFrameParam)) { frame = getParameterFact(FactSystem::defaultComponentId, _oldFrameParam); - } else { + } else if (parameterExists(FactSystem::defaultComponentId, _newFrameParam)){ frame = getParameterFact(FactSystem::defaultComponentId, _newFrameParam); } - connect(frame, &Fact::rawValueChanged, this, &APMAirframeComponentController::_factFrameChanged); - _factFrameChanged(frame->rawValue()); + + if (frame) { + connect(frame, &Fact::rawValueChanged, this, &APMAirframeComponentController::_factFrameChanged); + _factFrameChanged(frame->rawValue()); + } } APMAirframeComponentController::~APMAirframeComponentController() diff --git a/src/AutoPilotPlugins/APM/APMSubFrameComponent.qml b/src/AutoPilotPlugins/APM/APMSubFrameComponent.qml index d5d2e35395c2b43ac544a871b9c71430a103daa8..014e0675e1375d383e8df0581bf1860c1679bc34 100644 --- a/src/AutoPilotPlugins/APM/APMSubFrameComponent.qml +++ b/src/AutoPilotPlugins/APM/APMSubFrameComponent.qml @@ -10,16 +10,26 @@ import QtQuick 2.3 import QtQuick.Controls 1.2 +import QtQuick.Dialogs 1.2 import QGroundControl.FactSystem 1.0 import QGroundControl.FactControls 1.0 import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 +import QGroundControl.Controllers 1.0 SetupPage { id: subFramePage pageComponent: subFramePageComponent + property var _flatParamList: ListModel { + ListElement { + name: "Blue Robotics BlueROV2" + file: "Sub/bluerov2-3_5.params" + } + } + + APMAirframeComponentController { id: controller; factPanel: subFramePage.viewPanel } Component { id: subFramePageComponent @@ -28,8 +38,6 @@ SetupPage { id: mainColumn width: availableWidth - FactPanelController { id: controller; factPanel: subFramePage.viewPanel } - QGCPalette { id: palette; colorGroupEnabled: true } property Fact _frameConfig: controller.getParameterFact(-1, "FRAME_CONFIG") @@ -100,6 +108,19 @@ SetupPage { } } + Item { + anchors.left: parent.left + anchors.right: parent.right + height: defaultsButton.height + + QGCButton { + id: defaultsButton + anchors.left: parent.left + text: qsTr("Load Vehicle Default Parameters") + onClicked: showDialog(selectParamFileDialogComponent, qsTr("Load Vehicle Default Parameters"), qgcView.showDialogDefaultWidth, StandardButton.Close) + } + } + Flow { id: flowView width: parent.width @@ -148,4 +169,47 @@ SetupPage { }// Flow } // Column } // Component + + + Component { + id: selectParamFileDialogComponent + + QGCViewDialog { + QGCLabel { + id: applyParamsText + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: _margins + wrapMode: Text.WordWrap + text: qsTr("Select your vehicle to load the default parameters:") + } + + Flow { + anchors.margins: _margins + anchors.top: applyParamsText.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + spacing : _margins + layoutDirection: Qt.Vertical; + + Repeater { + id: airframePicker + model: _flatParamList + + delegate: QGCButton { + width: parent.width / 2.1 + height: (ScreenTools.defaultFontPixelHeight * 14) / 5 + text: name + + onClicked : { + controller.loadParameters(file) + hideDialog() + } + } + } + } + } + } } // SetupPage