Commit 6d20e85d authored by dogmaphobic's avatar dogmaphobic

Merge remote-tracking branch 'mavlink/master' into toggleMapButtons

* mavlink/master:
  Increase size of controls for tablet
  Make sync warning less tall
  Use Flickable to allow scroll on Tablet
  More header fixes for Mobile build
  More header moves for Mobile build
  More header moves for no widgets in Mobile build
  Move widget controllers out of Mobile build
  QGCUnconnectedInfoWidget needed in Mobile builds
  Remove widget code from Mobile builds
parents f299ff45 76077ac5
......@@ -153,7 +153,6 @@ INCLUDEPATH += \
src/ui/linechart \
src/ui/map \
src/ui/mapdisplay \
src/ui/mavlink \
src/ui/mission \
src/ui/px4_configuration \
src/ui/toolbar \
......@@ -166,28 +165,18 @@ FORMS += \
src/ui/Linechart.ui \
src/ui/LogReplayLinkConfigurationWidget.ui \
src/ui/MainWindow.ui \
src/ui/mavlink/QGCMAVLinkMessageSender.ui \
src/ui/MAVLinkSettingsWidget.ui \
src/ui/MultiVehicleDockWidget.ui \
src/ui/QGCCommConfiguration.ui \
src/ui/QGCDataPlot2D.ui \
src/ui/QGCLinkConfiguration.ui \
src/ui/QGCMapRCToParamDialog.ui \
src/ui/QGCMAVLinkInspector.ui \
src/ui/QGCMAVLinkLogPlayer.ui \
src/ui/QGCPluginHost.ui \
src/ui/QGCTabbedInfoView.ui \
src/ui/QGCTCPLinkConfiguration.ui \
src/ui/QGCUASFileView.ui \
src/ui/QGCUASFileViewMulti.ui \
src/ui/QGCUDPLinkConfiguration.ui \
src/ui/SettingsDialog.ui \
src/ui/uas/QGCUnconnectedInfoWidget.ui \
src/ui/uas/UASMessageView.ui \
src/ui/uas/UASQuickView.ui \
src/ui/uas/UASQuickViewItemSelect.ui \
src/ui/UASInfo.ui \
src/ui/UASRawStatusView.ui \
!iOSBuild {
FORMS += \
......@@ -196,10 +185,19 @@ FORMS += \
!MobileBuild {
FORMS += \
src/ui/MultiVehicleDockWidget.ui \
src/ui/QGCHilConfiguration.ui \
src/ui/QGCHilFlightGearConfiguration.ui \
src/ui/QGCHilJSBSimConfiguration.ui \
src/ui/QGCHilXPlaneConfiguration.ui \
src/ui/QGCMAVLinkInspector.ui \
src/ui/QGCTabbedInfoView.ui \
src/ui/QGCUASFileView.ui \
src/ui/QGCUASFileViewMulti.ui \
src/ui/uas/UASQuickView.ui \
src/ui/uas/UASQuickViewItemSelect.ui \
src/ui/UASInfo.ui \
src/ui/UASRawStatusView.ui \
}
HEADERS += \
......@@ -232,7 +230,6 @@ HEADERS += \
src/QGCApplication.h \
src/QGCComboBox.h \
src/QGCConfig.h \
src/QGCDockWidget.h \
src/QGCFileDialog.h \
src/QGCGeo.h \
src/QGCLoggingCategory.h \
......@@ -263,37 +260,20 @@ HEADERS += \
src/ui/linechart/ScrollZoomer.h \
src/ui/LogReplayLinkConfigurationWidget.h \
src/ui/MainWindow.h \
src/ui/mavlink/QGCMAVLinkMessageSender.h \
src/ui/MAVLinkDecoder.h \
src/ui/MAVLinkSettingsWidget.h \
src/ui/MultiVehicleDockWidget.h \
src/ui/QGCCommConfiguration.h \
src/ui/QGCDataPlot2D.h \
src/ui/QGCLinkConfiguration.h \
src/ui/QGCMainWindowAPConfigurator.h \
src/ui/QGCMapRCToParamDialog.h \
src/ui/QGCMAVLinkInspector.h \
src/ui/QGCMAVLinkLogPlayer.h \
src/ui/QGCPluginHost.h \
src/ui/QGCTabbedInfoView.h \
src/ui/QGCTCPLinkConfiguration.h \
src/ui/QGCUASFileView.h \
src/ui/QGCUASFileViewMulti.h \
src/ui/QGCUDPLinkConfiguration.h \
src/ui/SettingsDialog.h \
src/ui/toolbar/MainToolBar.h \
src/ui/uas/QGCUnconnectedInfoWidget.h \
src/ui/uas/UASInfoWidget.h \
src/ui/uas/UASMessageView.h \
src/ui/uas/UASQuickView.h \
src/ui/uas/UASQuickViewGaugeItem.h \
src/ui/uas/UASQuickViewItem.h \
src/ui/uas/UASQuickViewItemSelect.h \
src/ui/uas/UASQuickViewTextItem.h \
src/ui/UASRawStatusView.h \
src/ViewWidgets/CustomCommandWidget.h \
src/ViewWidgets/CustomCommandWidgetController.h \
src/ViewWidgets/ViewWidgetController.h \
src/MissionItem.h \
src/AutoPilotPlugins/PX4/PX4AirframeLoader.h
......@@ -309,13 +289,29 @@ HEADERS += \
src/comm/QGCHilLink.h \
src/comm/QGCJSBSimLink.h \
src/comm/QGCXPlaneLink.h \
src/QGCDockWidget.h \
src/ui/CameraView.h \
src/ui/HILDockWidget.h \
src/ui/MultiVehicleDockWidget.h \
src/ui/QGCHilConfiguration.h \
src/ui/QGCHilFlightGearConfiguration.h \
src/ui/QGCHilJSBSimConfiguration.h \
src/ui/QGCHilXPlaneConfiguration.h \
src/ui/QGCMAVLinkInspector.h \
src/ui/QGCTabbedInfoView.h \
src/ui/QGCUASFileView.h \
src/ui/QGCUASFileViewMulti.h \
src/ui/uas/UASInfoWidget.h \
src/ui/uas/UASQuickView.h \
src/ui/uas/UASQuickViewGaugeItem.h \
src/ui/uas/UASQuickViewItem.h \
src/ui/uas/UASQuickViewItemSelect.h \
src/ui/uas/UASQuickViewTextItem.h \
src/ui/UASRawStatusView.h \
src/VehicleSetup/JoystickConfigController.h \
src/ViewWidgets/CustomCommandWidget.h \
src/ViewWidgets/CustomCommandWidgetController.h \
src/ViewWidgets/ViewWidgetController.h \
}
SOURCES += \
......@@ -344,7 +340,6 @@ SOURCES += \
src/QGC.cc \
src/QGCApplication.cc \
src/QGCComboBox.cc \
src/QGCDockWidget.cc \
src/QGCFileDialog.cc \
src/QGCLoggingCategory.cc \
src/QGCPalette.cc \
......@@ -370,37 +365,20 @@ SOURCES += \
src/ui/linechart/ScrollZoomer.cc \
src/ui/LogReplayLinkConfigurationWidget.cc \
src/ui/MainWindow.cc \
src/ui/mavlink/QGCMAVLinkMessageSender.cc \
src/ui/MAVLinkDecoder.cc \
src/ui/MAVLinkSettingsWidget.cc \
src/ui/MultiVehicleDockWidget.cc \
src/ui/QGCCommConfiguration.cc \
src/ui/QGCDataPlot2D.cc \
src/ui/QGCLinkConfiguration.cc \
src/ui/QGCMainWindowAPConfigurator.cc \
src/ui/QGCMapRCToParamDialog.cpp \
src/ui/QGCMAVLinkInspector.cc \
src/ui/QGCMAVLinkLogPlayer.cc \
src/ui/QGCPluginHost.cc \
src/ui/QGCTabbedInfoView.cpp \
src/ui/QGCTCPLinkConfiguration.cc \
src/ui/QGCUASFileView.cc \
src/ui/QGCUASFileViewMulti.cc \
src/ui/QGCUDPLinkConfiguration.cc \
src/ui/SettingsDialog.cc \
src/ui/toolbar/MainToolBar.cc \
src/ui/uas/QGCUnconnectedInfoWidget.cc \
src/ui/uas/UASInfoWidget.cc \
src/ui/uas/UASMessageView.cc \
src/ui/uas/UASQuickView.cc \
src/ui/uas/UASQuickViewGaugeItem.cc \
src/ui/uas/UASQuickViewItem.cc \
src/ui/uas/UASQuickViewItemSelect.cc \
src/ui/uas/UASQuickViewTextItem.cc \
src/ui/UASRawStatusView.cpp \
src/ViewWidgets/CustomCommandWidget.cc \
src/ViewWidgets/CustomCommandWidgetController.cc \
src/ViewWidgets/ViewWidgetController.cc \
src/MissionItem.cc \
src/AutoPilotPlugins/PX4/PX4AirframeLoader.cc
......@@ -415,13 +393,29 @@ SOURCES += \
src/comm/QGCFlightGearLink.cc \
src/comm/QGCJSBSimLink.cc \
src/comm/QGCXPlaneLink.cc \
src/QGCDockWidget.cc \
src/ui/CameraView.cc \
src/ui/HILDockWidget.cc \
src/ui/MultiVehicleDockWidget.cc \
src/ui/QGCHilConfiguration.cc \
src/ui/QGCHilFlightGearConfiguration.cc \
src/ui/QGCHilJSBSimConfiguration.cc \
src/ui/QGCHilXPlaneConfiguration.cc \
src/ui/QGCMAVLinkInspector.cc \
src/ui/QGCTabbedInfoView.cpp \
src/ui/QGCUASFileView.cc \
src/ui/QGCUASFileViewMulti.cc \
src/ui/uas/UASInfoWidget.cc \
src/ui/uas/UASQuickView.cc \
src/ui/uas/UASQuickViewGaugeItem.cc \
src/ui/uas/UASQuickViewItem.cc \
src/ui/uas/UASQuickViewItemSelect.cc \
src/ui/uas/UASQuickViewTextItem.cc \
src/ui/UASRawStatusView.cpp \
src/VehicleSetup/JoystickConfigController.cc \
src/ViewWidgets/CustomCommandWidget.cc \
src/ViewWidgets/CustomCommandWidgetController.cc \
src/ViewWidgets/ViewWidgetController.cc \
}
#
......
......@@ -29,6 +29,7 @@
#include "QGCMessageBox.h"
#include "MainWindow.h"
#include "ParameterLoader.h"
#include "UAS.h"
AutoPilotPlugin::AutoPilotPlugin(Vehicle* vehicle, QObject* parent)
: QObject(parent)
......
......@@ -28,6 +28,7 @@
#include "FlightModesComponentController.h"
#include "AirframeComponentController.h"
#include "QGCMessageBox.h"
#include "UAS.h"
/// @file
/// @brief This is the AutoPilotPlugin implementatin for the MAV_AUTOPILOT_PX4 type.
......
......@@ -104,253 +104,260 @@ QGCView {
id: panel
anchors.fill: parent
Flickable {
anchors.fill: parent
flickableDirection: Flickable.VerticalFlick
contentHeight: innerColumn.height
Column {
id: innerColumn
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelHeight
QGCLabel {
text: "POWER CONFIG"
font.pixelSize: ScreenTools.largeFontPixelSize
}
Column {
anchors.fill: parent
spacing: ScreenTools.defaultFontPixelHeight
QGCLabel {
text: "POWER CONFIG"
font.pixelSize: ScreenTools.largeFontPixelSize
}
QGCLabel {
text: "Battery"
font.pixelSize: ScreenTools.mediumFontPixelSize
}
QGCLabel {
text: "Battery"
font.pixelSize: ScreenTools.mediumFontPixelSize
}
Rectangle {
width: parent.width
height: voltageCol.height + ScreenTools.defaultFontPixelHeight
color: palette.windowShade
Rectangle {
width: parent.width
height: voltageCol.height + ScreenTools.defaultFontPixelHeight
color: palette.windowShade
Column {
id: voltageCol
anchors.margins: ScreenTools.defaultFontPixelHeight / 2
anchors.left: parent.left
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelHeight / 2
Column {
id: voltageCol
anchors.margins: ScreenTools.defaultFontPixelHeight / 2
anchors.left: parent.left
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelHeight / 2
property real firstColumnWidth: Math.max(Math.max(cellsLabel.contentWidth, battHighLabel.contentWidth), battLowLabel.contentWidth) + ScreenTools.defaultFontPixelWidth
property real firstColumnWidth: Math.max(Math.max(cellsLabel.contentWidth, battHighLabel.contentWidth), battLowLabel.contentWidth) + ScreenTools.defaultFontPixelWidth
Row {
spacing: ScreenTools.defaultFontPixelWidth
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
id: cellsLabel
text: "Number of Cells (in Series)"
anchors.baseline: cellsField.baseline
}
QGCLabel {
id: cellsLabel
text: "Number of Cells (in Series)"
anchors.baseline: cellsField.baseline
FactTextField {
id: cellsField
x: voltageCol.firstColumnWidth
width: textEditWidth
fact: battNumCells
showUnits: true
}
}
FactTextField {
id: cellsField
x: voltageCol.firstColumnWidth
width: textEditWidth
fact: battNumCells
showUnits: true
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
id: battHighLabel
text: "Full Voltage (per cell)"
anchors.baseline: battHighField.baseline
}
FactTextField {
id: battHighField
x: voltageCol.firstColumnWidth
width: textEditWidth
fact: battHighVolt
showUnits: true
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
id: battHighLabel
text: "Full Voltage (per cell)"
anchors.baseline: battHighField.baseline
QGCLabel {
id: battLowLabel
text: "Empty Voltage (per cell)"
anchors.baseline: battLowField.baseline
}
FactTextField {
id: battHighField
x: voltageCol.firstColumnWidth
width: textEditWidth
fact: battHighVolt
showUnits: true
FactTextField {
id: battLowField
x: voltageCol.firstColumnWidth
width: textEditWidth
fact: battLowVolt
showUnits: true
}
}
} // Column
QGCColoredImage {
id: batteryImage
anchors.verticalCenter: voltageCol.verticalCenter
x: voltageCol.firstColumnWidth + textEditWidth + (ScreenTools.defaultFontPixelWidth * 3)
width: height * 0.75
height: voltageCol.height
fillMode: Image.PreserveAspectFit
smooth: true
color: palette.button
cache: false
source: getBatteryImage();
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
Column {
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
anchors.left: batteryImage.right
anchors.verticalCenter: voltageCol.verticalCenter
spacing: ScreenTools.defaultFontPixelHeight
QGCLabel {
id: battLowLabel
text: "Empty Voltage (per cell)"
anchors.baseline: battLowField.baseline
text: "Battery Max: " + (battNumCells.value * battHighVolt.value).toFixed(1) + ' V'
}
FactTextField {
id: battLowField
x: voltageCol.firstColumnWidth
width: textEditWidth
fact: battLowVolt
showUnits: true
QGCLabel {
text: "Battery Min: " + (battNumCells.value * battLowVolt.value).toFixed(1) + ' V'
}
}
} // Column
QGCColoredImage {
id: batteryImage
anchors.verticalCenter: voltageCol.verticalCenter
x: voltageCol.firstColumnWidth + textEditWidth + (ScreenTools.defaultFontPixelWidth * 3)
width: height * 0.75
height: voltageCol.height
fillMode: Image.PreserveAspectFit
smooth: true
color: palette.button
cache: false
source: getBatteryImage();
} // Rectangle - Battery settings
QGCLabel {
text: "ESC Calibration"
font.pixelSize: ScreenTools.mediumFontPixelSize
}
Column {
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
anchors.left: batteryImage.right
anchors.verticalCenter: voltageCol.verticalCenter
spacing: ScreenTools.defaultFontPixelHeight
Rectangle {
width: parent.width
height: escCalColumn.height + ScreenTools.defaultFontPixelHeight
color: palette.windowShade
QGCLabel {
text: "Battery Max: " + (battNumCells.value * battHighVolt.value).toFixed(1) + ' V'
}
Column {
id : escCalColumn
anchors.margins: ScreenTools.defaultFontPixelHeight / 2
anchors.left: parent.left
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: "Battery Min: " + (battNumCells.value * battLowVolt.value).toFixed(1) + ' V'
}
}
} // Rectangle - Battery settings
QGCLabel {
text: "ESC Calibration"
font.pixelSize: ScreenTools.mediumFontPixelSize
}
Rectangle {
width: parent.width
height: escCalColumn.height + ScreenTools.defaultFontPixelHeight
color: palette.windowShade
Column {
id : escCalColumn
anchors.margins: ScreenTools.defaultFontPixelHeight / 2
anchors.left: parent.left
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
color: palette.warningText
text: "<font color=\"yellow\">WARNING: Propellers must be removed from vehicle prior to performing ESC calibration.</font>"
}
QGCLabel {
color: palette.warningText
text: "<font color=\"yellow\">WARNING: Propellers must be removed from vehicle prior to performing ESC calibration.</font>"
}
QGCLabel {
text: "You must use USB connection for this operation."
}
QGCLabel {
text: "You must use USB connection for this operation."
}
QGCButton {
text: "Calibrate"
onClicked: controller.calibrateEsc()
QGCButton {
text: "Calibrate"
onClicked: controller.calibrateEsc()
}
}
}
}
QGCLabel {
text: "UAVCAN ESC Configuration"
font.pixelSize: ScreenTools.mediumFontPixelSize
}
Rectangle {
width: parent.width
height: uavCanEscCalColumn.height + ScreenTools.defaultFontPixelHeight
color: palette.windowShade
Column {
id: uavCanEscCalColumn
anchors.margins: ScreenTools.defaultFontPixelHeight / 2
anchors.left: parent.left
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
color: palette.warningText
text: "<font color=\"yellow\">WARNING: Propellers must be removed from vehicle prior to performing UAVCAN ESC configuration.</font>"
}
QGCLabel {
text: "You must use USB connection for this operation."
}
QGCLabel {
text: "UAVCAN ESC Configuration"
font.pixelSize: ScreenTools.mediumFontPixelSize
}
QGCButton {
text: "Start Configuration"
onClicked: controller.busConfigureActuators()
}
Rectangle {
width: parent.width
height: uavCanEscCalColumn.height + ScreenTools.defaultFontPixelHeight
color: palette.windowShade
QGCButton {
text: "End Configuration"
onClicked: controller.StopBusConfigureActuators()
}
}
}
QGCCheckBox {
id: showAdvanced
text: "Show Advanced Settings"
}
QGCLabel {
text: "Advanced Power Settings"
font.pixelSize: ScreenTools.mediumFontPixelSize
visible: showAdvanced.checked
}
Rectangle {
id: batteryRectangle
width: parent.width
height: advBatteryColumn.height + ScreenTools.defaultFontPixelHeight
color: palette.windowShade
visible: showAdvanced.checked
Column {
id: advBatteryColumn
anchors.margins: ScreenTools.defaultFontPixelHeight / 2
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelWidth
Row {
spacing: ScreenTools.defaultFontPixelWidth
Column {
id: uavCanEscCalColumn
anchors.margins: ScreenTools.defaultFontPixelHeight / 2
anchors.left: parent.left
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: "Voltage Drop on Full Load (per cell)"
anchors.baseline: battDropField.baseline
color: palette.warningText
text: "<font color=\"yellow\">WARNING: Propellers must be removed from vehicle prior to performing UAVCAN ESC configuration.</font>"
}
FactTextField {
id: battDropField
width: textEditWidth
fact: battVoltLoadDrop
showUnits: true
QGCLabel {
text: "You must use USB connection for this operation."
}
}
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
text: "Batteries show less voltage at high throttle. Enter the difference in Volts between idle throttle and full " +
"throttle, divided by the number of battery cells. Leave at the default if unsure. " +
"<font color=\"yellow\">If this value is set too high, the battery might be deep discharged and damaged.</font>"
QGCButton {
text: "Start Configuration"
onClicked: controller.busConfigureActuators()
}
QGCButton {
text: "End Configuration"
onClicked: controller.StopBusConfigureActuators()
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCCheckBox {
id: showAdvanced
text: "Show Advanced Settings"
}
QGCLabel {
text: "Compensated Minimum Voltage:"
QGCLabel {
text: "Advanced Power Settings"
font.pixelSize: ScreenTools.mediumFontPixelSize
visible: showAdvanced.checked
}
Rectangle {
id: batteryRectangle
width: parent.width
height: advBatteryColumn.height + ScreenTools.defaultFontPixelHeight
color: palette.windowShade
visible: showAdvanced.checked
Column {
id: advBatteryColumn
anchors.margins: ScreenTools.defaultFontPixelHeight / 2
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelWidth
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: "Voltage Drop on Full Load (per cell)"
anchors.baseline: battDropField.baseline
}
FactTextField {
id: battDropField
width: textEditWidth
fact: battVoltLoadDrop
showUnits: true
}
}
QGCLabel {
text: ((battNumCells.value * battLowVolt.value) - (battNumCells.value * battVoltLoadDrop.value)).toFixed(1) + ' V'
width: parent.width
wrapMode: Text.WordWrap
text: "Batteries show less voltage at high throttle. Enter the difference in Volts between idle throttle and full " +
"throttle, divided by the number of battery cells. Leave at the default if unsure. " +
"<font color=\"yellow\">If this value is set too high, the battery might be deep discharged and damaged.</font>"
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: "Compensated Minimum Voltage:"
}
QGCLabel {
text: ((battNumCells.value * battLowVolt.value) - (battNumCells.value * battVoltLoadDrop.value)).toFixed(1) + ' V'
}
}
}
}
} // Rectangle - Advanced power settings
} // Column
} // Rectangle - Advanced power settings
} // Column
} // Flickable
} // QGCViewPanel
} // QGCView
......@@ -27,6 +27,7 @@
#include "PowerComponentController.h"
#include "QGCMAVLink.h"
#include "QGCMessageBox.h"
#include "UAS.h"
#include <QVariant>
#include <QQmlProperty>
......
......@@ -27,6 +27,7 @@
#include "SensorsComponentController.h"
#include "QGCMAVLink.h"
#include "QGCMessageBox.h"
#include "UAS.h"
#include <QVariant>
#include <QQmlProperty>
......
......@@ -24,6 +24,7 @@
#include "FactPanelController.h"
#include "MultiVehicleManager.h"
#include "QGCMessageBox.h"
#include "UAS.h"
#include <QQmlEngine>
......
......@@ -31,6 +31,7 @@
#include "QGCMessageBox.h"
#include "UASMessageHandler.h"
#include "FirmwarePlugin.h"
#include "UAS.h"
#include <QFile>
#include <QDebug>
......
......@@ -115,7 +115,7 @@ QGCView {
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
width: parent.width / 3
width: parent.width * 0.75
height: syncNeededText.height + (ScreenTools.defaultFontPixelWidth * 2)
border.width: 1
border.color: "white"
......
......@@ -163,9 +163,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
, _runningUnitTests(unitTesting)
, _styleIsDark(true)
, _fakeMobile(false)
#ifdef UNITTEST_BUILD
, _useNewMissionEditor(true) // Unit Tests run new mission editor
#endif
#ifdef QT_DEBUG
, _testHighDPI(false)
#endif
......@@ -337,9 +334,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterUncreatableType<QGCQGeoCoordinate> ("QGroundControl", 1, 0, "QGCQGeoCoordinate", "Reference only");
qmlRegisterUncreatableType<CoordinateVector> ("QGroundControl", 1, 0, "CoordinateVector", "Reference only");
qmlRegisterType<ViewWidgetController> ("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<ParameterEditorController> ("QGroundControl.Controllers", 1, 0, "ParameterEditorController");
qmlRegisterType<CustomCommandWidgetController> ("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController");
qmlRegisterType<FlightModesComponentController> ("QGroundControl.Controllers", 1, 0, "FlightModesComponentController");
qmlRegisterType<AirframeComponentController> ("QGroundControl.Controllers", 1, 0, "AirframeComponentController");
qmlRegisterType<SensorsComponentController> ("QGroundControl.Controllers", 1, 0, "SensorsComponentController");
......@@ -348,6 +343,8 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<ScreenToolsController> ("QGroundControl.Controllers", 1, 0, "ScreenToolsController");
#ifndef __mobile__
qmlRegisterType<ViewWidgetController> ("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<CustomCommandWidgetController> ("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController");
qmlRegisterType<FirmwareUpgradeController> ("QGroundControl.Controllers", 1, 0, "FirmwareUpgradeController");
qmlRegisterType<JoystickConfigController> ("QGroundControl.Controllers", 1, 0, "JoystickConfigController");
#endif
......@@ -420,14 +417,6 @@ bool QGCApplication::_initForNormalAppBoot(void)
_styleIsDark = settings.value(_styleKey, _styleIsDark).toBool();
_loadCurrentStyle();
// Temp hack for new mission editor
#ifdef __mobile__
// Mobile builds always use new Mission Editor
_useNewMissionEditor = true;
#else
_useNewMissionEditor = settings.value("UseNewMissionEditor", false).toBool();
#endif
// Show splash screen
QPixmap splashImage(":/res/SplashScreen");
QSplashScreen* splashScreen = new QSplashScreen(splashImage);
......
......@@ -178,8 +178,6 @@ private:
QStringList _missingParams; ///< List of missing facts to be displayed
bool _fakeMobile; ///< true: Fake ui into displaying mobile interface
bool _useNewMissionEditor; ///< true: Use new Mission Editor
#ifdef QT_DEBUG
bool _testHighDPI; ///< true: double fonts sizes for simulating high dpi devices
......
......@@ -32,6 +32,7 @@
#include <QRegularExpression>
#include <QMessageBox>
#include <QPushButton>
QString QGCFileDialog::getExistingDirectory(
QWidget* parent,
......
......@@ -64,7 +64,7 @@ Button {
background: Item {
property bool down: control.pressed || (control.checkable && control.checked)
implicitWidth: Math.round(TextSingleton.implicitHeight * 4.5)
implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2))
implicitHeight: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 3 * 0.75 : Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2))
Rectangle {
anchors.fill: parent
......
......@@ -11,7 +11,7 @@ CheckBox {
style: CheckBoxStyle {
label: Item {
implicitWidth: text.implicitWidth + 2
implicitHeight: text.implicitHeight
implicitHeight: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 3 * 0.75 : text.implicitHeight
baselineOffset: text.baselineOffset
Rectangle {
anchors.fill: text
......
......@@ -18,7 +18,7 @@ ComboBox {
background: Item {
implicitWidth: Math.round(TextSingleton.implicitHeight * 4.5)
implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2))
implicitHeight: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 3 * 0.75 : Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2))
Rectangle {
anchors.fill: parent
......
......@@ -11,7 +11,7 @@ RadioButton {
style: RadioButtonStyle {
label: Item {
implicitWidth: text.implicitWidth + 2
implicitHeight: text.implicitHeight
implicitHeight: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 3 * 0.75 : text.implicitHeight
baselineOffset: text.y + text.baselineOffset
Rectangle {
anchors.fill: text
......
......@@ -12,6 +12,7 @@ TextField {
property var __qgcPal: QGCPalette { colorGroupEnabled: enabled }
textColor: __qgcPal.textFieldText
height: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 3 * 0.75 : implicitHeight
Label {
id: unitsLabelWidthGenerator
......
......@@ -31,21 +31,25 @@ This file is part of the QGROUNDCONTROL project
#include <QtGlobal>
#include <QApplication>
#include <QSslSocket>
#include <QProcessEnvironment>
#ifndef __mobile__
#include <QSerialPortInfo>
#include <QSerialPortInfo>
#endif
#include <QProcessEnvironment>
#include "QGCApplication.h"
#include "MainWindow.h"
#ifdef QT_DEBUG
#ifndef __mobile__
#include "UnitTest.h"
#endif
#include "CmdLineOptParser.h"
#ifdef Q_OS_WIN
#include <crtdbg.h>
#endif
#ifndef __mobile__
#include "UnitTest.h"
#endif
#include "CmdLineOptParser.h"
#ifdef Q_OS_WIN
#include <crtdbg.h>
#endif
#endif
#include <iostream>
/* SDL does ugly things to main() */
......
......@@ -33,11 +33,11 @@ This file is part of the QGROUNDCONTROL project
#include <QTimer>
#include <QHostInfo>
#include <QSplashScreen>
#include <QQuickView>
#include <QDesktopWidget>
#include <QScreen>
#include <QDesktopServices>
#include <QDockWidget>
#include "QGC.h"
#include "MAVLinkProtocol.h"
......@@ -46,27 +46,28 @@ This file is part of the QGROUNDCONTROL project
#include "QGCMAVLinkLogPlayer.h"
#include "SettingsDialog.h"
#include "MAVLinkDecoder.h"
#include "QGCMAVLinkMessageSender.h"
#include "UASQuickView.h"
#include "QGCDataPlot2D.h"
#include "Linecharts.h"
#include "QGCTabbedInfoView.h"
#include "UASRawStatusView.h"
#include "FlightDisplayView.h"
#include "FlightDisplayWidget.h"
#include "SetupView.h"
#include "QGCUASFileViewMulti.h"
#include "QGCApplication.h"
#include "QGCFileDialog.h"
#include "QGCMessageBox.h"
#include "QGCDockWidget.h"
#include "MultiVehicleManager.h"
#include "CustomCommandWidget.h"
#include "HomePositionManager.h"
#include "MissionEditor.h"
#include "LogCompressor.h"
#include "UAS.h"
#ifndef __mobile__
#include "QGCUASFileViewMulti.h"
#include "UASQuickView.h"
#include "QGCTabbedInfoView.h"
#include "UASRawStatusView.h"
#include "CustomCommandWidget.h"
#include "QGCDockWidget.h"
#include "FlightDisplayWidget.h"
#include "UASInfoWidget.h"
#include "HILDockWidget.h"
#endif
......@@ -86,6 +87,7 @@ This file is part of the QGROUNDCONTROL project
/// The key under which the Main Window settings are saved
const char* MAIN_SETTINGS_GROUP = "QGC_MAINWINDOW";
#ifndef __mobile__
const char* MainWindow::_mavlinkDockWidgetName = "MAVLINK_INSPECTOR_DOCKWIDGET";
const char* MainWindow::_customCommandWidgetName = "CUSTOM_COMMAND_DOCKWIDGET";
const char* MainWindow::_filesDockWidgetName = "FILE_VIEW_DOCKWIDGET";
......@@ -94,6 +96,7 @@ const char* MainWindow::_mapViewDockWidgetName = "MAP_VIEW_DOCKWIDGET";
const char* MainWindow::_pfdDockWidgetName = "PRIMARY_FLIGHT_DISPLAY_DOCKWIDGET";
const char* MainWindow::_uasInfoViewDockWidgetName = "UAS_INFO_INFOVIEW_DOCKWIDGET";
const char* MainWindow::_hilDockWidgetName = "HIL_DOCKWIDGET";
#endif
static MainWindow* _instance = NULL; ///< @brief MainWindow singleton
......@@ -162,10 +165,12 @@ MainWindow::MainWindow(QSplashScreen* splashScreen)
menuBar()->setNativeMenuBar(false);
#endif
#ifndef __mobile__
#ifdef UNITTEST_BUILD
QAction* qmlTestAction = new QAction("Test QML palette and controls", NULL);
connect(qmlTestAction, &QAction::triggered, this, &MainWindow::_showQmlTestWidget);
_ui.menuWidgets->addAction(qmlTestAction);
#endif
#endif
// Load QML Toolbar
......@@ -184,9 +189,12 @@ MainWindow::MainWindow(QSplashScreen* splashScreen)
setStatusBar(new QStatusBar(this));
statusBar()->setSizeGripEnabled(true);
#ifndef __mobile__
emit initStatusChanged(tr("Building common widgets."), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
_buildCommonWidgets();
emit initStatusChanged(tr("Building common actions"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
#endif
// Create actions
connectCommonActions();
// Connect user interface devices
......@@ -332,6 +340,7 @@ QString MainWindow::_getWindowGeometryKey()
return "_geometry";
}
#ifndef __mobile__
void MainWindow::_createDockWidget(const QString& title, const QString& name, Qt::DockWidgetArea area, QWidget* innerWidget)
{
Q_ASSERT(!_mapName2DockWidget.contains(name));
......@@ -401,46 +410,6 @@ void MainWindow::_buildCommonWidgets(void)
}
}
void MainWindow::_buildMissionEditorView(void)
{
if (!_missionEditorView) {
_missionEditorView = new MissionEditor(this);
_missionEditorView->setVisible(false);
}
}
void MainWindow::_buildFlightView(void)
{
if (!_flightView) {
_flightView = new FlightDisplayView(this);
_flightView->setVisible(false);
}
}
void MainWindow::_buildSetupView(void)
{
if (!_setupView) {
_setupView = new SetupView(this);
_setupView->setVisible(false);
}
}
void MainWindow::_buildAnalyzeView(void)
{
if (!_analyzeView) {
_analyzeView = new QGCDataPlot2D(this);
_analyzeView->setVisible(false);
}
}
void MainWindow::_buildSimView(void)
{
if (!_simView) {
_simView = new FlightDisplayView(this);
_simView->setVisible(false);
}
}
/// Shows or hides the specified dock widget, creating if necessary
void MainWindow::_showDockWidget(const QString& name, bool show)
{
......@@ -449,18 +418,18 @@ void MainWindow::_showDockWidget(const QString& name, bool show)
// Which would cause us to end up here.
return;
}
// Create the inner widget if we need to
if (!_mapName2DockWidget[name]->widget()) {
_createInnerDockWidget(name);
}
Q_ASSERT(_mapName2DockWidget.contains(name));
QDockWidget* dockWidget = _mapName2DockWidget[name];
Q_ASSERT(dockWidget);
dockWidget->setVisible(show);
Q_ASSERT(_mapDockWidget2Action.contains(dockWidget));
_mapDockWidget2Action[dockWidget]->setChecked(show);
}
......@@ -470,9 +439,9 @@ void MainWindow::_createInnerDockWidget(const QString& widgetName)
{
Q_ASSERT(_mapName2DockWidget.contains(widgetName)); // QDockWidget should already exist
Q_ASSERT(!_mapName2DockWidget[widgetName]->widget()); // Inner widget should not
QWidget* widget = NULL;
if (widgetName == _mavlinkDockWidgetName) {
widget = new QGCMAVLinkInspector(MAVLinkProtocol::instance(),this);
} else if (widgetName == _customCommandWidgetName) {
......@@ -494,7 +463,7 @@ void MainWindow::_createInnerDockWidget(const QString& widgetName)
} else {
qWarning() << "Attempt to create unknown Inner Dock Widget" << widgetName;
}
if (widget) {
QDockWidget* dockWidget = _mapName2DockWidget[widgetName];
Q_CHECK_PTR(dockWidget);
......@@ -503,6 +472,53 @@ void MainWindow::_createInnerDockWidget(const QString& widgetName)
}
}
void MainWindow::_hideAllDockWidgets(void)
{
foreach(QDockWidget* dockWidget, _mapName2DockWidget) {
dockWidget->setVisible(false);
}
}
void MainWindow::_showDockWidgetAction(bool show)
{
QAction* action = dynamic_cast<QAction*>(QObject::sender());
Q_ASSERT(action);
_showDockWidget(action->data().toString(), show);
}
#endif
void MainWindow::_buildMissionEditorView(void)
{
if (!_missionEditorView) {
_missionEditorView = new MissionEditor(this);
_missionEditorView->setVisible(false);
}
}
void MainWindow::_buildFlightView(void)
{
if (!_flightView) {
_flightView = new FlightDisplayView(this);
_flightView->setVisible(false);
}
}
void MainWindow::_buildSetupView(void)
{
if (!_setupView) {
_setupView = new SetupView(this);
_setupView->setVisible(false);
}
}
void MainWindow::_buildAnalyzeView(void)
{
if (!_analyzeView) {
_analyzeView = new QGCDataPlot2D(this);
_analyzeView->setVisible(false);
}
}
void MainWindow::fullScreenActionItemCallback(bool)
{
_ui.actionNormal->setChecked(false);
......@@ -804,10 +820,10 @@ void MainWindow::_loadCurrentViewState(void)
_centralLayout->setContentsMargins(0, 0, 0, 0);
_currentViewWidget->setVisible(true);
#ifndef __mobile__
// Hide all widgets from previous view
_hideAllDockWidgets();
#ifndef __mobile__
// Restore the widgets for the new view
QString widgetNames = settings.value(_getWindowStateKey() + "WIDGETS", defaultWidgets).toString();
qDebug() << widgetNames;
......@@ -829,21 +845,6 @@ void MainWindow::_loadCurrentViewState(void)
emit repaintCanvas();
}
void MainWindow::_hideAllDockWidgets(void)
{
foreach(QDockWidget* dockWidget, _mapName2DockWidget) {
dockWidget->setVisible(false);
}
}
void MainWindow::_showDockWidgetAction(bool show)
{
QAction* action = dynamic_cast<QAction*>(QObject::sender());
Q_ASSERT(action);
_showDockWidget(action->data().toString(), show);
}
void MainWindow::loadAnalyzeView()
{
if (_currentView != VIEW_ANALYZE)
......
......@@ -41,7 +41,6 @@ This file is part of the QGROUNDCONTROL project
#include "LinkManager.h"
#include "LinkInterface.h"
#include "UASInterface.h"
#include "UASInfoWidget.h"
#include "CameraView.h"
#if (defined QGC_MOUSE_ENABLED_WIN) | (defined QGC_MOUSE_ENABLED_LINUX)
#include "Mouse6dofInput.h"
......@@ -53,16 +52,13 @@ This file is part of the QGROUNDCONTROL project
#include "QGCMAVLinkInspector.h"
#include "QGCMAVLinkLogPlayer.h"
#include "MAVLinkDecoder.h"
#include "QGCUASFileViewMulti.h"
#include "Vehicle.h"
class QGCMAVLinkMessageSender;
class QGCFirmwareUpdate;
class QSplashScreen;
class QGCStatusBar;
class Linecharts;
class QGCDataPlot2D;
class QGCUASFileViewMulti;
/**
* @brief Main Application Window
......@@ -212,19 +208,11 @@ protected:
// Center widgets
QPointer<Linecharts> linechartWidget;
#ifdef QGC_OSG_ENABLED
QPointer<QWidget> q3DWidget;
#endif
QPointer<QGCFirmwareUpdate> firmwareUpdateWidget;
QPointer<MainToolBar> _mainToolBar;
QPointer<QDockWidget> mavlinkInspectorWidget;
QPointer<MAVLinkDecoder> mavlinkDecoder;
QPointer<QDockWidget> mavlinkSenderWidget;
QGCMAVLinkLogPlayer* logPlayer;
QPointer<QGCUASFileViewMulti> fileWidget;
#ifdef QGC_MOUSE_ENABLED_WIN
/** @brief 3d Mouse support (WIN only) */
Mouse3DInput* mouseInput; ///< 3dConnexion 3dMouse SDK
......@@ -251,15 +239,17 @@ protected:
QTimer windowNameUpdateTimer;
private slots:
void _showDockWidgetAction(bool show);
void _linkStateChange(LinkInterface*);
void _closeWindow(void) { close(); }
void _vehicleAdded(Vehicle* vehicle);
#ifndef __mobile__
void _showDockWidgetAction(bool show);
#endif
#ifdef UNITTEST_BUILD
void _showQmlTestWidget(void);
#endif
void _closeWindow(void) { close(); }
private slots:
void _vehicleAdded(Vehicle* vehicle);
private:
/// Constructor is private since all creation should be through MainWindow::_create
......@@ -272,10 +262,9 @@ private:
QPointer<QWidget> _flightView;
QPointer<QWidget> _setupView;
QPointer<QWidget> _analyzeView;
QPointer<QWidget> _simView;
QPointer<QWidget> _terminalView;
QPointer<QWidget> _missionEditorView;
#ifndef __mobile__
// Dock widget names
static const char* _mavlinkDockWidgetName;
static const char* _customCommandWidgetName;
......@@ -288,23 +277,25 @@ private:
QMap<QString, QDockWidget*> _mapName2DockWidget;
QMap<QDockWidget*, QAction*> _mapDockWidget2Action;
#endif
void _buildPlanView(void);
void _buildFlightView(void);
void _buildSetupView(void);
void _buildAnalyzeView(void);
void _buildSimView(void);
void _buildTerminalView(void);
void _buildMissionEditorView(void);
void _storeCurrentViewState(void);
void _loadCurrentViewState(void);
#ifndef __mobile__
void _createDockWidget(const QString& title, const QString& name, Qt::DockWidgetArea area, QWidget* innerWidget);
void _createInnerDockWidget(const QString& widgetName);
void _buildCommonWidgets(void);
void _hideAllDockWidgets(void);
void _showDockWidget(const QString &name, bool show);
#endif
bool _autoReconnect;
bool _lowPowerMode; ///< If enabled, QGC reduces the update rates of all widgets
......
#include "QGCMainWindowAPConfigurator.h"
QGCMainWindowAPConfigurator::QGCMainWindowAPConfigurator(QObject *parent) :
QObject(parent)
{
}
#ifndef QGCMAINWINDOWAPCONFIGURATOR_H
#define QGCMAINWINDOWAPCONFIGURATOR_H
#include <QObject>
class QGCMainWindowAPConfigurator : public QObject
{
Q_OBJECT
public:
explicit QGCMainWindowAPConfigurator(QObject *parent = 0);
signals:
public slots:
};
#endif // QGCMAINWINDOWAPCONFIGURATOR_H
......@@ -2,8 +2,8 @@
#include "Linecharts.h"
#include "MultiVehicleManager.h"
#include "MainWindow.h"
#include "UAS.h"
Linecharts::Linecharts(QWidget *parent) :
QStackedWidget(parent),
......
#include "QGCMAVLinkMessageSender.h"
#include "ui_QGCMAVLinkMessageSender.h"
#include "MAVLinkProtocol.h"
QGCMAVLinkMessageSender::QGCMAVLinkMessageSender(MAVLinkProtocol* mavlink, QWidget *parent) :
QWidget(parent),
protocol(mavlink),
ui(new Ui::QGCMAVLinkMessageSender)
{
ui->setupUi(this);
mavlink_message_info_t msg[256] = MAVLINK_MESSAGE_INFO;
memcpy(messageInfo, msg, sizeof(mavlink_message_info_t)*256);
QStringList header;
header << tr("Name");
header << tr("Value");
header << tr("Type");
ui->treeWidget->setHeaderLabels(header);
createTreeView();
connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
//refreshTimer.start(1000); // Refresh at 1 Hz interval
connect(ui->sendButton, SIGNAL(pressed()), this, SLOT(sendMessage()));
}
void QGCMAVLinkMessageSender::refresh()
{
// Send messages
foreach (unsigned int i, managementItems.keys())
{
if (!sendTimers.contains(i))
{
//sendTimers.insert(i, new QTimer())
}
}
// ui->treeWidget->topLevelItem(0)->children();
}
bool QGCMAVLinkMessageSender::sendMessage()
{
return sendMessage(ui->messageIdSpinBox->value());
}
bool QGCMAVLinkMessageSender::sendMessage(unsigned int msgid)
{
QString msgname(messageInfo[msgid].name);
if (msgid == 0 || msgid > 255 || messageInfo[msgid].name == NULL || msgname.compare(QString("EMPTY")))
{
return false;
}
bool result = true;
if (treeWidgetItems.contains(msgid))
{
// Fill message fields
mavlink_message_t msg;
QList<QTreeWidgetItem*> fields;// = treeWidgetItems.value(msgid)->;
for (unsigned int i = 0; i < messageInfo[msgid].num_fields; ++i)
{
QTreeWidgetItem* field = fields.at(i);
int fieldid = i;
uint8_t* m = ((uint8_t*)(&msg))+8;
switch (messageInfo[msgid].fields[fieldid].type)
{
case MAVLINK_TYPE_CHAR:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
char* str = (char*)(m+messageInfo[msgid].fields[fieldid].wire_offset);
// Copy data
QString string = field->data(1, Qt::DisplayRole).toString();
// Copy string size
int len = qMin((unsigned int)string.length(), messageInfo[msgid].fields[fieldid].array_length);
memcpy(str, string.toStdString().c_str(), len);
// Enforce null termination
str[len-1] = '\0';
}
else
{
// Single char
char* b = ((char*)(m+messageInfo[msgid].fields[fieldid].wire_offset));
*b = field->data(1, Qt::DisplayRole).toChar().toLatin1();
}
break;
case MAVLINK_TYPE_UINT8_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
uint8_t* nums = m+messageInfo[msgid].fields[fieldid].wire_offset;
for (unsigned int j = 0; j < messageInfo[msgid].fields[fieldid].array_length; ++j)
{
if ((unsigned int)(field->data(1, Qt::DisplayRole).toString().split(" ").size()) > j)
{
nums[j] = field->data(1, Qt::DisplayRole).toString().split(" ").at(j).toInt();
}
}
}
else
{
// Single value
uint8_t* u = (m+messageInfo[msgid].fields[fieldid].wire_offset);
*u = field->data(1, Qt::DisplayRole).toChar().toLatin1();
}
break;
case MAVLINK_TYPE_INT8_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
int8_t* nums = reinterpret_cast<int8_t*>((m+messageInfo[msgid].fields[fieldid].wire_offset));
for (unsigned int j = 0; j < messageInfo[msgid].fields[fieldid].array_length; ++j)
{
if ((unsigned int)(field->data(1, Qt::DisplayRole).toString().split(" ").size()) > j)
{
nums[j] = field->data(1, Qt::DisplayRole).toString().split(" ").at(j).toInt();
}
}
}
else
{
// Single value
int8_t* u = reinterpret_cast<int8_t*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
*u = field->data(1, Qt::DisplayRole).toChar().toLatin1();
}
break;
case MAVLINK_TYPE_INT16_T:
case MAVLINK_TYPE_UINT16_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
uint16_t* nums = reinterpret_cast<uint16_t*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
for (unsigned int j = 0; j < messageInfo[msgid].fields[fieldid].array_length; ++j)
{
if ((unsigned int)(field->data(1, Qt::DisplayRole).toString().split(" ").size()) > j)
{
nums[j] = field->data(1, Qt::DisplayRole).toString().split(" ").at(j).toUInt();
}
}
}
else
{
// Single value
uint16_t* u = reinterpret_cast<uint16_t*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
*u = field->data(1, Qt::DisplayRole).toUInt();
}
break;
case MAVLINK_TYPE_INT32_T:
case MAVLINK_TYPE_UINT32_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
int32_t* nums = reinterpret_cast<int32_t*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
for (unsigned int j = 0; j < messageInfo[msgid].fields[fieldid].array_length; ++j)
{
if ((unsigned int)(field->data(1, Qt::DisplayRole).toString().split(" ").size()) > j)
{
nums[j] = field->data(1, Qt::DisplayRole).toString().split(" ").at(j).toUInt();
}
}
}
else
{
// Single value
int32_t* u = reinterpret_cast<int32_t*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
*u = field->data(1, Qt::DisplayRole).toUInt();
}
break;
case MAVLINK_TYPE_INT64_T:
case MAVLINK_TYPE_UINT64_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
int64_t* nums = reinterpret_cast<int64_t*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
for (unsigned int j = 0; j < messageInfo[msgid].fields[fieldid].array_length; ++j)
{
if ((unsigned int)(field->data(1, Qt::DisplayRole).toString().split(" ").size()) > j)
{
nums[j] = field->data(1, Qt::DisplayRole).toString().split(" ").at(j).toULongLong();
}
}
}
else
{
// Single value
int64_t* u = reinterpret_cast<int64_t*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
*u = field->data(1, Qt::DisplayRole).toULongLong();
}
break;
case MAVLINK_TYPE_FLOAT:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
float* nums = reinterpret_cast<float*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
for (unsigned int j = 0; j < messageInfo[msgid].fields[fieldid].array_length; ++j)
{
if ((unsigned int)(field->data(1, Qt::DisplayRole).toString().split(" ").size()) > j)
{
nums[j] = field->data(1, Qt::DisplayRole).toString().split(" ").at(j).toFloat();
}
}
}
else
{
// Single value
float* u = reinterpret_cast<float*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
*u = field->data(1, Qt::DisplayRole).toFloat();
}
break;
case MAVLINK_TYPE_DOUBLE:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
double* nums = reinterpret_cast<double*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
for (unsigned int j = 0; j < messageInfo[msgid].fields[fieldid].array_length; ++j)
{
if ((unsigned int)(field->data(1, Qt::DisplayRole).toString().split(" ").size()) > j)
{
nums[j] = field->data(1, Qt::DisplayRole).toString().split(" ").at(j).toDouble();
}
}
}
else
{
// Single value
double* u = reinterpret_cast<double*>(m+messageInfo[msgid].fields[fieldid].wire_offset);
*u = field->data(1, Qt::DisplayRole).toDouble();
}
break;
}
}
// Send message
protocol->sendMessage(msg);
}
else
{
result = false;
}
return result;
}
QGCMAVLinkMessageSender::~QGCMAVLinkMessageSender()
{
delete ui;
}
void QGCMAVLinkMessageSender::createTreeView()
{
for (int i = 0; i < 256; ++i)//mavlink_message_t msg, receivedMessages)
{
// Update the tree view
QString messageName("%1 (%2 Hz, #%3)");
float msgHz = messagesHz.value(i, 0);
// Ignore non-existent messages
if (QString(messageInfo[i].name) == "EMPTY") continue;
messageName = messageName.arg(messageInfo[i].name).arg(msgHz, 3, 'f', 1).arg(i);
if (!treeWidgetItems.contains(i))
{
QStringList fields;
fields << messageName;
QTreeWidgetItem* widget = new QTreeWidgetItem(fields);
widget->setFirstColumnSpanned(true);
for (unsigned int j = 0; j < messageInfo[i].num_fields; ++j)
{
QTreeWidgetItem* field = new QTreeWidgetItem();
widget->addChild(field);
}
treeWidgetItems.insert(i, widget);
ui->treeWidget->addTopLevelItem(widget);
QTreeWidgetItem* message = widget;//treeWidgetItems.value(msg->msgid);
message->setFirstColumnSpanned(true);
message->setData(0, Qt::DisplayRole, QVariant(messageName));
for (unsigned int j = 0; j < messageInfo[i].num_fields; ++j)
{
createField(i, j, message->child(j));
}
// Add management fields, such as update rate and send button
// QTreeWidgetItem* management = new QTreeWidgetItem();
// widget->addChild(management);
// management->setData(0, Qt::DisplayRole, "Rate:");
// management->setData(1, Qt::DisplayRole, 0);
// management->setData(2, Qt::DisplayRole, "Hz");
// managementItems.insert(i, management);
}
}
}
void QGCMAVLinkMessageSender::createField(int msgid, int fieldid, QTreeWidgetItem* item)
{
// Add field tree widget item
item->setData(0, Qt::DisplayRole, QVariant(messageInfo[msgid].fields[fieldid].name));
//uint8_t* m = ((uint8_t*)(receivedMessages+msgid))+8;
switch (messageInfo[msgid].fields[fieldid].type)
{
case MAVLINK_TYPE_CHAR:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
item->setData(2, Qt::DisplayRole, "char");
item->setData(1, Qt::DisplayRole, "");
}
else
{
// Single char
item->setData(2, Qt::DisplayRole, QString("char[%1]").arg(messageInfo[msgid].fields[fieldid].array_length));
item->setData(1, Qt::DisplayRole, "");
}
break;
case MAVLINK_TYPE_UINT8_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
// Enforce null termination
QString tmp("%1, ");
QString string;
for (unsigned int j = 0; j < messageInfo[msgid].fields[fieldid].array_length; ++j)
{
string += tmp.arg(0);
}
item->setData(2, Qt::DisplayRole, QString("uint8_t[%1]").arg(messageInfo[msgid].fields[fieldid].array_length));
item->setData(1, Qt::DisplayRole, string);
}
else
{
// Single value
item->setData(2, Qt::DisplayRole, "uint8_t");
item->setData(1, Qt::DisplayRole, 0);
}
break;
case MAVLINK_TYPE_INT8_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
// Enforce null termination
QString tmp("%1, ");
QString string;
for (unsigned int j = 0; j < messageInfo[msgid].fields[j].array_length; ++j)
{
string += tmp.arg(0);
}
item->setData(2, Qt::DisplayRole, QString("int8_t[%1]").arg(messageInfo[msgid].fields[fieldid].array_length));
item->setData(1, Qt::DisplayRole, string);
}
else
{
// Single value
item->setData(2, Qt::DisplayRole, "int8_t");
item->setData(1, Qt::DisplayRole, 0);
}
break;
case MAVLINK_TYPE_UINT16_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
// Enforce null termination
QString tmp("%1, ");
QString string;
for (unsigned int j = 0; j < messageInfo[msgid].fields[j].array_length; ++j)
{
string += tmp.arg(0);
}
item->setData(2, Qt::DisplayRole, QString("uint16_t[%1]").arg(messageInfo[msgid].fields[fieldid].array_length));
item->setData(1, Qt::DisplayRole, string);
}
else
{
// Single value
item->setData(2, Qt::DisplayRole, "uint16_t");
item->setData(1, Qt::DisplayRole, 0);
}
break;
case MAVLINK_TYPE_INT16_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
// Enforce null termination
QString tmp("%1, ");
QString string;
for (unsigned int j = 0; j < messageInfo[msgid].fields[j].array_length; ++j)
{
string += tmp.arg(0);
}
item->setData(2, Qt::DisplayRole, QString("int16_t[%1]").arg(messageInfo[msgid].fields[fieldid].array_length));
item->setData(1, Qt::DisplayRole, string);
}
else
{
// Single value
item->setData(2, Qt::DisplayRole, "int16_t");
item->setData(1, Qt::DisplayRole, 0);
}
break;
case MAVLINK_TYPE_UINT32_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
// Enforce null termination
QString tmp("%1, ");
QString string;
for (unsigned int j = 0; j < messageInfo[msgid].fields[j].array_length; ++j)
{
string += tmp.arg(0);
}
item->setData(2, Qt::DisplayRole, QString("uint32_t[%1]").arg(messageInfo[msgid].fields[fieldid].array_length));
item->setData(1, Qt::DisplayRole, string);
}
else
{
// Single value
item->setData(2, Qt::DisplayRole, "uint32_t");
item->setData(1, Qt::DisplayRole, 0);
}
break;
case MAVLINK_TYPE_INT32_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
// Enforce null termination
QString tmp("%1, ");
QString string;
for (unsigned int j = 0; j < messageInfo[msgid].fields[j].array_length; ++j)
{
string += tmp.arg(0);
}
item->setData(2, Qt::DisplayRole, QString("int32_t[%1]").arg(messageInfo[msgid].fields[fieldid].array_length));
item->setData(1, Qt::DisplayRole, string);
}
else
{
// Single value
item->setData(2, Qt::DisplayRole, "int32_t");
item->setData(1, Qt::DisplayRole, 0);
}
break;
case MAVLINK_TYPE_FLOAT:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
// Enforce null termination
QString tmp("%1, ");
QString string;
for (unsigned int j = 0; j < messageInfo[msgid].fields[j].array_length; ++j)
{
string += tmp.arg(0.0f);
}
item->setData(2, Qt::DisplayRole, QString("float[%1]").arg(messageInfo[msgid].fields[fieldid].array_length));
item->setData(1, Qt::DisplayRole, string);
}
else
{
// Single value
item->setData(2, Qt::DisplayRole, "float");
item->setData(1, Qt::DisplayRole, 0.0f);
}
break;
case MAVLINK_TYPE_DOUBLE:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
// Enforce null termination
QString tmp("%1, ");
QString string;
for (unsigned int j = 0; j < messageInfo[msgid].fields[j].array_length; ++j)
{
string += tmp.arg(0);
}
item->setData(2, Qt::DisplayRole, QString("double[%1]").arg(messageInfo[msgid].fields[fieldid].array_length));
item->setData(1, Qt::DisplayRole, string);
}
else
{
// Single value
item->setData(2, Qt::DisplayRole, "double");
item->setData(1, Qt::DisplayRole, 0.0);
}
break;
case MAVLINK_TYPE_UINT64_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
// Enforce null termination
QString tmp("%1, ");
QString string;
for (unsigned int j = 0; j < messageInfo[msgid].fields[j].array_length; ++j)
{
string += tmp.arg(0);
}
item->setData(2, Qt::DisplayRole, QString("uint64_t[%1]").arg(messageInfo[msgid].fields[fieldid].array_length));
item->setData(1, Qt::DisplayRole, string);
}
else
{
// Single value
item->setData(2, Qt::DisplayRole, "uint64_t");
item->setData(1, Qt::DisplayRole, (quint64) 0);
}
break;
case MAVLINK_TYPE_INT64_T:
if (messageInfo[msgid].fields[fieldid].array_length > 0)
{
// Enforce null termination
QString tmp("%1, ");
QString string;
for (unsigned int j = 0; j < messageInfo[msgid].fields[j].array_length; ++j)
{
string += tmp.arg(0);
}
item->setData(2, Qt::DisplayRole, QString("int64_t[%1]").arg(messageInfo[msgid].fields[fieldid].array_length));
item->setData(1, Qt::DisplayRole, string);
}
else
{
// Single value
item->setData(2, Qt::DisplayRole, "int64_t");
item->setData(1, Qt::DisplayRole, (qint64) 0);
}
break;
}
}
#ifndef QGCMAVLINKMESSAGESENDER_H
#define QGCMAVLINKMESSAGESENDER_H
#include <QWidget>
#include <QTreeWidgetItem>
#include <QMap>
#include <QTimer>
#include "MAVLinkProtocol.h"
namespace Ui {
class QGCMAVLinkMessageSender;
}
class QGCMAVLinkMessageSender : public QWidget
{
Q_OBJECT
friend class QTimer;
public:
explicit QGCMAVLinkMessageSender(MAVLinkProtocol* mavlink, QWidget *parent = 0);
~QGCMAVLinkMessageSender();
public slots:
/** @brief Send message currently selected in ui, taking values from tree view */
bool sendMessage();
protected:
mavlink_message_info_t messageInfo[256]; ///< Meta information about all messages
MAVLinkProtocol* protocol; ///< MAVLink protocol
QMap<int, float> messagesHz; ///< Used to store update rate in Hz
QTimer refreshTimer;
QMap<unsigned int, QTimer*> sendTimers;
QMap<unsigned int, QTreeWidgetItem*> managementItems;
QMap<unsigned int, QTreeWidgetItem*> treeWidgetItems; ///< Messages
/** @brief Create the tree view of all messages */
void createTreeView();
/** @brief Create one field of one message in the tree view of all messages */
void createField(int msgid, int fieldid, QTreeWidgetItem* item);
/** @brief Send message with values taken from tree view */
bool sendMessage(unsigned int id);
protected slots:
/** @brief Read / display values in UI */
void refresh();
private:
Ui::QGCMAVLinkMessageSender *ui;
};
#endif // QGCMAVLINKMESSAGESENDER_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCMAVLinkMessageSender</class>
<widget class="QWidget" name="QGCMAVLinkMessageSender">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QTreeWidget" name="treeWidget">
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QSpinBox" name="messageIdSpinBox"/>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="sendButton">
<property name="text">
<string>Send Message</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -38,6 +38,7 @@ This file is part of the QGROUNDCONTROL project
#include "FlightDisplayView.h"
#include "QGCApplication.h"
#include "MultiVehicleManager.h"
#include "UAS.h"
MainToolBar::MainToolBar(QWidget* parent)
: QGCQmlWidgetHolder(parent)
......
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