Commit 3a37fd25 authored by dogmaphobic's avatar dogmaphobic

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

* mavlink/master:
  Missed qDebug. Sorry for the commit deluge...
  Reducing PIP size on Android a bit. It was kind of big...
  Revert "Start logging on heartbeat instead of connect"
  Doc fix for getting gstreamer in to android build
  Adjustments to Telemetry Data
  Remove removed Widget
  Fixed Style for switch
  Fix opening DockWidget views
  Do not use the text() of the Action to show a DockWidget
  Translate the names of the Views
  Declare the Static Const Char on the .cpp file
  Do not let the Fullscreen/Normal be completely unselected
  Do not dynamic_cast QObject, use qobject_cast, it's faster.
  Support correct parameter set for APM
parents 0818cfe4 b2471b00
<RCC>
<qresource prefix="/unittest">
<file alias="MockLink.params">src/comm/MockLink.params</file>
<file alias="PX4MockLink.params">src/comm/PX4MockLink.params</file>
<file alias="APMArduCopterMockLink.params">src/comm/APMArduCopterMockLink.params</file>
<file alias="APMArduPlaneMockLink.params">src/comm/APMArduPlaneMockLink.params</file>
<file alias="FactSystemTest.qml">src/FactSystem/FactSystemTest.qml</file>
</qresource>
<qresource prefix="/qml">
......
......@@ -75,6 +75,8 @@ Item {
property var _flightVideo: null
property var _savedZoomLevel: 0
property real _pipSize: ScreenTools.isAndroid ? ScreenTools.defaultFontPixelSize * (8) : ScreenTools.defaultFontPixelSize * (9)
FlightDisplayViewController { id: _controller }
MissionController {
......@@ -125,8 +127,8 @@ Item {
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.left: parent.left
anchors.bottom: parent.bottom
height: ScreenTools.defaultFontPixelSize * (9)
width: ScreenTools.defaultFontPixelSize * (9) * (16/9)
height: _pipSize
width: _pipSize * (16/9)
color: "#000010"
border.width: 4
radius: 4
......
......@@ -87,7 +87,6 @@ Item {
altitude: _altitudeWGS84
groundSpeed: _groundSpeed
airSpeed: _airSpeed
climbRate: _climbRate
isSatellite: _mainIsMap ? _flightMap ? _flightMap.isSatelliteMap : true : true
z: QGroundControl.zOrderWidgets
}
......@@ -97,7 +96,7 @@ Item {
id: toolColumn
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelHeight
//-- Map Center Control
......
......@@ -42,7 +42,6 @@ Item {
property real altitude: 0
property real groundSpeed: 0
property real airSpeed: 0
property real climbRate: 0
property real size: ScreenTools.defaultFontPixelSize * (10)
property bool isSatellite: false
property bool active: false
......@@ -78,24 +77,21 @@ Item {
color: isSatellite ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25)
anchors.horizontalCenter: parent.horizontalCenter
}
Row {
width: root.size * 0.8
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: "H"
font.pixelSize: ScreenTools.defaultFontPixelSize * 1.25
width: parent.width * 0.45
color: isSatellite ? "black" : "white"
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: altitude.toFixed(1)
font.pixelSize: ScreenTools.defaultFontPixelSize * 1.25
font.weight: Font.DemiBold
width: parent.width * 0.549
color: isSatellite ? "black" : "white"
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: "Altitude"
font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
width: parent.width
height: ScreenTools.defaultFontPixelHeight * 0.5
color: isSatellite ? "black" : "white"
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: altitude < 10000 ? altitude.toFixed(1) : altitude.toFixed(0)
font.pixelSize: ScreenTools.defaultFontPixelSize * 2.5
font.weight: Font.DemiBold
width: parent.width
color: isSatellite ? "black" : "white"
horizontalAlignment: TextEdit.AlignHCenter
}
//-- Ground Speed
Rectangle {
......@@ -103,25 +99,25 @@ Item {
width: parent.width * 0.9
color: isSatellite ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25)
anchors.horizontalCenter: parent.horizontalCenter
visible: airSpeed <= 0
}
Row {
width: root.size * 0.8
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: "GS"
font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
width: parent.width * 0.45
color: isSatellite ? "black" : "white"
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: groundSpeed.toFixed(1)
font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
font.weight: Font.DemiBold
width: parent.width * 0.549
color: isSatellite ? "black" : "white"
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: "Ground Speed"
font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
width: parent.width
height: ScreenTools.defaultFontPixelHeight * 0.75
color: isSatellite ? "black" : "white"
horizontalAlignment: TextEdit.AlignHCenter
visible: airSpeed <= 0
}
QGCLabel {
text: groundSpeed.toFixed(1)
font.pixelSize: ScreenTools.defaultFontPixelSize * 1.25
font.weight: Font.DemiBold
width: parent.width
color: isSatellite ? "black" : "white"
horizontalAlignment: TextEdit.AlignHCenter
visible: airSpeed <= 0
}
//-- Air Speed
Rectangle {
......@@ -131,51 +127,23 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
visible: airSpeed > 0
}
Row {
width: root.size * 0.8
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: "Air Speed"
font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
width: parent.width
height: ScreenTools.defaultFontPixelHeight * 0.75
color: isSatellite ? "black" : "white"
visible: airSpeed > 0
QGCLabel {
text: "AS"
font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
width: parent.width * 0.45
color: isSatellite ? "black" : "white"
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: airSpeed.toFixed(1)
font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
font.weight: Font.DemiBold
width: parent.width * 0.549
color: isSatellite ? "black" : "white"
horizontalAlignment: TextEdit.AlignHCenter
}
horizontalAlignment: TextEdit.AlignHCenter
}
//-- Climb Rate
Rectangle {
height: 1
width: parent.width * 0.9
color: isSatellite ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25)
anchors.horizontalCenter: parent.horizontalCenter
}
Row {
width: root.size * 0.8
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: "VS"
font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
width: parent.width * 0.45
color: isSatellite ? "black" : "white"
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: climbRate.toFixed(1)
font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
font.weight: Font.DemiBold
width: parent.width * 0.549
color: isSatellite ? "black" : "white"
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: airSpeed.toFixed(1)
font.pixelSize: ScreenTools.defaultFontPixelSize * 1.25
font.weight: Font.DemiBold
width: parent.width
color: isSatellite ? "black" : "white"
visible: airSpeed > 0
horizontalAlignment: TextEdit.AlignHCenter
}
//-- Compass
Rectangle {
......
......@@ -60,7 +60,16 @@ TODO: Binaries found in http://gstreamer.freedesktop.org/data/pkg/ios
### Android
Binaries found in http://gstreamer.freedesktop.org/data/pkg/android
Download the [gstreamer-1.0-android-armv7-1.5.2.tar.bz2](http://gstreamer.freedesktop.org/data/pkg/android/1.5.2/gstreamer-1.0-android-armv7-1.5.2.tar.bz2) archive (assuming you want the ARM V7 platform) and extract it to the root qgroundcontrol directory (the same directory qgroundcontrol.pro is located). That's where the build system will look for it.
Download the [gstreamer-1.0-android-armv7-1.5.2.tar.bz2](http://gstreamer.freedesktop.org/data/pkg/android/1.5.2/gstreamer-1.0-android-armv7-1.5.2.tar.bz2) archive (assuming you want the ARM V7 platform).
Create a directory named "gstreamer-1.0-android-armv7-1.5.2" under the root qgroundcontrol directory (the same directory qgroundcontrol.pro is located). Extract the gstreamer tar file under this directory. That's where the build system will look for it. Make sure your archive tool doesn't create any additional top level directories. The structure after extracting the archive should look like this:
qgroundcontrol
├── gstreamer-1.0-android-armv7-1.5.2
│   ├── etc
│   ├── include
│   ├── lib
│   └── share
### Windows
......
This diff is collapsed.
This diff is collapsed.
......@@ -187,6 +187,13 @@ void MAVLinkProtocol::_linkStatusChanged(LinkInterface* link, bool connected)
// Use the same shared pointer as LinkManager
_connectedLinks.append(LinkManager::instance()->sharedPointerForLink(link));
#ifndef __mobile__
if (_connectedLinks.count() == 1) {
// This is the first link, we need to start logging
_startLogging();
}
#endif
// Send command to start MAVLink
// XXX hacky but safe
// Start NSH
......@@ -346,11 +353,6 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
#endif
if (message.msgid == MAVLINK_MSG_ID_HEARTBEAT) {
#ifndef __mobile__
// Start logging on first heartbeat
_startLogging();
#endif
// Notify the vehicle manager of the heartbeat. This will create/update vehicles as needed.
mavlink_heartbeat_t heartbeat;
mavlink_msg_heartbeat_decode(&message, &heartbeat);
......@@ -644,20 +646,20 @@ bool MAVLinkProtocol::_closeLogFile(void)
void MAVLinkProtocol::_startLogging(void)
{
if (!_tempLogFile.isOpen()) {
if (!_logSuspendReplay) {
if (!_tempLogFile.open()) {
emit protocolStatusMessage(tr("MAVLink Protocol"), tr("Opening Flight Data file for writing failed. "
"Unable to write to %1. Please choose a different file location.").arg(_tempLogFile.fileName()));
_closeLogFile();
_logSuspendError = true;
return;
}
qDebug() << "Temp log" << _tempLogFile.fileName();
Q_ASSERT(!_tempLogFile.isOpen());
_logSuspendError = false;
if (!_logSuspendReplay) {
if (!_tempLogFile.open()) {
emit protocolStatusMessage(tr("MAVLink Protocol"), tr("Opening Flight Data file for writing failed. "
"Unable to write to %1. Please choose a different file location.").arg(_tempLogFile.fileName()));
_closeLogFile();
_logSuspendError = true;
return;
}
qDebug() << "Temp log" << _tempLogFile.fileName();
_logSuspendError = false;
}
}
......
......@@ -72,6 +72,7 @@ float MockLink::_vehicleLongitude = -122.08794f;
float MockLink::_vehicleAltitude = 2.5f;
const char* MockConfiguration::_firmwareTypeKey = "FirmwareType";
const char* MockConfiguration::_vehicleTypeKey = "VehicleType";
const char* MockConfiguration::_sendStatusTextKey = "SendStatusText";
MockLink::MockLink(MockConfiguration* config)
......@@ -85,6 +86,7 @@ MockLink::MockLink(MockConfiguration* config)
, _mavBaseMode(MAV_MODE_FLAG_MANUAL_INPUT_ENABLED | MAV_MODE_FLAG_CUSTOM_MODE_ENABLED)
, _mavState(MAV_STATE_STANDBY)
, _firmwareType(MAV_AUTOPILOT_PX4)
, _vehicleType(MAV_TYPE_QUADROTOR)
, _fileServer(NULL)
, _sendStatusText(false)
, _apmSendHomePositionOnEmptyList(false)
......@@ -93,6 +95,7 @@ MockLink::MockLink(MockConfiguration* config)
_config = config;
if (_config) {
_firmwareType = config->firmwareType();
_vehicleType = config->vehicleType();
_sendStatusText = config->sendStatusText();
}
......@@ -113,7 +116,6 @@ MockLink::MockLink(MockConfiguration* config)
MockLink::~MockLink(void)
{
qDebug() << "MockLink destructor";
_disconnect();
}
......@@ -200,7 +202,18 @@ void MockLink::_run50HzTasks(void)
void MockLink::_loadParams(void)
{
QFile paramFile(":/unittest/MockLink.params");
QFile paramFile;
if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
if (_vehicleType == MAV_TYPE_FIXED_WING) {
paramFile.setFileName(":/unittest/APMArduPlaneMockLink.params");
} else {
paramFile.setFileName(":/unittest/APMArduCopterMockLink.params");
}
} else {
paramFile.setFileName(":/unittest/PX4MockLink.params");
}
bool success = paramFile.open(QFile::ReadOnly);
Q_UNUSED(success);
......@@ -234,11 +247,21 @@ void MockLink::_loadParams(void)
case MAV_PARAM_TYPE_INT32:
paramValue = QVariant(valStr.toInt());
break;
case MAV_PARAM_TYPE_UINT16:
paramValue = QVariant((quint16)valStr.toUInt());
break;
case MAV_PARAM_TYPE_INT16:
paramValue = QVariant((qint16)valStr.toInt());
break;
case MAV_PARAM_TYPE_UINT8:
paramValue = QVariant((quint8)valStr.toUInt());
break;
case MAV_PARAM_TYPE_INT8:
paramValue = QVariant((unsigned char)valStr.toUInt());
paramValue = QVariant((qint8)valStr.toUInt());
break;
default:
Q_ASSERT(false);
qCritical() << "Unknown type" << paramType;
paramValue = QVariant(valStr.toInt());
break;
}
......@@ -405,24 +428,38 @@ void MockLink::_setParamFloatUnionIntoMap(int componentId, const QString& paramN
QVariant paramVariant;
switch (paramType) {
case MAV_PARAM_TYPE_INT8:
paramVariant = QVariant::fromValue(valueUnion.param_int8);
break;
case MAV_PARAM_TYPE_INT32:
paramVariant = QVariant::fromValue(valueUnion.param_int32);
break;
case MAV_PARAM_TYPE_UINT32:
paramVariant = QVariant::fromValue(valueUnion.param_uint32);
break;
case MAV_PARAM_TYPE_REAL32:
paramVariant = QVariant::fromValue(valueUnion.param_float);
break;
default:
qCritical() << "Invalid parameter type" << paramType;
case MAV_PARAM_TYPE_REAL32:
paramVariant = QVariant::fromValue(valueUnion.param_float);
break;
case MAV_PARAM_TYPE_UINT32:
paramVariant = QVariant::fromValue(valueUnion.param_uint32);
break;
case MAV_PARAM_TYPE_INT32:
paramVariant = QVariant::fromValue(valueUnion.param_int32);
break;
case MAV_PARAM_TYPE_UINT16:
paramVariant = QVariant::fromValue(valueUnion.param_uint16);
break;
case MAV_PARAM_TYPE_INT16:
paramVariant = QVariant::fromValue(valueUnion.param_int16);
break;
case MAV_PARAM_TYPE_UINT8:
paramVariant = QVariant::fromValue(valueUnion.param_uint8);
break;
case MAV_PARAM_TYPE_INT8:
paramVariant = QVariant::fromValue(valueUnion.param_int8);
break;
default:
qCritical() << "Invalid parameter type" << paramType;
paramVariant = QVariant::fromValue(valueUnion.param_int32);
break;
}
qCDebug(MockLinkLog) << "_setParamFloatUnionIntoMap" << paramName << paramVariant;
......@@ -442,36 +479,65 @@ float MockLink::_floatUnionForParam(int componentId, const QString& paramName)
QVariant paramVar = _mapParamName2Value[componentId][paramName];
switch (paramType) {
case MAV_PARAM_TYPE_INT8:
if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
valueUnion.param_float = (unsigned char)paramVar.toChar().toLatin1();
} else {
valueUnion.param_int8 = (unsigned char)paramVar.toChar().toLatin1();
}
break;
case MAV_PARAM_TYPE_REAL32:
valueUnion.param_float = paramVar.toFloat();
break;
case MAV_PARAM_TYPE_INT32:
if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
valueUnion.param_float = paramVar.toInt();
} else {
valueUnion.param_int32 = paramVar.toInt();
}
break;
case MAV_PARAM_TYPE_UINT32:
if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
valueUnion.param_float = paramVar.toUInt();
} else {
valueUnion.param_uint32 = paramVar.toUInt();
}
break;
case MAV_PARAM_TYPE_UINT32:
if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
valueUnion.param_float = paramVar.toUInt();
} else {
valueUnion.param_uint32 = paramVar.toUInt();
}
break;
case MAV_PARAM_TYPE_INT32:
if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
valueUnion.param_float = paramVar.toInt();
} else {
valueUnion.param_int32 = paramVar.toInt();
}
break;
case MAV_PARAM_TYPE_REAL32:
valueUnion.param_float = paramVar.toFloat();
break;
case MAV_PARAM_TYPE_UINT16:
if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
valueUnion.param_float = paramVar.toUInt();
} else {
valueUnion.param_uint16 = paramVar.toUInt();
}
break;
default:
qCritical() << "Invalid parameter type" << paramType;
case MAV_PARAM_TYPE_INT16:
if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
valueUnion.param_float = paramVar.toInt();
} else {
valueUnion.param_int16 = paramVar.toInt();
}
break;
case MAV_PARAM_TYPE_UINT8:
if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
valueUnion.param_float = paramVar.toUInt();
} else {
valueUnion.param_uint8 = paramVar.toUInt();
}
break;
case MAV_PARAM_TYPE_INT8:
if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
valueUnion.param_float = (unsigned char)paramVar.toChar().toLatin1();
} else {
valueUnion.param_int8 = (unsigned char)paramVar.toChar().toLatin1();
}
break;
default:
if (_firmwareType == MAV_AUTOPILOT_ARDUPILOTMEGA) {
valueUnion.param_float = paramVar.toInt();
} else {
valueUnion.param_int32 = paramVar.toInt();
}
qCritical() << "Invalid parameter type" << paramType;
}
return valueUnion.param_float;
......@@ -801,6 +867,7 @@ void MockLink::_sendStatusTextMessages(void)
MockConfiguration::MockConfiguration(const QString& name)
: LinkConfiguration(name)
, _firmwareType(MAV_AUTOPILOT_PX4)
, _vehicleType(MAV_TYPE_QUADROTOR)
, _sendStatusText(false)
{
......@@ -810,6 +877,7 @@ MockConfiguration::MockConfiguration(MockConfiguration* source)
: LinkConfiguration(source)
{
_firmwareType = source->_firmwareType;
_vehicleType = source->_vehicleType;
_sendStatusText = source->_sendStatusText;
}
......@@ -824,6 +892,7 @@ void MockConfiguration::copyFrom(LinkConfiguration *source)
}
_firmwareType = usource->_firmwareType;
_vehicleType = usource->_vehicleType;
_sendStatusText = usource->_sendStatusText;
}
......@@ -831,6 +900,7 @@ void MockConfiguration::saveSettings(QSettings& settings, const QString& root)
{
settings.beginGroup(root);
settings.setValue(_firmwareTypeKey, (int)_firmwareType);
settings.setValue(_vehicleTypeKey, (int)_vehicleType);
settings.setValue(_sendStatusTextKey, _sendStatusText);
settings.sync();
settings.endGroup();
......@@ -840,6 +910,7 @@ void MockConfiguration::loadSettings(QSettings& settings, const QString& root)
{
settings.beginGroup(root);
_firmwareType = (MAV_AUTOPILOT)settings.value(_firmwareTypeKey, (int)MAV_AUTOPILOT_PX4).toInt();
_vehicleType = (MAV_TYPE)settings.value(_vehicleTypeKey, (int)MAV_TYPE_QUADROTOR).toInt();
_sendStatusText = settings.value(_sendStatusTextKey, false).toBool();
settings.endGroup();
}
......
......@@ -44,6 +44,9 @@ public:
MAV_AUTOPILOT firmwareType(void) { return _firmwareType; }
void setFirmwareType(MAV_AUTOPILOT firmwareType) { _firmwareType = firmwareType; }
MAV_TYPE vehicleType(void) { return _vehicleType; }
void setVehicleType(MAV_TYPE vehicleType) { _vehicleType = vehicleType; }
/// @param sendStatusText true: mavlink status text messages will be sent for each severity, as well as voice output info message
void setSendStatusText(bool sendStatusText) { _sendStatusText = sendStatusText; }
bool sendStatusText(void) { return _sendStatusText; }
......@@ -57,9 +60,11 @@ public:
private:
MAV_AUTOPILOT _firmwareType;
MAV_TYPE _vehicleType;
bool _sendStatusText;
static const char* _firmwareTypeKey;
static const char* _vehicleTypeKey;
static const char* _sendStatusTextKey;
};
......@@ -183,8 +188,9 @@ private:
uint32_t _mavCustomMode;
uint8_t _mavState;
MockConfiguration* _config;
MAV_AUTOPILOT _firmwareType;
MockConfiguration* _config;
MAV_AUTOPILOT _firmwareType;
MAV_TYPE _vehicleType;
MockLinkFileServer* _fileServer;
......
......@@ -84,15 +84,29 @@ This file is part of the QGROUNDCONTROL project
const char* MAIN_SETTINGS_GROUP = "QGC_MAINWINDOW";
#ifndef __mobile__
const char* MainWindow::_mavlinkDockWidgetName = "MAVLink Inspector";
const char* MainWindow::_customCommandWidgetName = "Custom Command";
const char* MainWindow::_filesDockWidgetName = "Onboard Files";
const char* MainWindow::_uasStatusDetailsDockWidgetName = "Status Details";
const char* MainWindow::_uasInfoViewDockWidgetName = "Info View";
const char* MainWindow::_hilDockWidgetName = "HIL Config";
const char* MainWindow::_analyzeDockWidgetName = "Analyze";
const char* MainWindow::_visibleWidgetsKey = "VisibleWidgets";
enum DockWidgetTypes {
MAVLINK_INSPECTOR,
CUSTOM_COMMAND,
ONBOARD_FILES,
STATUS_DETAILS,
INFO_VIEW,
HIL_CONFIG,
ANALYZE
};
static const char *rgDockWidgetNames[] = {
"MAVLink Inspector",
"Custom Command",
"Onboard Files",
"Status Details",
"Info View",
"HIL Config",
"Analyze"
};
#define ARRAY_SIZE(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0]))
static const char* _visibleWidgetsKey = "VisibleWidgets";
#endif
static MainWindow* _instance = NULL; ///< @brief MainWindow singleton
......@@ -318,27 +332,16 @@ void MainWindow::_buildCommonWidgets(void)
logPlayer = new QGCMAVLinkLogPlayer(statusBar());
statusBar()->addPermanentWidget(logPlayer);
static const char* rgDockWidgetNames[] = {
_mavlinkDockWidgetName,
_customCommandWidgetName,
_filesDockWidgetName,
_uasStatusDetailsDockWidgetName,
_uasInfoViewDockWidgetName,
_hilDockWidgetName,
_analyzeDockWidgetName,
};
static const size_t cDockWidgetNames = sizeof(rgDockWidgetNames) / sizeof(rgDockWidgetNames[0]);
for (size_t i=0; i<cDockWidgetNames; i++) {
for (int i = 0, end = ARRAY_SIZE(rgDockWidgetNames); i < end; i++) {
const char* pDockWidgetName = rgDockWidgetNames[i];
// Add to menu
QAction* action = new QAction(pDockWidgetName, NULL);
QAction* action = new QAction(tr(pDockWidgetName), NULL);
action->setCheckable(true);
action->setData(pDockWidgetName);
action->setData(i);
connect(action, &QAction::triggered, this, &MainWindow::_showDockWidgetAction);
_ui.menuWidgets->addAction(action);
_mapName2Action[pDockWidgetName] = action;
}
}
......@@ -365,28 +368,35 @@ void MainWindow::_showDockWidget(const QString& name, bool show)
void MainWindow::_createInnerDockWidget(const QString& widgetName)
{
QGCDockWidget* widget = NULL;
if (widgetName == _mavlinkDockWidgetName) {
widget = new QGCMAVLinkInspector(widgetName, _mapName2Action[widgetName], MAVLinkProtocol::instance(),this);
} else if (widgetName == _customCommandWidgetName) {
widget = new CustomCommandWidget(widgetName, _mapName2Action[widgetName], this);
} else if (widgetName == _filesDockWidgetName) {
widget = new QGCUASFileViewMulti(widgetName, _mapName2Action[widgetName], this);
} else if (widgetName == _uasStatusDetailsDockWidgetName) {
widget = new UASInfoWidget(widgetName, _mapName2Action[widgetName], this);
} else if (widgetName == _hilDockWidgetName) {
widget = new HILDockWidget(widgetName, _mapName2Action[widgetName], this);
} else if (widgetName == _analyzeDockWidgetName) {
widget = new Linecharts(widgetName, _mapName2Action[widgetName], mavlinkDecoder, this);
} else if (widgetName == _uasInfoViewDockWidgetName) {
QGCTabbedInfoView* pInfoView = new QGCTabbedInfoView(widgetName, _mapName2Action[widgetName], this);
pInfoView->addSource(mavlinkDecoder);
widget = pInfoView;
} else {
qWarning() << "Attempt to create unknown Inner Dock Widget" << widgetName;
return;
QAction *action = _mapName2Action[widgetName];
switch(action->data().toInt()) {
case MAVLINK_INSPECTOR:
widget = new QGCMAVLinkInspector(widgetName, action, MAVLinkProtocol::instance(),this);
break;
case CUSTOM_COMMAND:
widget = new CustomCommandWidget(widgetName, action, this);
break;
case ONBOARD_FILES:
widget = new QGCUASFileViewMulti(widgetName, action, this);
break;
case STATUS_DETAILS:
widget = new UASInfoWidget(widgetName, action, this);
break;
case HIL_CONFIG:
widget = new HILDockWidget(widgetName, action, this);
break;
case ANALYZE:
widget = new Linecharts(widgetName, action, mavlinkDecoder, this);
break;
case INFO_VIEW:
widget= new QGCTabbedInfoView(widgetName, action, this);
break;
}
if(action->data().toInt() == INFO_VIEW) {
qobject_cast<QGCTabbedInfoView*>(widget)->addSource(mavlinkDecoder);
}
_mapName2DockWidget[widgetName] = widget;
}
......@@ -399,19 +409,23 @@ void MainWindow::_hideAllDockWidgets(void)
void MainWindow::_showDockWidgetAction(bool show)
{
QAction* action = dynamic_cast<QAction*>(QObject::sender());
QAction* action = qobject_cast<QAction*>(QObject::sender());
Q_ASSERT(action);
_showDockWidget(action->text(), show);
_showDockWidget(rgDockWidgetNames[action->data().toInt()], show);
}
#endif