Browse Source

Position flight mode menu below toolbar to prevent double-click mode change

QGC4.4
DonLakeFlyer 4 years ago committed by Don Gagne
parent
commit
fed7ccf20c
  1. 17
      src/QmlControls/FlightModeMenu.qml

17
src/QmlControls/FlightModeMenu.qml

@ -7,8 +7,8 @@ @@ -7,8 +7,8 @@
*
****************************************************************************/
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick 2.12
import QtQuick.Controls 2.12
import QGroundControl 1.0
import QGroundControl.Controls 1.0
@ -16,20 +16,21 @@ import QGroundControl.ScreenTools 1.0 @@ -16,20 +16,21 @@ import QGroundControl.ScreenTools 1.0
// Label control whichs pop up a flight mode change menu when clicked
QGCLabel {
id: flightModeMenuLabel
id: _root
text: currentVehicle ? currentVehicle.flightMode : qsTr("N/A", "No data to display")
property var currentVehicle: QGroundControl.multiVehicleManager.activeVehicle
property real mouseAreaLeftMargin: 0
QGCMenu {
Menu {
id: flightModesMenu
}
Component {
id: flightModeMenuItemComponent
QGCMenuItem {
MenuItem {
enabled: true
onTriggered: currentVehicle.flightMode = text
}
}
@ -53,11 +54,11 @@ QGCLabel { @@ -53,11 +54,11 @@ QGCLabel {
}
}
Component.onCompleted: flightModeMenuLabel.updateFlightModesMenu()
Component.onCompleted: _root.updateFlightModesMenu()
Connections {
target: QGroundControl.multiVehicleManager
onActiveVehicleChanged: flightModeMenuLabel.updateFlightModesMenu()
onActiveVehicleChanged: _root.updateFlightModesMenu()
}
MouseArea {
@ -65,6 +66,6 @@ QGCLabel { @@ -65,6 +66,6 @@ QGCLabel {
visible: currentVehicle && currentVehicle.flightModeSetAvailable
anchors.leftMargin: mouseAreaLeftMargin
anchors.fill: parent
onClicked: flightModesMenu.popup()
onClicked: flightModesMenu.popup((_root.width - flightModesMenu.width) / 2, _root.height)
}
}

Loading…
Cancel
Save