From 377508a9a4cbd27ef07c473237550f0d1133d4a4 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Sat, 6 May 2017 14:59:50 -0700 Subject: [PATCH] Core plugin can override Value Widgets default settings Also added Vehicle.flightTime to default setup --- src/FlightMap/Widgets/ValuesWidgetController.cc | 9 ++++++--- src/api/QGCCorePlugin.cc | 6 ++++++ src/api/QGCCorePlugin.h | 13 ++++++++----- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/FlightMap/Widgets/ValuesWidgetController.cc b/src/FlightMap/Widgets/ValuesWidgetController.cc index 17d0cab29..15a4927b4 100644 --- a/src/FlightMap/Widgets/ValuesWidgetController.cc +++ b/src/FlightMap/Widgets/ValuesWidgetController.cc @@ -9,6 +9,8 @@ #include "ValuesWidgetController.h" +#include "QGCApplication.h" +#include "QGCCorePlugin.h" #include @@ -19,13 +21,14 @@ const char* ValuesWidgetController::_smallValuesKey = "small"; ValuesWidgetController::ValuesWidgetController(void) { QSettings settings; - QStringList largeDefaults; settings.beginGroup(_groupKey); - largeDefaults << "Vehicle.altitudeRelative" << "Vehicle.groundSpeed"; + QStringList largeDefaults, smallDefaults; + qgcApp()->toolbox()->corePlugin()->valuesWidgetDefaultSettings(largeDefaults, smallDefaults); + _largeValues = settings.value(_largeValuesKey, largeDefaults).toStringList(); - _smallValues = settings.value(_smallValuesKey, QStringList()).toStringList(); + _smallValues = settings.value(_smallValuesKey, smallDefaults).toStringList(); _altitudeProperties << "altitudeRelative" << "altitudeAMSL"; diff --git a/src/api/QGCCorePlugin.cc b/src/api/QGCCorePlugin.cc index b6b8d16ee..909fa3f9b 100644 --- a/src/api/QGCCorePlugin.cc +++ b/src/api/QGCCorePlugin.cc @@ -198,3 +198,9 @@ QString QGCCorePlugin::showAdvancedUIMessage(void) const "You should do so only if instructed by customer support. " "Are you sure you want to enable Advanced Mode?"); } + +void QGCCorePlugin::valuesWidgetDefaultSettings(QStringList& largeValues, QStringList& smallValues) +{ + Q_UNUSED(smallValues); + largeValues << "Vehicle.altitudeRelative" << "Vehicle.groundSpeed" << "Vehicle.flightTime"; +} diff --git a/src/api/QGCCorePlugin.h b/src/api/QGCCorePlugin.h index a1f6df028..222552d00 100644 --- a/src/api/QGCCorePlugin.h +++ b/src/api/QGCCorePlugin.h @@ -48,25 +48,25 @@ public: /// The list of settings under the Settings Menu /// @return A list of QGCSettings - virtual QVariantList& settingsPages (); + virtual QVariantList& settingsPages(void); /// The default settings panel to show /// @return The settings index - virtual int defaultSettings (); + virtual int defaultSettings(void); /// Global options /// @return An instance of QGCOptions - virtual QGCOptions* options (); + virtual QGCOptions* options(void); /// Allows the core plugin to override the visibility for a settings group /// @param name - Setting group name /// @return true: Show settings ui, false: Hide settings ui - virtual bool overrideSettingsGroupVisibility (QString name); + virtual bool overrideSettingsGroupVisibility(QString name); /// Allows the core plugin to override the setting meta data before the setting fact is created. /// @param metaData - MetaData for setting fact /// @return true: Setting should be visible in ui, false: Setting should not be shown in ui - virtual bool adjustSettingMetaData (FactMetaData& metaData); + virtual bool adjustSettingMetaData(FactMetaData& metaData); /// Return the resource file which contains the brand image for for Indoor theme. virtual QString brandImageIndoor(void) const { return QString(); } @@ -83,6 +83,9 @@ public: /// Allows a plugin to override the specified color name from the palette virtual void paletteOverride(QString colorName, QGCPalette::PaletteColorInfo_t& colorInfo); + /// Allows the plugin the override the default settings for the Values Widget large and small values + virtual void valuesWidgetDefaultSettings(QStringList& largeValues, QStringList& smallValues); + bool showTouchAreas(void) const { return _showTouchAreas; } bool showAdvancedUI(void) const { return _showAdvancedUI; } void setShowTouchAreas(bool show); -- 2.22.0