Commit 0e4d256c authored by Gus Grubba's avatar Gus Grubba

Handle multi vehicles

parent a1ed12ee
......@@ -3,18 +3,19 @@
<file alias="FactSystemTest.qml">src/FactSystem/FactSystemTest.qml</file>
</qresource>
<qresource prefix="/toolbar">
<file alias="MainToolBarIndicators.qml">src/ui/toolbar/MainToolBarIndicators.qml</file>
<file alias="ArmedIndicator.qml">src/ui/toolbar/ArmedIndicator.qml</file>
<file alias="BatteryIndicator.qml">src/ui/toolbar/BatteryIndicator.qml</file>
<file alias="GPSIndicator.qml">src/ui/toolbar/GPSIndicator.qml</file>
<file alias="GPSRTKIndicator.qml">src/ui/toolbar/GPSRTKIndicator.qml</file>
<file alias="JoystickIndicator.qml">src/ui/toolbar/JoystickIndicator.qml</file>
<file alias="LinkIndicator.qml">src/ui/toolbar/LinkIndicator.qml</file>
<file alias="MainToolBarIndicators.qml">src/ui/toolbar/MainToolBarIndicators.qml</file>
<file alias="MessageIndicator.qml">src/ui/toolbar/MessageIndicator.qml</file>
<file alias="ModeIndicator.qml">src/ui/toolbar/ModeIndicator.qml</file>
<file alias="VTOLModeIndicator.qml">src/ui/toolbar/VTOLModeIndicator.qml</file>
<file alias="MultiVehicleSelector.qml">src/ui/toolbar/MultiVehicleSelector.qml</file>
<file alias="RCRSSIIndicator.qml">src/ui/toolbar/RCRSSIIndicator.qml</file>
<file alias="TelemetryRSSIIndicator.qml">src/ui/toolbar/TelemetryRSSIIndicator.qml</file>
<file alias="JoystickIndicator.qml">src/ui/toolbar/JoystickIndicator.qml</file>
<file alias="LinkIndicator.qml">src/ui/toolbar/LinkIndicator.qml</file>
<file alias="VTOLModeIndicator.qml">src/ui/toolbar/VTOLModeIndicator.qml</file>
</qresource>
<qresource prefix="/qml">
<file alias="CorridorScanEditor.qml">src/PlanView/CorridorScanEditor.qml</file>
......
......@@ -8,7 +8,6 @@ import QGroundControl.Palette 1.0
Item {
anchors.fill: parent
color: qgcPal.windowShadeDark
FactPanelController { id: controller; }
......
......@@ -321,6 +321,7 @@ const QVariantList &FirmwarePlugin::toolBarIndicators(const Vehicle* vehicle)
Q_UNUSED(vehicle);
//-- Default list of indicators for all vehicles.
if(_toolBarIndicatorList.size() == 0) {
_toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/MultiVehicleSelector.qml")));
_toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/MessageIndicator.qml")));
_toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/GPSIndicator.qml")));
_toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/TelemetryRSSIIndicator.qml")));
......
......@@ -19,7 +19,7 @@ import QGroundControl.Vehicle 1.0
import QGroundControl.FlightMap 1.0
Item {
property var guidedActionsController
property var guidedActionsController
property real _margin: ScreenTools.defaultFontPixelWidth / 2
property real _widgetHeight: ScreenTools.defaultFontPixelHeight * 3
......@@ -111,7 +111,7 @@ Item {
QGCLabel {
Layout.alignment: Qt.AlignTop
text: _vehicle.id
text: _vehicle ? _vehicle.id : ""
color: _textColor
}
......@@ -128,7 +128,7 @@ Item {
QGCLabel {
Layout.alignment: Qt.AlignHCenter
text: _vehicle.armed ? qsTr("Armed") : qsTr("Disarmed")
text: _vehicle && _vehicle.armed ? qsTr("Armed") : qsTr("Disarmed")
color: _textColor
}
}
......
......@@ -591,7 +591,7 @@ ApplicationWindow {
//-- System Messages
property var _messageQueue: []
property string _systemMessage: ""
property string _systemMessage: ""
function showMessage(message) {
vehicleMessageArea.close()
......@@ -616,7 +616,7 @@ ApplicationWindow {
y: ScreenTools.defaultFontPixelHeight
x: Math.round((mainWindow.width - width) * 0.5)
width: mainWindow.width * 0.55
height: ScreenTools.defaultFontPixelHeight * 4
height: ScreenTools.defaultFontPixelHeight * 6
modal: false
focus: true
closePolicy: Popup.CloseOnEscape
......@@ -640,7 +640,8 @@ ApplicationWindow {
//-- Show all messages in queue
for (var i = 0; i < mainWindow._messageQueue.length; i++) {
var text = mainWindow._messageQueue[i]
mainWindow._systemMessage.append(text)
if(i) mainWindow._systemMessage += "<br>"
mainWindow._systemMessage += text
}
//-- Clear it
mainWindow._messageQueue = []
......
......@@ -81,61 +81,6 @@ Item {
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
spacing: ScreenTools.defaultFontPixelWidth * 1.5
visible: activeVehicle && !communicationLost
//---------------------------------------------------------------------
//-- Vehicle Selector
QGCButton {
id: vehicleSelectorButton
width: visible ? 0 : ScreenTools.defaultFontPixelHeight * 8
text: "Vehicle " + (activeVehicle ? activeVehicle.id : "None")
visible: QGroundControl.multiVehicleManager.vehicles.count > 1
Layout.alignment: Qt.AlignVCenter
onClicked: {
vehicleMenu.popup()
}
Menu {
id: vehicleMenu
}
Component {
id: vehicleMenuItemComponent
MenuItem {
onTriggered: QGroundControl.multiVehicleManager.activeVehicle = vehicle
property int vehicleId: Number(text.split(" ")[1])
property var vehicle: QGroundControl.multiVehicleManager.getVehicleById(vehicleId)
}
}
property var vehicleMenuItems: []
function updateVehicleMenu() {
var i;
// Remove old menu items
for (i = 0; i < vehicleMenuItems.length; i++) {
vehicleMenu.removeItem(vehicleMenuItems[i])
}
vehicleMenuItems.length = 0
// Add new items
for (i = 0; i < QGroundControl.multiVehicleManager.vehicles.count; i++) {
var vehicle = QGroundControl.multiVehicleManager.vehicles.get(i)
var menuItem = vehicleMenuItemComponent.createObject(null, { "text": "Vehicle " + vehicle.id })
vehicleMenuItems.push(menuItem)
vehicleMenu.insertItem(i, menuItem)
}
}
Component.onCompleted: updateVehicleMenu()
Connections {
target: QGroundControl.multiVehicleManager.vehicles
onCountChanged: vehicleSelectorButton.updateVehicleMenu()
}
}
//---------------------------------------------------------------------
//-- Indicators
Repeater {
model: activeVehicle ? activeVehicle.toolBarIndicators : []
Loader {
......
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QGroundControl 1.0
import QGroundControl.Controls 1.0
import QGroundControl.MultiVehicleManager 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
//-------------------------------------------------------------------------
//-- Mode Indicator
Item {
anchors.top: parent.top
anchors.bottom: parent.bottom
visible: _multiVehicles
width: _multiVehicles ? multiVehicleSelector.width : 0
property bool _multiVehicles: activeVehicle ? QGroundControl.multiVehicleManager.vehicles.count > 1 : false
Connections {
target: QGroundControl.multiVehicleManager.vehicles
onCountChanged: multiVehicleSelector.updatemultiVehiclesMenu()
}
QGCLabel {
id: multiVehicleSelector
text: "Vehicle " + (activeVehicle ? activeVehicle.id : "None")
font.pointSize: ScreenTools.mediumFontPointSize
color: qgcPal.buttonText
anchors.verticalCenter: parent.verticalCenter
Menu {
id: multiVehiclesMenu
}
Component {
id: multiVehicleMenuItemComponent
MenuItem {
onTriggered: QGroundControl.multiVehicleManager.activeVehicle = vehicle
property int vehicleId: Number(text.split(" ")[1])
property var vehicle: QGroundControl.multiVehicleManager.getVehicleById(vehicleId)
}
}
property var multiVehiclesMenuItems: []
function updatemultiVehiclesMenu() {
if (_multiVehicles) {
// Remove old menu items
for (var i = 0; i < multiVehiclesMenuItems.length; i++) {
multiVehiclesMenu.removeItem(multiVehiclesMenuItems[i])
}
multiVehiclesMenuItems.length = 0
// Add new items
for (i = 0; i < QGroundControl.multiVehicleManager.vehicles.count; i++) {
var vehicle = QGroundControl.multiVehicleManager.vehicles.get(i)
var menuItem = multiVehicleMenuItemComponent.createObject(null, { "text": "Vehicle " + vehicle.id })
multiVehiclesMenuItems.push(menuItem)
multiVehiclesMenu.insertItem(i, menuItem)
console.log("Vehicle " + vehicle.id)
}
}
}
Component.onCompleted: {
multiVehicleSelector.updatemultiVehiclesMenu()
}
}
MouseArea {
visible: _multiVehicles
anchors.fill: parent
onClicked: multiVehiclesMenu.popup()
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment