Unverified Commit acfd001f authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #7645 from mavlink/customFlightModes

Custom flight modes
parents dee1314f f185e875
...@@ -88,7 +88,7 @@ Item { ...@@ -88,7 +88,7 @@ Item {
id: backgroundRect id: backgroundRect
width: buttonsRow.width + (ScreenTools.defaultFontPixelWidth * 4) width: buttonsRow.width + (ScreenTools.defaultFontPixelWidth * 4)
height: buttonsRow.height + (ScreenTools.defaultFontPixelHeight) height: buttonsRow.height + (ScreenTools.defaultFontPixelHeight)
visible: _irPaletteFact && QGroundControl.videoManager.hasThermal || _camera.vendor === "NextVision" visible: _irPaletteFact && (QGroundControl.videoManager.hasThermal || _camera.vendor === "NextVision")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
Component.onCompleted: { Component.onCompleted: {
if(_irPaletteFact && QGroundControl.videoManager.hasThermal) { if(_irPaletteFact && QGroundControl.videoManager.hasThermal) {
...@@ -965,19 +965,25 @@ Item { ...@@ -965,19 +965,25 @@ Item {
contentHeight: comboListCol.height contentHeight: comboListCol.height
contentWidth: comboListCol.width contentWidth: comboListCol.width
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
Column { ColumnLayout {
id: comboListCol id: comboListCol
spacing: ScreenTools.defaultFontPixelHeight spacing: ScreenTools.defaultFontPixelHeight
anchors.margins: ScreenTools.defaultFontPixelHeight anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: qsTr("Thermal Palettes")
Layout.alignment: Qt.AlignHCenter
}
Repeater { Repeater {
model: _irPaletteFact ? _irPaletteFact.enumStrings : [] model: _irPaletteFact ? _irPaletteFact.enumStrings : []
QGCButton { QGCButton {
text: modelData text: modelData
width: ScreenTools.defaultFontPixelWidth * 30 Layout.minimumHeight: ScreenTools.defaultFontPixelHeight * 3
height: ScreenTools.defaultFontPixelHeight * 2 Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 30
Layout.fillHeight: true
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
checked: index === _irPaletteFact.value checked: index === _irPaletteFact.value
anchors.horizontalCenter: parent.horizontalCenter
onClicked: { onClicked: {
_irPaletteFact.value = index _irPaletteFact.value = index
thermalPalettes.close() thermalPalettes.close()
......
...@@ -9,8 +9,11 @@ ...@@ -9,8 +9,11 @@
* @author Gus Grubba <gus@auterion.com> * @author Gus Grubba <gus@auterion.com>
*/ */
import QtQuick 2.11 import QtQuick 2.11
import QtQuick.Controls 1.4 import QtQuick.Controls 2.4
import QtQuick.Layouts 1.11
import QtQuick.Dialogs 1.3
import QGroundControl 1.0 import QGroundControl 1.0
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
...@@ -25,10 +28,6 @@ Item { ...@@ -25,10 +28,6 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
width: selectorRow.width width: selectorRow.width
property var _flightModes: activeVehicle ? activeVehicle.flightModes : [ ]
on_FlightModesChanged: flightModeSelector.updateFlightModesMenu()
Row { Row {
id: selectorRow id: selectorRow
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
...@@ -39,32 +38,6 @@ Item { ...@@ -39,32 +38,6 @@ Item {
color: qgcPal.text color: qgcPal.text
font.pointSize: ScreenTools.defaultFontPointSize font.pointSize: ScreenTools.defaultFontPointSize
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
Menu {
id: flightModesMenu
}
Component {
id: flightModeMenuItemComponent
MenuItem {
onTriggered: activeVehicle.flightMode = text
}
}
property var flightModesMenuItems: []
function updateFlightModesMenu() {
if (activeVehicle && activeVehicle.flightModeSetAvailable) {
// Remove old menu items
var i = 0
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)
}
}
}
} }
QGCColoredImage { QGCColoredImage {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
...@@ -76,10 +49,53 @@ Item { ...@@ -76,10 +49,53 @@ Item {
color: qgcPal.text color: qgcPal.text
} }
} }
Component.onCompleted: flightModeSelector.updateFlightModesMenu()
MouseArea { MouseArea {
visible: activeVehicle && activeVehicle.flightModeSetAvailable visible: activeVehicle && activeVehicle.flightModeSetAvailable
anchors.fill: parent anchors.fill: parent
onClicked: flightModesMenu.popup() onClicked: flightModesMenu.open()
}
//-------------------------------------------------------------------------
//-- Flight Modes
Popup {
id: flightModesMenu
width: Math.min(mainWindow.width * 0.666, ScreenTools.defaultFontPixelWidth * 40)
height: mainWindow.height * 0.5
modal: true
focus: true
parent: Overlay.overlay
x: Math.round((mainWindow.width - width) * 0.5)
y: Math.round((mainWindow.height - height) * 0.5)
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
property int selectedIndex: 0
background: Rectangle {
anchors.fill: parent
color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.95) : Qt.rgba(0,0,0,0.75)
border.color: qgcPal.text
radius: ScreenTools.defaultFontPixelWidth
}
ColumnLayout {
id: comboListCol
spacing: ScreenTools.defaultFontPixelHeight
anchors.centerIn: parent
QGCLabel {
text: qsTr("Flight Modes")
Layout.alignment: Qt.AlignHCenter
}
Repeater {
model: activeVehicle ? activeVehicle.flightModes : [ ]
QGCButton {
text: modelData
Layout.minimumHeight: ScreenTools.defaultFontPixelHeight * 3
Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 30
Layout.fillHeight: true
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
onClicked: {
activeVehicle.flightMode = modelData
flightModesMenu.close()
}
}
}
}
} }
} }
...@@ -19,6 +19,14 @@ ...@@ -19,6 +19,14 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
CustomFirmwarePlugin::CustomFirmwarePlugin() CustomFirmwarePlugin::CustomFirmwarePlugin()
{ {
for (int i = 0; i < _flightModeInfoList.count(); i++) {
FlightModeInfo_t& info = _flightModeInfoList[i];
//-- Narrow the options to only these two
if (info.name != _altCtlFlightMode &&
info.name != _posCtlFlightMode) {
info.canBeSet = false;
}
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
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