From 64095e3850791a6a72a7a389da9288420538da93 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Fri, 29 May 2015 09:52:53 -0700 Subject: [PATCH] Add setup pre-req check --- src/VehicleSetup/SetupView.cc | 5 ++--- src/VehicleSetup/SetupView.h | 2 +- src/VehicleSetup/SetupView.qml | 21 +++++++++++++++------ src/VehicleSetup/SetupViewTest.cc | 3 ++- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/VehicleSetup/SetupView.cc b/src/VehicleSetup/SetupView.cc index fa8398811..a744f4893 100644 --- a/src/VehicleSetup/SetupView.cc +++ b/src/VehicleSetup/SetupView.cc @@ -127,14 +127,13 @@ void SetupView::showSummary(void) Q_ASSERT(success); } -void SetupView::showVehicleComponentSetup(const QUrl& url) +void SetupView::showVehicleComponentSetup(VehicleComponent* vehicleComponent) { QVariant returnedValue; - QVariant varSource = url; bool success = QMetaObject::invokeMethod(getRootObject(), "showVehicleComponentPanel", Q_RETURN_ARG(QVariant, returnedValue), - Q_ARG(QVariant, varSource)); + Q_ARG(QVariant, QVariant::fromValue((VehicleComponent*)vehicleComponent))); Q_ASSERT(success); } #endif diff --git a/src/VehicleSetup/SetupView.h b/src/VehicleSetup/SetupView.h index dcca47bed..c8566251c 100644 --- a/src/VehicleSetup/SetupView.h +++ b/src/VehicleSetup/SetupView.h @@ -50,7 +50,7 @@ public: void showFirmware(void); void showParameters(void); void showSummary(void); - void showVehicleComponentSetup(const QUrl& url); + void showVehicleComponentSetup(VehicleComponent* vehicleComponent); #endif AutoPilotPlugin* autopilot(void); diff --git a/src/VehicleSetup/SetupView.qml b/src/VehicleSetup/SetupView.qml index 3dd60eadb..5eb099515 100644 --- a/src/VehicleSetup/SetupView.qml +++ b/src/VehicleSetup/SetupView.qml @@ -76,13 +76,18 @@ Rectangle { panelLoader.source = "SetupParameterEditor.qml"; } - function showVehicleComponentPanel(setupSource) + function showVehicleComponentPanel(vehicleComponent) { if (controller.autopilot.armed) { messagePanelText = armedVehicleText panelLoader.sourceComponent = messagePanelComponent } else { - panelLoader.source = setupSource + if (vehicleComponent.prerequisiteSetup != "") { + messagePanelText = vehicleComponent.prerequisiteSetup + " setup must be completed prior to " + vehicleComponent.name + " setup." + panelLoader.sourceComponent = messagePanelComponent + } else { + panelLoader.source = vehicleComponent.setupSource + } } } @@ -126,9 +131,13 @@ Rectangle { Item { QGCLabel { - anchors.fill: parent - wrapMode: Text.WordWrap - text: messagePanelText + anchors.margins: defaultTextWidth * 2 + anchors.fill: parent + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + font.pointSize: ScreenTools.mediumFontPointSize + text: messagePanelText } } } @@ -170,7 +179,7 @@ Rectangle { exclusiveGroup: setupButtonGroup text: modelData.name.toUpperCase() - onClicked: showVehicleComponentPanel(modelData.setupSource) + onClicked: showVehicleComponentPanel(modelData) } } diff --git a/src/VehicleSetup/SetupViewTest.cc b/src/VehicleSetup/SetupViewTest.cc index 72449715e..eedcf433c 100644 --- a/src/VehicleSetup/SetupViewTest.cc +++ b/src/VehicleSetup/SetupViewTest.cc @@ -106,7 +106,8 @@ void SetupViewTest::_clickThrough_test(void) foreach(QVariant varComponent, components) { VehicleComponent* component = qobject_cast(qvariant_cast(varComponent)); qDebug() << "Showing" << component->name(); - setupView->showVehicleComponentSetup(component->setupSource()); + setupView->showVehicleComponentSetup(component); + QTest::qWait(1000); } // On MainWindow close we should get a message box telling the user to disconnect first. Disconnect will then pop -- 2.22.0