From f3f54cd574de1f5a1691df1cf847de6043309feb Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sun, 13 Mar 2016 12:53:19 -0700 Subject: [PATCH] Pull multiVehicleManager from QGroundControl --- src/FlightDisplay/FlightDisplayView.qml | 4 ++-- src/FlightDisplay/FlightDisplayViewMap.qml | 4 ++-- src/FlightDisplay/FlightDisplayViewVideo.qml | 2 +- .../FlightDisplayViewWidgets.qml | 4 ++-- src/FlightMap/Widgets/QGCInstrumentWidget.qml | 2 +- src/MissionEditor/MissionEditor.qml | 8 +++---- src/QGCApplication.cc | 1 - src/QGCQuickWidget.cc | 1 - src/QmlControls/ParameterEditor.qml | 2 +- src/VehicleSetup/FirmwareUpgrade.qml | 2 +- src/VehicleSetup/JoystickConfig.qml | 3 ++- src/VehicleSetup/PX4FlowSensor.qml | 24 +++++++++---------- src/VehicleSetup/SetupView.qml | 18 +++++++------- src/VehicleSetup/VehicleSummary.qml | 5 ++-- src/ui/MainWindowInner.qml | 4 ++-- src/ui/preferences/MavlinkSettings.qml | 4 ++-- src/ui/toolbar/MainToolBar.qml | 2 +- src/ui/toolbar/MainToolBarIndicators.qml | 12 +++++----- 18 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 1dfa87a38..fdced82c0 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -47,7 +47,7 @@ QGCView { QGCPalette { id: qgcPal; colorGroupEnabled: enabled } property real availableHeight: parent.height - property var _activeVehicle: multiVehicleManager.activeVehicle + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property bool _mainIsMap: QGroundControl.loadBoolGlobalSetting(_mainIsMapKey, true) @@ -121,7 +121,7 @@ QGCView { } Connections { - target: multiVehicleManager + target: QGroundControl.multiVehicleManager onActiveVehicleChanged: px4JoystickCheck() } diff --git a/src/FlightDisplay/FlightDisplayViewMap.qml b/src/FlightDisplay/FlightDisplayViewMap.qml index 884719ea9..9e2c630d4 100644 --- a/src/FlightDisplay/FlightDisplayViewMap.qml +++ b/src/FlightDisplay/FlightDisplayViewMap.qml @@ -72,7 +72,7 @@ FlightMap { // Add trajectory points to the map MapItemView { - model: _mainIsMap ? multiVehicleManager.activeVehicle ? multiVehicleManager.activeVehicle.trajectoryPoints : 0 : 0 + model: _mainIsMap ? _activeVehicle ? _activeVehicle.trajectoryPoints : 0 : 0 delegate: MapPolyline { line.width: 3 @@ -87,7 +87,7 @@ FlightMap { // Add the vehicles to the map MapItemView { - model: multiVehicleManager.vehicles + model: QGroundControl.multiVehicleManager.vehicles delegate: VehicleMapItem { vehicle: object diff --git a/src/FlightDisplay/FlightDisplayViewVideo.qml b/src/FlightDisplay/FlightDisplayViewVideo.qml index f98c0b5fa..eb90d3c6d 100644 --- a/src/FlightDisplay/FlightDisplayViewVideo.qml +++ b/src/FlightDisplay/FlightDisplayViewVideo.qml @@ -63,7 +63,7 @@ Item { pitchAngle: _pitch width: ScreenTools.defaultFontPixelSize * (30) height: ScreenTools.defaultFontPixelSize * (30) - active: multiVehicleManager.activeVehicleAvailable + active: QGroundControl.multiVehicleManager.activeVehicleAvailable z: QGroundControl.zOrderWidgets } */ diff --git a/src/FlightDisplay/FlightDisplayViewWidgets.qml b/src/FlightDisplay/FlightDisplayViewWidgets.qml index 371ffcf17..5f1112872 100644 --- a/src/FlightDisplay/FlightDisplayViewWidgets.qml +++ b/src/FlightDisplay/FlightDisplayViewWidgets.qml @@ -68,7 +68,7 @@ Item { width: parent.width Repeater { - model: multiVehicleManager.vehicles + model: QGroundControl.multiVehicleManager.vehicles delegate: QGCLabel { @@ -180,7 +180,7 @@ Item { text: "Center map on Vehicle" enabled: _activeVehicle && !followVehicleCheckBox.checked - property var activeVehicle: multiVehicleManager.activeVehicle + property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle onClicked: { _dropButtonsExclusiveGroup.current = null diff --git a/src/FlightMap/Widgets/QGCInstrumentWidget.qml b/src/FlightMap/Widgets/QGCInstrumentWidget.qml index 0573beb78..694072839 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidget.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidget.qml @@ -104,7 +104,7 @@ Item { opacity: 0.5 width: attitudeWidget.width * 0.15 fillMode: Image.PreserveAspectFit - visible: QGroundControl.multiVehicleManager.activeVehicle + visible: _activeVehicle MouseArea { anchors.fill: parent diff --git a/src/MissionEditor/MissionEditor.qml b/src/MissionEditor/MissionEditor.qml index d83d797c7..d0017fa6e 100644 --- a/src/MissionEditor/MissionEditor.qml +++ b/src/MissionEditor/MissionEditor.qml @@ -51,7 +51,7 @@ QGCView { readonly property int _decimalPlaces: 8 readonly property real _horizontalMargin: ScreenTools.defaultFontPixelWidth / 2 readonly property real _margin: ScreenTools.defaultFontPixelHeight / 2 - readonly property var _activeVehicle: multiVehicleManager.activeVehicle + readonly property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle readonly property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 16 readonly property real _rightPanelWidth: Math.min(parent.width / 3, ScreenTools.defaultFontPixelWidth * 30) readonly property real _rightPanelOpacity: 0.8 @@ -68,7 +68,7 @@ QGCView { onActiveVehiclePositionChanged: updateMapToVehiclePosition() Connections { - target: multiVehicleManager + target: QGroundControl.multiVehicleManager onActiveVehicleChanged: { // When the active vehicle changes we need to allow the first vehicle position to move the map again @@ -443,7 +443,7 @@ QGCView { // Add the vehicles to the map MapItemView { - model: multiVehicleManager.vehicles + model: QGroundControl.multiVehicleManager.vehicles delegate: VehicleMapItem { vehicle: object @@ -596,7 +596,7 @@ QGCView { text: "Vehicle" enabled: activeVehicle && activeVehicle.latitude != 0 && activeVehicle.longitude != 0 - property var activeVehicle: multiVehicleManager.activeVehicle + property var activeVehicle: _activeVehicle onClicked: { centerMapButton.hideDropDown() diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index a890f5e00..f7090f0ed 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -483,7 +483,6 @@ bool QGCApplication::_initForNormalAppBoot(void) #ifdef __mobile__ _qmlAppEngine = new QQmlApplicationEngine(this); _qmlAppEngine->addImportPath("qrc:/qml"); - _qmlAppEngine->rootContext()->setContextProperty("multiVehicleManager", toolbox()->multiVehicleManager()); _qmlAppEngine->rootContext()->setContextProperty("joystickManager", toolbox()->joystickManager()); _qmlAppEngine->load(QUrl(QStringLiteral("qrc:/qml/MainWindowNative.qml"))); #else diff --git a/src/QGCQuickWidget.cc b/src/QGCQuickWidget.cc index 0993a4323..b51002f23 100644 --- a/src/QGCQuickWidget.cc +++ b/src/QGCQuickWidget.cc @@ -41,7 +41,6 @@ QGCQuickWidget::QGCQuickWidget(QWidget* parent) : { setAttribute(Qt::WA_AcceptTouchEvents); rootContext()->engine()->addImportPath("qrc:/qml"); - rootContext()->setContextProperty("multiVehicleManager", qgcApp()->toolbox()->multiVehicleManager()); rootContext()->setContextProperty("joystickManager", qgcApp()->toolbox()->joystickManager()); } diff --git a/src/QmlControls/ParameterEditor.qml b/src/QmlControls/ParameterEditor.qml index d2ce7fc7b..c0ccf753f 100644 --- a/src/QmlControls/ParameterEditor.qml +++ b/src/QmlControls/ParameterEditor.qml @@ -48,7 +48,7 @@ QGCView { property bool _searchFilter: false ///< true: showing results of search property var _searchResults ///< List of parameter names from search results property string _currentGroup: "" - property bool _showRCToParam: !ScreenTools.isMobile && multiVehicleManager.activeVehicle.px4Firmware + property bool _showRCToParam: !ScreenTools.isMobile && QGroundControl.multiVehicleManager.activeVehicle.px4Firmware ParameterEditorController { id: controller; diff --git a/src/VehicleSetup/FirmwareUpgrade.qml b/src/VehicleSetup/FirmwareUpgrade.qml index 0af389306..b637b46f1 100644 --- a/src/VehicleSetup/FirmwareUpgrade.qml +++ b/src/VehicleSetup/FirmwareUpgrade.qml @@ -102,7 +102,7 @@ QGCView { // Board was found right away, so something is already plugged in before we've started upgrade statusTextArea.append(qgcUnplugText1) statusTextArea.append(qgcUnplugText2) - multiVehicleManager.activeVehicle.autoDisconnect = true + QGroundControl.multiVehicleManager.activeVehicle.autoDisconnect = true } else { // We end up here when we detect a board plugged in after we've started upgrade statusTextArea.append(highlightPrefix + "Found device" + highlightSuffix + ": " + controller.boardType) diff --git a/src/VehicleSetup/JoystickConfig.qml b/src/VehicleSetup/JoystickConfig.qml index c5926410f..9f2a3c539 100644 --- a/src/VehicleSetup/JoystickConfig.qml +++ b/src/VehicleSetup/JoystickConfig.qml @@ -25,6 +25,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Dialogs 1.2 +import QGroundControl 1.0 import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 @@ -43,7 +44,7 @@ QGCView { property bool controllerCompleted: false property bool controllerAndViewReady: false - property var _activeVehicle: multiVehicleManager.activeVehicle + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property var _activeJoystick: joystickManager.activeJoystick JoystickConfigController { diff --git a/src/VehicleSetup/PX4FlowSensor.qml b/src/VehicleSetup/PX4FlowSensor.qml index 95805261e..94cc07e4f 100644 --- a/src/VehicleSetup/PX4FlowSensor.qml +++ b/src/VehicleSetup/PX4FlowSensor.qml @@ -21,24 +21,24 @@ ======================================================================*/ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.2 -import QtQuick.Dialogs 1.2 +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 +import QtQuick.Dialogs 1.2 -import QGroundControl.Controls 1.0 -import QGroundControl.FactSystem 1.0 -import QGroundControl.FactControls 1.0 -import QGroundControl.Palette 1.0 -import QGroundControl.Controllers 1.0 -import QGroundControl.ScreenTools 1.0 -import QGroundControl.MultiVehicleManager 1.0 +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controllers 1.0 +import QGroundControl.ScreenTools 1.0 QGCView { id: qgcView viewPanel: panel - property var _activeVehicle: multiVehicleManager.activeVehicle + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } diff --git a/src/VehicleSetup/SetupView.qml b/src/VehicleSetup/SetupView.qml index cb4ee371d..e39058755 100644 --- a/src/VehicleSetup/SetupView.qml +++ b/src/VehicleSetup/SetupView.qml @@ -50,17 +50,17 @@ Rectangle { readonly property string _armedVehicleText: "This operation cannot be performed while vehicle is armed." property string _messagePanelText: "missing message panel text" - property bool _fullParameterVehicleAvailable: multiVehicleManager.parameterReadyVehicleAvailable && !multiVehicleManager.activeVehicle.missingParameters + property bool _fullParameterVehicleAvailable: QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable && !QGroundControl.multiVehicleManager.activeVehicle.missingParameters function showSummaryPanel() { if (_fullParameterVehicleAvailable) { - if (multiVehicleManager.activeVehicle.autopilot.vehicleComponents.length == 0) { + if (QGroundControl.multiVehicleManager.activeVehicle.autopilot.vehicleComponents.length == 0) { panelLoader.sourceComponent = noComponentsVehicleSummaryComponent } else { panelLoader.source = "VehicleSummary.qml"; } - } else if (multiVehicleManager.parameterReadyVehicleAvailable) { + } else if (QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable) { panelLoader.sourceComponent = missingParametersVehicleSummaryComponent } else { panelLoader.sourceComponent = disconnectedVehicleSummaryComponent @@ -70,7 +70,7 @@ Rectangle { function showFirmwarePanel() { if (!ScreenTools.isMobile) { - if (multiVehicleManager.activeVehicleAvailable && multiVehicleManager.activeVehicle.armed) { + if (QGroundControl.multiVehicleManager.activeVehicleAvailable && QGroundControl.multiVehicleManager.activeVehicle.armed) { _messagePanelText = _armedVehicleText panelLoader.sourceComponent = messagePanelComponent } else { @@ -81,7 +81,7 @@ Rectangle { function showJoystickPanel() { - if (multiVehicleManager.activeVehicleAvailable && multiVehicleManager.activeVehicle.armed) { + if (QGroundControl.multiVehicleManager.activeVehicleAvailable && QGroundControl.multiVehicleManager.activeVehicle.armed) { _messagePanelText = _armedVehicleText panelLoader.sourceComponent = messagePanelComponent } else { @@ -101,7 +101,7 @@ Rectangle { function showVehicleComponentPanel(vehicleComponent) { - if (multiVehicleManager.activeVehicle.armed && !vehicleComponent.allowSetupWhileArmed) { + if (QGroundControl.multiVehicleManager.activeVehicle.armed && !vehicleComponent.allowSetupWhileArmed) { _messagePanelText = _armedVehicleText panelLoader.sourceComponent = messagePanelComponent } else { @@ -117,7 +117,7 @@ Rectangle { Component.onCompleted: showSummaryPanel() Connections { - target: multiVehicleManager + target: QGroundControl.multiVehicleManager onParameterReadyVehicleAvailableChanged: { if (parameterReadyVehicleAvailable || summaryButton.checked || setupButtonGroup.current != firmwareButton) { @@ -295,7 +295,7 @@ Rectangle { Repeater { id: componentRepeater - model: _fullParameterVehicleAvailable ? multiVehicleManager.activeVehicle.autopilot.vehicleComponents : 0 + model: _fullParameterVehicleAvailable ? QGroundControl.multiVehicleManager.activeVehicle.autopilot.vehicleComponents : 0 SubMenuButton { imageResource: modelData.iconResource @@ -313,7 +313,7 @@ Rectangle { SubMenuButton { setupIndicator: false exclusiveGroup: setupButtonGroup - visible: multiVehicleManager.parameterReadyVehicleAvailable + visible: QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable text: "Parameters" onClicked: showParametersPanel() diff --git a/src/VehicleSetup/VehicleSummary.qml b/src/VehicleSetup/VehicleSummary.qml index 82b402957..e44ada102 100644 --- a/src/VehicleSetup/VehicleSummary.qml +++ b/src/VehicleSetup/VehicleSummary.qml @@ -25,6 +25,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 +import QGroundControl 1.0 import QGroundControl.FactSystem 1.0 import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 @@ -95,7 +96,7 @@ Rectangle { text: setupComplete ? "Below you will find a summary of the settings for your vehicle. To the left are the setup menus for each component." : "WARNING: Your vehicle requires setup prior to flight. Please resolve the items marked in red using the menu on the left." - property bool setupComplete: multiVehicleManager.activeVehicle ? multiVehicleManager.activeVehicle.autopilot.setupComplete : false + property bool setupComplete: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.autopilot.setupComplete : false } Flow { @@ -104,7 +105,7 @@ Rectangle { spacing: _summaryBoxSpace Repeater { - model: multiVehicleManager.activeVehicle ? multiVehicleManager.activeVehicle.autopilot.vehicleComponents : undefined + model: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.autopilot.vehicleComponents : undefined // Outer summary item rectangle Rectangle { diff --git a/src/ui/MainWindowInner.qml b/src/ui/MainWindowInner.qml index e515a9288..cf249e516 100644 --- a/src/ui/MainWindowInner.qml +++ b/src/ui/MainWindowInner.qml @@ -53,7 +53,7 @@ Item { property var gcsPosition: QtPositioning.coordinate() // Starts as invalid coordinate property var currentPopUp: null property real currentCenterX: 0 - property var activeVehicle: multiVehicleManager.activeVehicle + property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property string formatedMessage: activeVehicle ? activeVehicle.formatedMessage : "" function showFlyView() { @@ -232,7 +232,7 @@ Item { if(currentPopUp) { currentPopUp.close() } - if(multiVehicleManager.activeVehicleAvailable) { + if(QGroundControl.multiVehicleManager.activeVehicleAvailable) { messageText.text = activeVehicle.formatedMessages //-- Hack to scroll to last message for (var i = 0; i < activeVehicle.messageCount; i++) diff --git a/src/ui/preferences/MavlinkSettings.qml b/src/ui/preferences/MavlinkSettings.qml index f901bbeb5..4c64f3d29 100644 --- a/src/ui/preferences/MavlinkSettings.qml +++ b/src/ui/preferences/MavlinkSettings.qml @@ -88,9 +88,9 @@ Rectangle { //-- Mavlink Heartbeats QGCCheckBox { text: "Emit heartbeat" - checked: multiVehicleManager.gcsHeartBeatEnabled + checked: QGroundControl.multiVehicleManager.gcsHeartBeatEnabled onClicked: { - multiVehicleManager.gcsHeartBeatEnabled = checked + QGroundControl.multiVehicleManager.gcsHeartBeatEnabled = checked } } //----------------------------------------------------------------- diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index 8fe4ec732..acd067c7d 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -45,7 +45,7 @@ Rectangle { QGCPalette { id: qgcPal; colorGroupEnabled: true } - property var activeVehicle: multiVehicleManager.activeVehicle + property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property var mainWindow: null property bool isMessageImportant: activeVehicle ? !activeVehicle.messageTypeNormal && !activeVehicle.messageTypeNone : false property bool isBackgroundDark: true diff --git a/src/ui/toolbar/MainToolBarIndicators.qml b/src/ui/toolbar/MainToolBarIndicators.qml index 7a5496211..e36efd146 100644 --- a/src/ui/toolbar/MainToolBarIndicators.qml +++ b/src/ui/toolbar/MainToolBarIndicators.qml @@ -322,10 +322,10 @@ Row { MenuItem { checkable: true - onTriggered: multiVehicleManager.activeVehicle = vehicle + onTriggered: QGroundControl.multiVehicleManager.activeVehicle = vehicle property int vehicleId: Number(text.split(" ")[1]) - property var vehicle: multiVehicleManager.getVehicleById(vehicleId) + property var vehicle: QGroundControl.multiVehicleManager.getVehicleById(vehicleId) } } @@ -339,8 +339,8 @@ Row { vehicleMenuItems.length = 0 // Add new items - for (var i=0; i