diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 4b7b893904ecb9eb71dd0b086570ff14c9cdfbe3..fc3446c49c948d0b6e0a903a1ca1ec5b7a96a2fd 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -48,6 +48,7 @@ src/QmlControls/ExclusiveGroupItem.qml src/QmlControls/FactSliderPanel.qml src/QmlControls/FlightModeDropdown.qml + src/QmlControls/FlightModeMenu.qml src/QmlControls/GuidedBar.qml src/QmlControls/IndicatorButton.qml src/QmlControls/JoystickThumbPad.qml diff --git a/src/FlightDisplay/MultiVehicleList.qml b/src/FlightDisplay/MultiVehicleList.qml index fbb78e729b0a489ee3c971094e6e5df119e2c3df..c59f876b8f8bfc9009e8eb282dcdaa861cb97251 100644 --- a/src/FlightDisplay/MultiVehicleList.qml +++ b/src/FlightDisplay/MultiVehicleList.qml @@ -77,10 +77,10 @@ QGCListView { color: _textColor } - QGCLabel { - text: _vehicle.flightMode - font.pointSize: ScreenTools.largeFontPointSize - color: _textColor + FlightModeMenu { + font.pointSize: ScreenTools.largeFontPointSize + color: _textColor + activeVehicle: _vehicle } } diff --git a/src/QmlControls/FlightModeMenu.qml b/src/QmlControls/FlightModeMenu.qml new file mode 100644 index 0000000000000000000000000000000000000000..2f7794913b052be3f440045682d01572e50fcabc --- /dev/null +++ b/src/QmlControls/FlightModeMenu.qml @@ -0,0 +1,66 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.5 +import QtQuick.Controls 1.2 + +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: activeVehicle ? activeVehicle.flightMode : qsTr("N/A", "No data to display") + + property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + + Menu { + id: flightModesMenu + } + + Component { + id: flightModeMenuItemComponent + + MenuItem { + onTriggered: activeVehicle.flightMode = text + } + } + + property var flightModesMenuItems: [] + + function updateFlightModesMenu() { + if (activeVehicle && activeVehicle.flightModeSetAvailable) { + // Remove old menu items + for (var i = 0; i < flightModesMenuItems.length; i++) { + flightModesMenu.removeItem(flightModesMenuItems[i]) + } + flightModesMenuItems.length = 0 + // Add new items + for (var i = 0; i < activeVehicle.flightModes.length; i++) { + var menuItem = flightModeMenuItemComponent.createObject(null, { "text": activeVehicle.flightModes[i] }) + flightModesMenuItems.push(menuItem) + flightModesMenu.insertItem(i, menuItem) + } + } + } + + Component.onCompleted: flightModeMenuLabel.updateFlightModesMenu() + + Connections { + target: QGroundControl.multiVehicleManager + onActiveVehicleChanged: flightModeMenuLabel.updateFlightModesMenu() + } + + MouseArea { + visible: activeVehicle && activeVehicle.flightModeSetAvailable + anchors.fill: parent + onClicked: flightModesMenu.popup() + } +} diff --git a/src/QmlControls/QGroundControl.Controls.qmldir b/src/QmlControls/QGroundControl.Controls.qmldir index f1a1caf12d617e379918ad4f5cbe3ee434f66c46..c33e30fea26a5662d53bfb26b5d225ceb9165072 100644 --- a/src/QmlControls/QGroundControl.Controls.qmldir +++ b/src/QmlControls/QGroundControl.Controls.qmldir @@ -7,6 +7,7 @@ DropButton 1.0 DropButton.qml ExclusiveGroupItem 1.0 ExclusiveGroupItem.qml FactSliderPanel 1.0 FactSliderPanel.qml FlightModeDropdown 1.0 FlightModeDropdown.qml +FlightModeMenu 1.0 FlightModeMenu.qml GuidedBar 1.0 GuidedBar.qml IndicatorButton 1.0 IndicatorButton.qml JoystickThumbPad 1.0 JoystickThumbPad.qml