diff --git a/src/ui/toolbar/ArmedIndicator.qml b/src/ui/toolbar/ArmedIndicator.qml index d0f5d2c1f65429c6ea8d3802faed0a9846f0d1a1..41e8a4fd10d69d8aa5f0c3a89212c5e02ce85143 100644 --- a/src/ui/toolbar/ArmedIndicator.qml +++ b/src/ui/toolbar/ArmedIndicator.qml @@ -19,20 +19,24 @@ import QGroundControl.Palette 1.0 //------------------------------------------------------------------------- //-- Armed Indicator -QGCLabel { - anchors.top: parent.top - anchors.bottom: parent.bottom - verticalAlignment: Text.AlignVCenter - text: _armed ? qsTr("Armed") : qsTr("Disarmed") - font.pointSize: ScreenTools.mediumFontPointSize - color: qgcPal.buttonText +QGCComboBox { + anchors.top: parent.top + anchors.bottom: parent.bottom + alternateText: _armed ? qsTr("Armed") : qsTr("Disarmed") + model: [ qsTr("Arm"), qsTr("Disarm") ] + font.pointSize: ScreenTools.mediumFontPointSize + currentIndex: -1 + sizeToContents: true - property bool _armed: activeVehicle ? activeVehicle.armed : false + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + property bool _armed: _activeVehicle ? _activeVehicle.armed : false - QGCPalette { id: qgcPal } - - QGCMouseArea { - fillItem: parent - onClicked: _armed ? mainWindow.disarmVehicle() : mainWindow.armVehicle() + onActivated: { + if (index == 0) { + mainWindow.armVehicle() + } else { + mainWindow.disarmVehicle() + } + currentIndex = -1 } } diff --git a/src/ui/toolbar/ModeIndicator.qml b/src/ui/toolbar/ModeIndicator.qml index 720a994c46302529d48ae1c54addc0adb500c848..aaec9bb71588e5d2a7cd0e61355c19a0e7f30b15 100644 --- a/src/ui/toolbar/ModeIndicator.qml +++ b/src/ui/toolbar/ModeIndicator.qml @@ -19,52 +19,20 @@ import QGroundControl.Palette 1.0 //------------------------------------------------------------------------- //-- Mode Indicator -Item { +QGCComboBox { anchors.top: parent.top anchors.bottom: parent.bottom - width: flightModeSelector.width + alternateText: _activeVehicle ? _activeVehicle.flightMode : "" + model: _flightModes + font.pointSize: ScreenTools.mediumFontPointSize + currentIndex: -1 + sizeToContents: true - property var _flightModes: activeVehicle ? activeVehicle.flightModes : [ ] + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + property var _flightModes: _activeVehicle ? _activeVehicle.flightModes : [ ] - on_FlightModesChanged: flightModeSelector.updateFlightModesMenu() - - QGCLabel { - id: flightModeSelector - text: activeVehicle ? activeVehicle.flightMode : qsTr("N/A", "No data to display") - font.pointSize: ScreenTools.mediumFontPointSize - color: qgcPal.buttonText - anchors.verticalCenter: parent.verticalCenter - QGCMenu { - id: flightModesMenu - } - Component { - id: flightModeMenuItemComponent - QGCMenuItem { - onTriggered: activeVehicle.flightMode = text - } - } - property var flightModesMenuItems: [] - function updateFlightModesMenu() { - if (activeVehicle && activeVehicle.flightModeSetAvailable) { - // Remove old menu items - var i - for (i = 0; i < flightModesMenuItems.length; i++) { - flightModesMenu.removeItem(flightModesMenuItems[i]) - } - flightModesMenuItems.length = 0 - // Add new items - for (i = 0; i < _flightModes.length; i++) { - var menuItem = flightModeMenuItemComponent.createObject(null, { "text": _flightModes[i] }) - flightModesMenuItems.push(menuItem) - flightModesMenu.insertItem(i, menuItem) - } - } - } - Component.onCompleted: flightModeSelector.updateFlightModesMenu() - MouseArea { - visible: activeVehicle && activeVehicle.flightModeSetAvailable - anchors.fill: parent - onClicked: flightModesMenu.popup() - } + onActivated: { + _activeVehicle.flightMode = _flightModes[index] + currentIndex = -1 } }