From 2666ec405cd2c0f16ac24f6b9bf882873f165542 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Fri, 3 Mar 2017 17:05:26 -0500 Subject: [PATCH] Moved toolbar indicator list from QGCCorePlugin to FirmwarePlugin. --- src/FirmwarePlugin/APM/APMFirmwarePlugin.h | 6 +++--- src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc | 14 ++++++++++++++ src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h | 1 + src/FirmwarePlugin/FirmwarePlugin.cc | 15 +++++++++++++++ src/FirmwarePlugin/FirmwarePlugin.h | 9 +++++++++ src/Vehicle/Vehicle.cc | 9 +++++++++ src/Vehicle/Vehicle.h | 3 +++ src/api/QGCCorePlugin.cc | 16 +--------------- src/api/QGCCorePlugin.h | 5 ----- src/ui/toolbar/MainToolBarIndicators.qml | 2 +- 10 files changed, 56 insertions(+), 24 deletions(-) diff --git a/src/FirmwarePlugin/APM/APMFirmwarePlugin.h b/src/FirmwarePlugin/APM/APMFirmwarePlugin.h index 6ea8bc4d2..faf3c0b76 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 5b0dd15a0..61c8acc54 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 d44bacf43..f8ca03ba8 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 5df28367d..7271ede19 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 d9aa61803..175a6c235 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 adf4ace24..fdfae329a 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 4c6c16dcb..bd4e01db9 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 3d7ff1098..f547ede2a 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 e9f1a0a9f..2f5d3926f 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 1a8c1e389..e212bc76a 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 -- 2.22.0