From 6c4ff9c8623e214cddf2a2ad5d469fa3161733b4 Mon Sep 17 00:00:00 2001 From: davidsastresas Date: Sun, 21 May 2023 20:25:47 +0200 Subject: [PATCH] APM support forwarding: Add toolbar indicator just to APMFirmwarePlugin --- qgroundcontrol.qrc | 1 + src/FirmwarePlugin/APM/APMFirmwarePlugin.cc | 11 ++++ src/FirmwarePlugin/APM/APMFirmwarePlugin.h | 2 + src/ui/toolbar/APMSupportForwardingIndicator.qml | 75 ++++++++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 src/ui/toolbar/APMSupportForwardingIndicator.qml diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 6345e54..f07d6a3 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -18,6 +18,7 @@ src/ui/toolbar/ROIIndicator.qml src/ui/toolbar/TelemetryRSSIIndicator.qml src/ui/toolbar/VTOLModeIndicator.qml + src/ui/toolbar/APMSupportForwardingIndicator.qml src/FlightDisplay/DefaultChecklist.qml diff --git a/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc b/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc index cbc0160..d404c70 100644 --- a/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc +++ b/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc @@ -639,6 +639,17 @@ bool APMFirmwarePlugin::hasGripper(const Vehicle* vehicle) const return false; } +const QVariantList& APMFirmwarePlugin::toolIndicators(const Vehicle* vehicle) +{ + if (_toolIndicatorList.size() == 0) { + // First call the base class to get the standard QGC list + _toolIndicatorList = FirmwarePlugin::toolIndicators(vehicle); + // Then add the forwarding support indicator + _toolIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/APMSupportForwardingIndicator.qml"))); + } + return _toolIndicatorList; +} + bool APMFirmwarePlugin::isGuidedMode(const Vehicle* vehicle) const { return vehicle->flightMode() == "Guided"; diff --git a/src/FirmwarePlugin/APM/APMFirmwarePlugin.h b/src/FirmwarePlugin/APM/APMFirmwarePlugin.h index 89a3dbf..f4587f9 100644 --- a/src/FirmwarePlugin/APM/APMFirmwarePlugin.h +++ b/src/FirmwarePlugin/APM/APMFirmwarePlugin.h @@ -79,6 +79,7 @@ public: QString brandImageOutdoor (const Vehicle* vehicle) const override { Q_UNUSED(vehicle); return QStringLiteral("/qmlimages/APM/BrandImage"); } QString getHobbsMeter (Vehicle* vehicle) override; bool hasGripper (const Vehicle* vehicle) const override; + const QVariantList& toolIndicators (const Vehicle* vehicle) override; protected: /// All access to singleton is through stack specific implementation @@ -110,6 +111,7 @@ private: // Any instance data here must be global to all vehicles // Vehicle specific data should go into APMFirmwarePluginInstanceData + QVariantList _toolIndicatorList; QList _supportedModes; QMap> _ardupilotComponentMap; diff --git a/src/ui/toolbar/APMSupportForwardingIndicator.qml b/src/ui/toolbar/APMSupportForwardingIndicator.qml new file mode 100644 index 0000000..91e1a4a --- /dev/null +++ b/src/ui/toolbar/APMSupportForwardingIndicator.qml @@ -0,0 +1,75 @@ +/**************************************************************************** + * + * (c) 2009-2023 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.11 +import QtQuick.Layouts 1.11 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 + +//------------------------------------------------------------------------- +//-- Telemetry RSSI +Item { + id: _root + anchors.top: parent.top + anchors.bottom: parent.bottom + width: forwardingSupportIcon.width * 1.1 + + property bool showIndicator: QGroundControl.linkManager.mavlinkSupportForwardingEnabled + + Component { + id: forwardingSupportInfo + + Rectangle { + width: telemGrid.width + ScreenTools.defaultFontPixelWidth * 3 + height: telemGrid.height + ScreenTools.defaultFontPixelHeight * 2 + radius: ScreenTools.defaultFontPixelHeight * 0.5 + color: qgcPal.window + + GridLayout { + id: telemGrid + anchors.margins: ScreenTools.defaultFontPixelHeight + columnSpacing: ScreenTools.defaultFontPixelWidth + columns: 2 + anchors.centerIn: parent + + QGCLabel { + Layout.columnSpan: 2 + text: qsTr("Mavlink traffic is being forwarded to a support server") + } + + QGCLabel { + text: qsTr("Server name:") + } + QGCLabel { + text: QGroundControl.settingsManager.appSettings.forwardMavlinkAPMSupportHostName.value + } + } + } + } + + Image { + id: forwardingSupportIcon + anchors.top: parent.top + anchors.bottom: parent.bottom + width: height + sourceSize.height: height + source: "/qmlimages/ForwardingSupportIconGreen.svg" + fillMode: Image.PreserveAspectFit + } + + MouseArea { + anchors.fill: parent + onClicked: { + mainWindow.showIndicatorPopup(_root, forwardingSupportInfo) + } + } +}