Commit e55dc465 authored by Don Gagne's avatar Don Gagne

Use QGCCombBox with alternateText for better understanding of the ability to click on these indicators
parent e5aa03b6
...@@ -19,20 +19,24 @@ import QGroundControl.Palette 1.0 ...@@ -19,20 +19,24 @@ import QGroundControl.Palette 1.0
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//-- Armed Indicator //-- Armed Indicator
QGCLabel { QGCComboBox {
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
verticalAlignment: Text.AlignVCenter alternateText: _armed ? qsTr("Armed") : qsTr("Disarmed")
text: _armed ? qsTr("Armed") : qsTr("Disarmed") model: [ qsTr("Arm"), qsTr("Disarm") ]
font.pointSize: ScreenTools.mediumFontPointSize font.pointSize: ScreenTools.mediumFontPointSize
color: qgcPal.buttonText 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 } onActivated: {
if (index == 0) {
QGCMouseArea { mainWindow.armVehicle()
fillItem: parent } else {
onClicked: _armed ? mainWindow.disarmVehicle() : mainWindow.armVehicle() mainWindow.disarmVehicle()
}
currentIndex = -1
} }
} }
...@@ -19,52 +19,20 @@ import QGroundControl.Palette 1.0 ...@@ -19,52 +19,20 @@ import QGroundControl.Palette 1.0
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//-- Mode Indicator //-- Mode Indicator
Item { QGCComboBox {
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
width: flightModeSelector.width alternateText: _activeVehicle ? _activeVehicle.flightMode : ""
model: _flightModes
property var _flightModes: activeVehicle ? activeVehicle.flightModes : [ ] font.pointSize: ScreenTools.mediumFontPointSize
currentIndex: -1
sizeToContents: true
on_FlightModesChanged: flightModeSelector.updateFlightModesMenu() property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property var _flightModes: _activeVehicle ? _activeVehicle.flightModes : [ ]
QGCLabel { onActivated: {
id: flightModeSelector _activeVehicle.flightMode = _flightModes[index]
text: activeVehicle ? activeVehicle.flightMode : qsTr("N/A", "No data to display") currentIndex = -1
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()
}
} }
} }
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