diff --git a/src/FirmwarePlugin/APM/APMFirmwarePlugin.h b/src/FirmwarePlugin/APM/APMFirmwarePlugin.h index 6ea8bc4d21c3c53ca1394c6cf66b402a1a99ef2e..faf3c0b76f315364e7af4055847ec8b24e5381cb 100644 --- a/src/FirmwarePlugin/APM/APMFirmwarePlugin.h +++ b/src/FirmwarePlugin/APM/APMFirmwarePlugin.h @@ -104,7 +104,7 @@ protected: APMFirmwarePlugin(void); void setSupportedModes(QList supportedModes); - bool _coaxialMotors; + bool _coaxialMotors; private slots: void _artooSocketError(QAbstractSocket::SocketError socketError); @@ -125,8 +125,8 @@ private: QList _supportedModes; QMap _noisyPrearmMap; - static const char* _artooIP; - static const int _artooVideoHandshakePort; + static const char* _artooIP; + static const int _artooVideoHandshakePort; }; diff --git a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc index 5b0dd15a049a20feae7cdb1c16f1e73f506e0365..61c8acc540485db473cbc37341b76e43776a756b 100644 --- a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc +++ b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc @@ -106,3 +106,17 @@ bool ArduSubFirmwarePlugin::supportsMotorInterference(void) { return false; } + +QVariantList& ArduSubFirmwarePlugin::toolBarIndicators(const Vehicle* vehicle) +{ + Q_UNUSED(vehicle); + //-- Sub specific list of indicators (Enter your modified list here) + if(_toolBarIndicatorList.size() == 0) { + _toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/MessageIndicator.qml"))); + _toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/TelemetryRSSIIndicator.qml"))); + _toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/RCRSSIIndicator.qml"))); + _toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/BatteryIndicator.qml"))); + _toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/ModeIndicator.qml"))); + } + return _toolBarIndicatorList; +} diff --git a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h index d44bacf43f5bb019047b6714d1e36b9acc7cdb3b..f8ca03ba8278e19eda260edd7d6cd17d5ce950aa 100644 --- a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h +++ b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h @@ -86,6 +86,7 @@ public: QString brandImage(const Vehicle* vehicle) const { Q_UNUSED(vehicle); return QStringLiteral("/qmlimages/APM/BrandImageSub"); } const FirmwarePlugin::remapParamNameMajorVersionMap_t& paramNameRemapMajorVersionMap(void) const final { return _remapParamName; } int remapParamNameHigestMinorVersionNumber(int majorVersionNumber) const final; + QVariantList& toolBarIndicators(const Vehicle* vehicle) final; private: static bool _remapParamNameIntialized; diff --git a/src/FirmwarePlugin/FirmwarePlugin.cc b/src/FirmwarePlugin/FirmwarePlugin.cc index 5df28367dd5ac895caf761ce4dbd157ee6939649..7271ede1911f8a39e2ba79c1f63849b75830fc7b 100644 --- a/src/FirmwarePlugin/FirmwarePlugin.cc +++ b/src/FirmwarePlugin/FirmwarePlugin.cc @@ -337,3 +337,18 @@ QString FirmwarePlugin::vehicleImageCompass(const Vehicle* vehicle) const Q_UNUSED(vehicle); return QStringLiteral("/qmlimages/compassInstrumentArrow.svg"); } + +QVariantList& FirmwarePlugin::toolBarIndicators(const Vehicle* vehicle) +{ + Q_UNUSED(vehicle); + //-- Default list of indicators for all vehicles. + if(_toolBarIndicatorList.size() == 0) { + _toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/MessageIndicator.qml"))); + _toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/GPSIndicator.qml"))); + _toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/TelemetryRSSIIndicator.qml"))); + _toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/RCRSSIIndicator.qml"))); + _toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/BatteryIndicator.qml"))); + _toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/ModeIndicator.qml"))); + } + return _toolBarIndicatorList; +} diff --git a/src/FirmwarePlugin/FirmwarePlugin.h b/src/FirmwarePlugin/FirmwarePlugin.h index d9aa618034cfdaf461119d0f4be3d552b630b5b3..175a6c2358cdb0e35860e69be1c1c1bbb1cefbdc 100644 --- a/src/FirmwarePlugin/FirmwarePlugin.h +++ b/src/FirmwarePlugin/FirmwarePlugin.h @@ -22,6 +22,7 @@ #include #include +#include class Vehicle; @@ -256,8 +257,16 @@ public: /// Return the resource file which contains the vehicle icon used in the compass virtual QString vehicleImageCompass(const Vehicle* vehicle) const; + /// Allows the core plugin to override the toolbar indicators + /// @return A list of QUrl with the indicators (see MainToolBarIndicators.qml) + virtual QVariantList& toolBarIndicators(const Vehicle* vehicle); + // FIXME: Hack workaround for non pluginize FollowMe support static const char* px4FollowMeFlightMode; + +protected: + QVariantList _toolBarIndicatorList; + }; class FirmwarePluginFactory : public QObject diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index adf4ace24f9bb2c4c9fc61e16386e3603ac41b53..fdfae329ad930552e44ac7ee6f9a914a1e39b50d 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -2375,6 +2375,15 @@ QString Vehicle::vehicleImageCompass() const return QString(); } +QVariantList& Vehicle::toolBarIndicators() +{ + if(_firmwarePlugin) { + return _firmwarePlugin->toolBarIndicators(this); + } + static QVariantList emptyList; + return emptyList; +} + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 4c6c16dcbb567333ad370df0edeebf8b353b9599..bd4e01db96650bac92e557bda1f5452b1139984d 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -307,6 +307,7 @@ public: Q_PROPERTY(unsigned int telemetryTXBuffer READ telemetryTXBuffer NOTIFY telemetryTXBufferChanged) Q_PROPERTY(unsigned int telemetryLNoise READ telemetryLNoise NOTIFY telemetryLNoiseChanged) Q_PROPERTY(unsigned int telemetryRNoise READ telemetryRNoise NOTIFY telemetryRNoiseChanged) + Q_PROPERTY(QVariantList toolBarIndicators READ toolBarIndicators CONSTANT) /// true: Vehicle is flying, false: Vehicle is on ground Q_PROPERTY(bool flying READ flying WRITE setFlying NOTIFY flyingChanged) @@ -651,6 +652,8 @@ public: QString vehicleImageOutline () const; QString vehicleImageCompass () const; + QVariantList& toolBarIndicators(); + public slots: /// Sets the firmware plugin instance data associated with this Vehicle. This object will be parented to the Vehicle /// and destroyed when the vehicle goes away. diff --git a/src/api/QGCCorePlugin.cc b/src/api/QGCCorePlugin.cc index 3d7ff10987e9f15c999900734be5f8fa4329515f..f547ede2a7b68abfbb6fad7b5a29bd1a7a55e6a3 100644 --- a/src/api/QGCCorePlugin.cc +++ b/src/api/QGCCorePlugin.cc @@ -67,7 +67,6 @@ public: QGCSettings* pDebug; #endif QVariantList settingsList; - QVariantList toolBarIndicatorList; QGCOptions* defaultOptions; }; @@ -142,23 +141,10 @@ QGCOptions* QGCCorePlugin::options() return _p->defaultOptions; } -QVariantList& QGCCorePlugin::toolBarIndicators() -{ - if(_p->toolBarIndicatorList.size() == 0) { - _p->toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/MessageIndicator.qml"))); - _p->toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/GPSIndicator.qml"))); - _p->toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/TelemetryRSSIIndicator.qml"))); - _p->toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/RCRSSIIndicator.qml"))); - _p->toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/BatteryIndicator.qml"))); - _p->toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/ModeIndicator.qml"))); - } - return _p->toolBarIndicatorList; -} - bool QGCCorePlugin::overrideSettingsGroupVisibility(QString name) { Q_UNUSED(name); - + // Always show all return true; } diff --git a/src/api/QGCCorePlugin.h b/src/api/QGCCorePlugin.h index e9f1a0a9f3cd82e2c8fedcd9a5b36616c4c5c18e..2f5d3926fa903af69e58e20eb5a19fdb9748df7e 100644 --- a/src/api/QGCCorePlugin.h +++ b/src/api/QGCCorePlugin.h @@ -36,16 +36,11 @@ public: Q_PROPERTY(QVariantList settings READ settings CONSTANT) Q_PROPERTY(int defaultSettings READ defaultSettings CONSTANT) Q_PROPERTY(QGCOptions* options READ options CONSTANT) - Q_PROPERTY(QVariantList toolBarIndicators READ toolBarIndicators CONSTANT) /// The list of settings under the Settings Menu /// @return A list of QGCSettings virtual QVariantList& settings (); - /// Allows the core plugin to override the toolbar indicators - /// @return A list of QUrl with the indicators (see MainToolBarIndicators.qml) - virtual QVariantList& toolBarIndicators (); - /// The default settings panel to show /// @return The settings index virtual int defaultSettings (); diff --git a/src/ui/toolbar/MainToolBarIndicators.qml b/src/ui/toolbar/MainToolBarIndicators.qml index 1a8c1e38921ef5964c4036bbf85436c76ee68cad..e212bc76abd1eafac07a0eea3ccf003e145b8e29 100644 --- a/src/ui/toolbar/MainToolBarIndicators.qml +++ b/src/ui/toolbar/MainToolBarIndicators.qml @@ -31,7 +31,7 @@ Item { spacing: ScreenTools.defaultFontPixelWidth * 1.5 visible: !communicationLost Repeater { - model: QGroundControl.corePlugin.toolBarIndicators + model: activeVehicle ? activeVehicle.toolBarIndicators : [] Loader { anchors.top: parent.top anchors.bottom: parent.bottom