Newer
Older
/****************************************************************************
*
* (c) 2009-2020 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.
*
****************************************************************************/
Gus Grubba
committed
import QtQuick 2.11
import QtQuick.Controls 2.4
import QGroundControl 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
// Label control whichs pop up a flight mode change menu when clicked
QGCLabel {
id: flightModeMenuLabel
text: currentVehicle ? currentVehicle.flightMode : qsTr("N/A", "No data to display")
property var currentVehicle: QGroundControl.multiVehicleManager.activeVehicle
id: flightModesMenu
}
Component {
id: flightModeMenuItemComponent
}
}
property var flightModesMenuItems: []
function updateFlightModesMenu() {
if (currentVehicle && currentVehicle.flightModeSetAvailable) {
for (i = 0; i < flightModesMenuItems.length; i++) {
flightModesMenu.removeItem(flightModesMenuItems[i])
}
flightModesMenuItems.length = 0
// Add new items
for (i = 0; i < currentVehicle.flightModes.length; i++) {
var menuItem = flightModeMenuItemComponent.createObject(null, { "text": currentVehicle.flightModes[i] })
flightModesMenuItems.push(menuItem)
flightModesMenu.insertItem(i, menuItem)
}
}
}
Component.onCompleted: flightModeMenuLabel.updateFlightModesMenu()
Connections {
target: QGroundControl.multiVehicleManager
onActiveVehicleChanged: flightModeMenuLabel.updateFlightModesMenu()
}
MouseArea {
visible: currentVehicle && currentVehicle.flightModeSetAvailable