Commit e857ac5c authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4583 from DonLakeFlyer/SettingsGroup

Add new SettingsGroup support
parents 6c7158d3 0c8694e5
......@@ -291,6 +291,7 @@ INCLUDEPATH += \
src/QmlControls \
src/QtLocationPlugin \
src/QtLocationPlugin/QMLControl \
src/Settings \
src/VehicleSetup \
src/ViewWidgets \
src/audio \
......@@ -474,7 +475,12 @@ HEADERS += \
src/QmlControls/RCChannelMonitorController.h \
src/QmlControls/ScreenToolsController.h \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \
src/SettingsManager.h \
src/Settings/AppSettings.h \
src/Settings/AutoConnectSettings.h \
src/Settings/SettingsGroup.h \
src/Settings/SettingsManager.h \
src/Settings/UnitsSettings.h \
src/Settings/VideoSettings.h \
src/Vehicle/MAVLinkLogManager.h \
src/VehicleSetup/JoystickConfigController.h \
src/audio/QGCAudioWorker.h \
......@@ -636,7 +642,12 @@ SOURCES += \
src/QmlControls/RCChannelMonitorController.cc \
src/QmlControls/ScreenToolsController.cc \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \
src/SettingsManager.cc \
src/Settings/AppSettings.cc \
src/Settings/AutoConnectSettings.cc \
src/Settings/SettingsGroup.cc \
src/Settings/SettingsManager.cc \
src/Settings/UnitsSettings.cc \
src/Settings/VideoSettings.cc \
src/Vehicle/MAVLinkLogManager.cc \
src/VehicleSetup/JoystickConfigController.cc \
src/audio/QGCAudioWorker.cpp \
......
......@@ -178,7 +178,10 @@
<file alias="Vehicle/GPSFact.json">src/Vehicle/GPSFact.json</file>
<file alias="Vehicle/WindFact.json">src/Vehicle/WindFact.json</file>
<file alias="Vehicle/VibrationFact.json">src/Vehicle/VibrationFact.json</file>
<file alias="SettingsManager.json">src/SettingsManager.json</file>
<file alias="SettingsGroup.app.json">src/Settings/SettingsGroup.app.json</file>
<file alias="SettingsGroup.autoConnect.json">src/Settings/SettingsGroup.autoConnect.json</file>
<file alias="SettingsGroup.units.json">src/Settings/SettingsGroup.units.json</file>
<file alias="SettingsGroup.video.json">src/Settings/SettingsGroup.video.json</file>
<file alias="RallyPoint.FactMetaData.json">src/MissionManager/RallyPoint.FactMetaData.json</file>
<file alias="FWLandingPattern.FactMetaData.json">src/MissionManager/FWLandingPattern.FactMetaData.json</file>
<file alias="Survey.FactMetaData.json">src/MissionManager/Survey.FactMetaData.json</file>
......
......@@ -40,21 +40,21 @@ const FactMetaData::BuiltInTranslation_s FactMetaData::_rgBuiltInTranslations[]
// Translations driven by app settings
const FactMetaData::AppSettingsTranslation_s FactMetaData::_rgAppSettingsTranslations[] = {
{ "m", "m", false, SettingsManager::DistanceUnitsMeters, FactMetaData::_defaultTranslator, FactMetaData::_defaultTranslator },
{ "meters", "meters", false, SettingsManager::DistanceUnitsMeters, FactMetaData::_defaultTranslator, FactMetaData::_defaultTranslator },
{ "m/s", "m/s", true, SettingsManager::SpeedUnitsMetersPerSecond, FactMetaData::_defaultTranslator, FactMetaData::_defaultTranslator },
{ "m^2", "m^2", false, SettingsManager::AreaUnitsSquareMeters, FactMetaData::_defaultTranslator, FactMetaData::_defaultTranslator },
{ "m", "ft", false, SettingsManager::DistanceUnitsFeet, FactMetaData::_metersToFeet, FactMetaData::_feetToMeters },
{ "meters", "ft", false, SettingsManager::DistanceUnitsFeet, FactMetaData::_metersToFeet, FactMetaData::_feetToMeters },
{ "m^2", "km^2", false, SettingsManager::AreaUnitsSquareKilometers, FactMetaData::_squareMetersToSquareKilometers, FactMetaData::_squareKilometersToSquareMeters },
{ "m^2", "ha", false, SettingsManager::AreaUnitsHectares, FactMetaData::_squareMetersToHectares, FactMetaData::_hectaresToSquareMeters },
{ "m^2", "ft^2", false, SettingsManager::AreaUnitsSquareFeet, FactMetaData::_squareMetersToSquareFeet, FactMetaData::_squareFeetToSquareMeters },
{ "m^2", "ac", false, SettingsManager::AreaUnitsAcres, FactMetaData::_squareMetersToAcres, FactMetaData::_acresToSquareMeters },
{ "m^2", "mi^2", false, SettingsManager::AreaUnitsSquareMiles, FactMetaData::_squareMetersToSquareMiles, FactMetaData::_squareMilesToSquareMeters },
{ "m/s", "ft/s", true, SettingsManager::SpeedUnitsFeetPerSecond, FactMetaData::_metersToFeet, FactMetaData::_feetToMeters },
{ "m/s", "mph", true, SettingsManager::SpeedUnitsMilesPerHour, FactMetaData::_metersPerSecondToMilesPerHour, FactMetaData::_milesPerHourToMetersPerSecond },
{ "m/s", "km/h", true, SettingsManager::SpeedUnitsKilometersPerHour, FactMetaData::_metersPerSecondToKilometersPerHour, FactMetaData::_kilometersPerHourToMetersPerSecond },
{ "m/s", "kn", true, SettingsManager::SpeedUnitsKnots, FactMetaData::_metersPerSecondToKnots, FactMetaData::_knotsToMetersPerSecond },
{ "m", "m", false, UnitsSettings::DistanceUnitsMeters, FactMetaData::_defaultTranslator, FactMetaData::_defaultTranslator },
{ "meters", "meters", false, UnitsSettings::DistanceUnitsMeters, FactMetaData::_defaultTranslator, FactMetaData::_defaultTranslator },
{ "m/s", "m/s", true, UnitsSettings::SpeedUnitsMetersPerSecond, FactMetaData::_defaultTranslator, FactMetaData::_defaultTranslator },
{ "m^2", "m^2", false, UnitsSettings::AreaUnitsSquareMeters, FactMetaData::_defaultTranslator, FactMetaData::_defaultTranslator },
{ "m", "ft", false, UnitsSettings::DistanceUnitsFeet, FactMetaData::_metersToFeet, FactMetaData::_feetToMeters },
{ "meters", "ft", false, UnitsSettings::DistanceUnitsFeet, FactMetaData::_metersToFeet, FactMetaData::_feetToMeters },
{ "m^2", "km^2", false, UnitsSettings::AreaUnitsSquareKilometers, FactMetaData::_squareMetersToSquareKilometers, FactMetaData::_squareKilometersToSquareMeters },
{ "m^2", "ha", false, UnitsSettings::AreaUnitsHectares, FactMetaData::_squareMetersToHectares, FactMetaData::_hectaresToSquareMeters },
{ "m^2", "ft^2", false, UnitsSettings::AreaUnitsSquareFeet, FactMetaData::_squareMetersToSquareFeet, FactMetaData::_squareFeetToSquareMeters },
{ "m^2", "ac", false, UnitsSettings::AreaUnitsAcres, FactMetaData::_squareMetersToAcres, FactMetaData::_acresToSquareMeters },
{ "m^2", "mi^2", false, UnitsSettings::AreaUnitsSquareMiles, FactMetaData::_squareMetersToSquareMiles, FactMetaData::_squareMilesToSquareMeters },
{ "m/s", "ft/s", true, UnitsSettings::SpeedUnitsFeetPerSecond, FactMetaData::_metersToFeet, FactMetaData::_feetToMeters },
{ "m/s", "mph", true, UnitsSettings::SpeedUnitsMilesPerHour, FactMetaData::_metersPerSecondToMilesPerHour, FactMetaData::_milesPerHourToMetersPerSecond },
{ "m/s", "km/h", true, UnitsSettings::SpeedUnitsKilometersPerHour, FactMetaData::_metersPerSecondToKilometersPerHour, FactMetaData::_kilometersPerHourToMetersPerSecond },
{ "m/s", "kn", true, UnitsSettings::SpeedUnitsKnots, FactMetaData::_metersPerSecondToKnots, FactMetaData::_knotsToMetersPerSecond },
};
const char* FactMetaData::_decimalPlacesJsonKey = "decimalPlaces";
......@@ -635,8 +635,8 @@ void FactMetaData::_setAppSettingsTranslators(void)
const AppSettingsTranslation_s* pAppSettingsTranslation = &_rgAppSettingsTranslations[i];
if (pAppSettingsTranslation->rawUnits == _rawUnits.toLower() &&
((pAppSettingsTranslation->speed && pAppSettingsTranslation->speedOrDistanceUnits == qgcApp()->toolbox()->settingsManager()->speedUnits()->rawValue().toUInt()) ||
(!pAppSettingsTranslation->speed && pAppSettingsTranslation->speedOrDistanceUnits == qgcApp()->toolbox()->settingsManager()->distanceUnits()->rawValue().toUInt()))) {
((pAppSettingsTranslation->speed && pAppSettingsTranslation->speedOrDistanceUnits == qgcApp()->toolbox()->settingsManager()->unitsSettings()->speedUnits()->rawValue().toUInt()) ||
(!pAppSettingsTranslation->speed && pAppSettingsTranslation->speedOrDistanceUnits == qgcApp()->toolbox()->settingsManager()->unitsSettings()->distanceUnits()->rawValue().toUInt()))) {
_cookedUnits = pAppSettingsTranslation->cookedUnits;
setTranslators(pAppSettingsTranslation->rawTranslator, pAppSettingsTranslation->cookedTranslator);
return;
......@@ -651,7 +651,7 @@ const FactMetaData::AppSettingsTranslation_s* FactMetaData::_findAppSettingsDist
const AppSettingsTranslation_s* pAppSettingsTranslation = &_rgAppSettingsTranslations[i];
if (pAppSettingsTranslation->rawUnits == rawUnits &&
(!pAppSettingsTranslation->speed && pAppSettingsTranslation->speedOrDistanceUnits == qgcApp()->toolbox()->settingsManager()->distanceUnits()->rawValue().toUInt())) {
(!pAppSettingsTranslation->speed && pAppSettingsTranslation->speedOrDistanceUnits == qgcApp()->toolbox()->settingsManager()->unitsSettings()->distanceUnits()->rawValue().toUInt())) {
return pAppSettingsTranslation;
}
}
......@@ -665,7 +665,7 @@ const FactMetaData::AppSettingsTranslation_s* FactMetaData::_findAppSettingsArea
const AppSettingsTranslation_s* pAppSettingsTranslation = &_rgAppSettingsTranslations[i];
if (pAppSettingsTranslation->rawUnits == rawUnits &&
(!pAppSettingsTranslation->speed && pAppSettingsTranslation->speedOrDistanceUnits == qgcApp()->toolbox()->settingsManager()->areaUnits()->rawValue().toUInt())
(!pAppSettingsTranslation->speed && pAppSettingsTranslation->speedOrDistanceUnits == qgcApp()->toolbox()->settingsManager()->unitsSettings()->areaUnits()->rawValue().toUInt())
) {
return pAppSettingsTranslation;
}
......
......@@ -115,7 +115,7 @@ Item {
var rightCoord = mapControl.toCoordinate(Qt.point(scaleLinePixelLength, scale.y))
var scaleLineMeters = Math.round(leftCoord.distanceTo(rightCoord))
if (QGroundControl.settingsManager.distanceUnits.value == QGroundControl.settingsManager.DistanceUnitsFeet) {
if (QGroundControl.settingsManager.unitsSettings.distanceUnits.value == UnitsSettings.DistanceUnitsFeet) {
calculateFeetRatio(scaleLineMeters, scaleLinePixelLength)
} else {
calculateMetersRatio(scaleLineMeters, scaleLinePixelLength)
......
......@@ -56,7 +56,7 @@ GAudioOutput::~GAudioOutput()
bool GAudioOutput::say(const QString& inText)
{
bool muted = qgcApp()->toolbox()->settingsManager()->audioMuted()->rawValue().toBool();
bool muted = qgcApp()->toolbox()->settingsManager()->appSettings()->audioMuted()->rawValue().toBool();
muted |= qgcApp()->runningUnitTests();
if (!muted && !qgcApp()->runningUnitTests()) {
#if defined __android__
......
......@@ -122,7 +122,7 @@ Rectangle {
Layout.fillWidth: true
}
FactComboBox {
fact: QGroundControl.settingsManager.offlineEditingFirmwareType
fact: QGroundControl.settingsManager.appSettings.offlineEditingFirmwareType
indexModel: false
visible: _showOfflineEditingCombos
Layout.preferredWidth: _fieldWidth
......@@ -146,7 +146,7 @@ Rectangle {
}
FactComboBox {
id: offlineVehicleCombo
fact: QGroundControl.settingsManager.offlineEditingVehicleType
fact: QGroundControl.settingsManager.appSettings.offlineEditingVehicleType
indexModel: false
visible: _showOfflineEditingCombos
Layout.preferredWidth: _fieldWidth
......@@ -170,7 +170,7 @@ Rectangle {
Layout.fillWidth: true
}
FactTextField {
fact: QGroundControl.settingsManager.offlineEditingCruiseSpeed
fact: QGroundControl.settingsManager.appSettings.offlineEditingCruiseSpeed
visible: _showCruiseSpeed
Layout.preferredWidth: _fieldWidth
}
......@@ -182,7 +182,7 @@ Rectangle {
Layout.fillWidth: true
}
FactTextField {
fact: QGroundControl.settingsManager.offlineEditingHoverSpeed
fact: QGroundControl.settingsManager.appSettings.offlineEditingHoverSpeed
visible: _showHoverSpeed
Layout.preferredWidth: _fieldWidth
}
......@@ -196,7 +196,7 @@ Rectangle {
QGCLabel { text: qsTr("Hover speed:"); Layout.fillWidth: true }
FactTextField {
Layout.preferredWidth: _fieldWidth
fact: QGroundControl.settingsManager.offlineEditingHoverSpeed
fact: QGroundControl.settingsManager.appSettings.offlineEditingHoverSpeed
}
}
......
......@@ -253,7 +253,7 @@ void MissionCommandTree::_baseVehicleInfo(Vehicle* vehicle, MAV_AUTOPILOT& baseF
baseVehicleType = _baseVehicleType(vehicle->vehicleType());
} else {
// No Vehicle means offline editing
baseFirmwareType = _baseFirmwareType((MAV_AUTOPILOT)_settingsManager->offlineEditingFirmwareType()->rawValue().toInt());
baseVehicleType = _baseVehicleType((MAV_TYPE)_settingsManager->offlineEditingVehicleType()->rawValue().toInt());
baseFirmwareType = _baseFirmwareType((MAV_AUTOPILOT)_settingsManager->appSettings()->offlineEditingFirmwareType()->rawValue().toInt());
baseVehicleType = _baseVehicleType((MAV_TYPE)_settingsManager->appSettings()->offlineEditingVehicleType()->rawValue().toInt());
}
}
......@@ -437,13 +437,13 @@ bool MissionController::_loadJsonMissionFileV2(Vehicle* vehicle, const QJsonObje
return false;
}
if (json.contains(_jsonVehicleTypeKey) && vehicle->isOfflineEditingVehicle()) {
settingsManager->offlineEditingVehicleType()->setRawValue(json[_jsonVehicleTypeKey].toDouble());
settingsManager->appSettings()->offlineEditingVehicleType()->setRawValue(json[_jsonVehicleTypeKey].toDouble());
}
if (json.contains(_jsonCruiseSpeedKey)) {
settingsManager->offlineEditingCruiseSpeed()->setRawValue(json[_jsonCruiseSpeedKey].toDouble());
settingsManager->appSettings()->offlineEditingCruiseSpeed()->setRawValue(json[_jsonCruiseSpeedKey].toDouble());
}
if (json.contains(_jsonHoverSpeedKey)) {
settingsManager->offlineEditingHoverSpeed()->setRawValue(json[_jsonHoverSpeedKey].toDouble());
settingsManager->appSettings()->offlineEditingHoverSpeed()->setRawValue(json[_jsonHoverSpeedKey].toDouble());
}
SimpleMissionItem* homeItem = new SimpleMissionItem(vehicle, visualItems);
......
......@@ -268,7 +268,7 @@ void RallyPointController::addPoint(QGeoCoordinate point)
if (_points.count()) {
defaultAlt = qobject_cast<RallyPoint*>(_points[_points.count() - 1])->coordinate().altitude();
} else {
defaultAlt = qgcApp()->toolbox()->settingsManager()->defaultMissionItemAltitude()->rawValue().toDouble();
defaultAlt = qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble();
}
point.setAltitude(defaultAlt);
RallyPoint* newPoint = new RallyPoint(point, this);
......
......@@ -530,7 +530,7 @@ void SimpleMissionItem::_syncFrameToAltitudeRelativeToHome(void)
void SimpleMissionItem::setDefaultsForCommand(void)
{
// We set these global defaults first, then if there are param defaults they will get reset
_missionItem.setParam7(qgcApp()->toolbox()->settingsManager()->defaultMissionItemAltitude()->rawValue().toDouble());
_missionItem.setParam7(qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble());
MAV_CMD command = (MAV_CMD)this->command();
const MissionCommandUIInfo* uiInfo = _commandTree->getUIInfo(_vehicle, command);
......
......@@ -141,7 +141,7 @@ void SimpleMissionItemTest::_testDefaultValues(void)
item.missionItem().setCommand(MAV_CMD_NAV_WAYPOINT);
item.missionItem().setFrame(MAV_FRAME_GLOBAL_RELATIVE_ALT);
QCOMPARE(item.missionItem().param7(), qgcApp()->toolbox()->settingsManager()->defaultMissionItemAltitude()->rawValue().toDouble());
QCOMPARE(item.missionItem().param7(), qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble());
}
void SimpleMissionItemTest::_testSignals(void)
......@@ -226,7 +226,7 @@ void SimpleMissionItemTest::_testSignals(void)
// dirtyChanged
// Check that changing to the same coordinate does not signal
simpleMissionItem.setCoordinate(QGeoCoordinate(50.1234567, 60.1234567, qgcApp()->toolbox()->settingsManager()->defaultMissionItemAltitude()->rawValue().toDouble()));
simpleMissionItem.setCoordinate(QGeoCoordinate(50.1234567, 60.1234567, qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble()));
QVERIFY(multiSpy->checkNoSignals());
// Check that actually changing coordinate signals correctly
......
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "AppSettings.h"
#include <QQmlEngine>
#include <QtQml>
const char* AppSettings::appSettingsGroupName = "app";
const char* AppSettings::offlineEditingFirmwareTypeSettingsName = "OfflineEditingFirmwareType";
const char* AppSettings::offlineEditingVehicleTypeSettingsName = "OfflineEditingVehicleType";
const char* AppSettings::offlineEditingCruiseSpeedSettingsName = "OfflineEditingCruiseSpeed";
const char* AppSettings::offlineEditingHoverSpeedSettingsName = "OfflineEditingHoverSpeed";
const char* AppSettings::batteryPercentRemainingAnnounceSettingsName = "batteryPercentRemainingAnnounce";
const char* AppSettings::defaultMissionItemAltitudeSettingsName = "DefaultMissionItemAltitude";
const char* AppSettings::missionAutoLoadDirSettingsName = "MissionAutoLoadDir";
const char* AppSettings::promptFlightTelemetrySaveName = "PromptFLightDataSave";
const char* AppSettings::promptFlightTelemetrySaveNotArmedName = "PromptFLightDataSaveNotArmed";
const char* AppSettings::audioMutedName = "AudioMuted";
AppSettings::AppSettings(QObject* parent)
: SettingsGroup(appSettingsGroupName, QString() /* root settings group */, parent)
, _offlineEditingFirmwareTypeFact(NULL)
, _offlineEditingVehicleTypeFact(NULL)
, _offlineEditingCruiseSpeedFact(NULL)
, _offlineEditingHoverSpeedFact(NULL)
, _batteryPercentRemainingAnnounceFact(NULL)
, _defaultMissionItemAltitudeFact(NULL)
, _missionAutoLoadDirFact(NULL)
, _promptFlightTelemetrySave(NULL)
, _promptFlightTelemetrySaveNotArmed(NULL)
, _audioMuted(NULL)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<AppSettings>("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only");
}
Fact* AppSettings::offlineEditingFirmwareType(void)
{
if (!_offlineEditingFirmwareTypeFact) {
_offlineEditingFirmwareTypeFact = _createSettingsFact(offlineEditingFirmwareTypeSettingsName);
}
return _offlineEditingFirmwareTypeFact;
}
Fact* AppSettings::offlineEditingVehicleType(void)
{
if (!_offlineEditingVehicleTypeFact) {
_offlineEditingVehicleTypeFact = _createSettingsFact(offlineEditingVehicleTypeSettingsName);
}
return _offlineEditingVehicleTypeFact;
}
Fact* AppSettings::offlineEditingCruiseSpeed(void)
{
if (!_offlineEditingCruiseSpeedFact) {
_offlineEditingCruiseSpeedFact = _createSettingsFact(offlineEditingCruiseSpeedSettingsName);
}
return _offlineEditingCruiseSpeedFact;
}
Fact* AppSettings::offlineEditingHoverSpeed(void)
{
if (!_offlineEditingHoverSpeedFact) {
_offlineEditingHoverSpeedFact = _createSettingsFact(offlineEditingHoverSpeedSettingsName);
}
return _offlineEditingHoverSpeedFact;
}
Fact* AppSettings::batteryPercentRemainingAnnounce(void)
{
if (!_batteryPercentRemainingAnnounceFact) {
_batteryPercentRemainingAnnounceFact = _createSettingsFact(batteryPercentRemainingAnnounceSettingsName);
}
return _batteryPercentRemainingAnnounceFact;
}
Fact* AppSettings::defaultMissionItemAltitude(void)
{
if (!_defaultMissionItemAltitudeFact) {
_defaultMissionItemAltitudeFact = _createSettingsFact(defaultMissionItemAltitudeSettingsName);
}
return _defaultMissionItemAltitudeFact;
}
Fact* AppSettings::missionAutoLoadDir(void)
{
if (!_missionAutoLoadDirFact) {
_missionAutoLoadDirFact = _createSettingsFact(missionAutoLoadDirSettingsName);
}
return _missionAutoLoadDirFact;
}
Fact* AppSettings::promptFlightTelemetrySave(void)
{
if (!_promptFlightTelemetrySave) {
_promptFlightTelemetrySave = _createSettingsFact(promptFlightTelemetrySaveName);
}
return _promptFlightTelemetrySave;
}
Fact* AppSettings::promptFlightTelemetrySaveNotArmed(void)
{
if (!_promptFlightTelemetrySaveNotArmed) {
_promptFlightTelemetrySaveNotArmed = _createSettingsFact(promptFlightTelemetrySaveNotArmedName);
}
return _promptFlightTelemetrySaveNotArmed;
}
Fact* AppSettings::audioMuted(void)
{
if (!_audioMuted) {
_audioMuted = _createSettingsFact(audioMutedName);
}
return _audioMuted;
}
......@@ -7,60 +7,22 @@
*
****************************************************************************/
#ifndef AppSettings_H
#define AppSettings_H
#ifndef SettingsManager_H
#define SettingsManager_H
#include "SettingsGroup.h"
#include "QGCLoggingCategory.h"
#include "Joystick.h"
#include "MultiVehicleManager.h"
#include "QGCToolbox.h"
#include <QVariantList>
Q_DECLARE_LOGGING_CATEGORY(SettingsManagerLog)
/// Provides access to all app settings
class SettingsManager : public QGCTool
class AppSettings : public SettingsGroup
{
Q_OBJECT
public:
SettingsManager(QGCApplication* app);
enum DistanceUnits {
DistanceUnitsFeet = 0,
DistanceUnitsMeters
};
enum AreaUnits {
AreaUnitsSquareFeet = 0,
AreaUnitsSquareMeters,
AreaUnitsSquareKilometers,
AreaUnitsHectares,
AreaUnitsAcres,
AreaUnitsSquareMiles,
};
enum SpeedUnits {
SpeedUnitsFeetPerSecond = 0,
SpeedUnitsMetersPerSecond,
SpeedUnitsMilesPerHour,
SpeedUnitsKilometersPerHour,
SpeedUnitsKnots,
};
Q_ENUMS(DistanceUnits)
Q_ENUMS(AreaUnits)
Q_ENUMS(SpeedUnits)
AppSettings(QObject* parent = NULL);
Q_PROPERTY(Fact* offlineEditingFirmwareType READ offlineEditingFirmwareType CONSTANT)
Q_PROPERTY(Fact* offlineEditingVehicleType READ offlineEditingVehicleType CONSTANT)
Q_PROPERTY(Fact* offlineEditingCruiseSpeed READ offlineEditingCruiseSpeed CONSTANT)
Q_PROPERTY(Fact* offlineEditingHoverSpeed READ offlineEditingHoverSpeed CONSTANT)
Q_PROPERTY(Fact* distanceUnits READ distanceUnits CONSTANT)
Q_PROPERTY(Fact* areaUnits READ areaUnits CONSTANT)
Q_PROPERTY(Fact* speedUnits READ speedUnits CONSTANT)
Q_PROPERTY(Fact* batteryPercentRemainingAnnounce READ batteryPercentRemainingAnnounce CONSTANT)
Q_PROPERTY(Fact* defaultMissionItemAltitude READ defaultMissionItemAltitude CONSTANT)
Q_PROPERTY(Fact* missionAutoLoadDir READ missionAutoLoadDir CONSTANT)
......@@ -72,9 +34,6 @@ public:
Fact* offlineEditingVehicleType (void);
Fact* offlineEditingCruiseSpeed (void);
Fact* offlineEditingHoverSpeed (void);
Fact* distanceUnits (void);
Fact* areaUnits (void);
Fact* speedUnits (void);
Fact* batteryPercentRemainingAnnounce (void);
Fact* defaultMissionItemAltitude (void);
Fact* missionAutoLoadDir (void);
......@@ -82,16 +41,12 @@ public:
Fact* promptFlightTelemetrySaveNotArmed (void);
Fact* audioMuted (void);
// Override from QGCTool
virtual void setToolbox(QGCToolbox *toolbox);
static const char* appSettingsGroupName;
static const char* offlineEditingFirmwareTypeSettingsName;
static const char* offlineEditingVehicleTypeSettingsName;
static const char* offlineEditingCruiseSpeedSettingsName;
static const char* offlineEditingHoverSpeedSettingsName;
static const char* distanceUnitsSettingsName;
static const char* areaUnitsSettingsName;
static const char* speedUnitsSettingsName;
static const char* batteryPercentRemainingAnnounceSettingsName;
static const char* defaultMissionItemAltitudeSettingsName;
static const char* missionAutoLoadDirSettingsName;
......@@ -100,17 +55,10 @@ public:
static const char* audioMutedName;
private:
SettingsFact* _createSettingsFact(const QString& name);
QMap<QString, FactMetaData*> _nameToMetaDataMap;
SettingsFact* _offlineEditingFirmwareTypeFact;
SettingsFact* _offlineEditingVehicleTypeFact;
SettingsFact* _offlineEditingCruiseSpeedFact;
SettingsFact* _offlineEditingHoverSpeedFact;
SettingsFact* _distanceUnitsFact;
SettingsFact* _areaUnitsFact;
SettingsFact* _speedUnitsFact;
SettingsFact* _batteryPercentRemainingAnnounceFact;
SettingsFact* _defaultMissionItemAltitudeFact;
SettingsFact* _missionAutoLoadDirFact;
......
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "AutoConnectSettings.h"
#include <QQmlEngine>
#include <QtQml>
const char* AutoConnectSettings::autoConnectSettingsGroupName = "autoConnect";
AutoConnectSettings::AutoConnectSettings(QObject* parent)
: SettingsGroup(autoConnectSettingsGroupName, QString() /* root settings group */, parent)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<AutoConnectSettings>("QGroundControl.SettingsManager", 1, 0, "AutoConnectSettings", "Reference only");
}
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#ifndef AutoConnectSettings_H
#define AutoConnectSettings_H
#include "SettingsGroup.h"
class AutoConnectSettings : public SettingsGroup
{
Q_OBJECT
public:
AutoConnectSettings(QObject* parent = NULL);
static const char* autoConnectSettingsGroupName;
private:
};
#endif
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "SettingsGroup.h"
#include "QGCCorePlugin.h"
#include "QGCApplication.h"
SettingsGroup::SettingsGroup(const QString& name, const QString& settingsGroup, QObject* parent)
: QObject(parent)
, _name(name)
, _settingsGroup(settingsGroup)
, _visible(qgcApp()->toolbox()->corePlugin()->overrideSettingsGroupVisibility(name))
{
QString jsonNameFormat(":/json/SettingsGroup.%1.json");
_nameToMetaDataMap = FactMetaData::createMapFromJsonFile(jsonNameFormat.arg(name), this);
}
SettingsFact* SettingsGroup::_createSettingsFact(const QString& name)
{
return new SettingsFact(_settingsGroup, _nameToMetaDataMap[name], this);
}
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#ifndef SettingsGroup_H
#define SettingsGroup_H
#include "QGCLoggingCategory.h"
#include "Joystick.h"
#include "MultiVehicleManager.h"
#include "QGCToolbox.h"
#include <QVariantList>
/// Provides access to group of settings. The group is named and has a visible property associated with which can control whether the group
/// is shows in the ui.
class SettingsGroup : public QObject
{
Q_OBJECT
public:
/// @param name Name for this Settings group
/// @param settingsGroup Group to place settings in for QSettings::setGroup
SettingsGroup(const QString& name, const QString& settingsGroup, QObject* parent = NULL);
Q_PROPERTY(bool visible MEMBER _visible CONSTANT)
protected:
SettingsFact* _createSettingsFact(const QString& name);
QString _name;
QString _settingsGroup;
bool _visible;
QMap<QString, FactMetaData*> _nameToMetaDataMap;
};
#endif
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "SettingsManager.h"
#include <QQmlEngine>
#include <QtQml>
SettingsManager::SettingsManager(QGCApplication* app)
: QGCTool(app)
, _appSettings(NULL)
, _unitsSettings(NULL)
, _autoConnectSettings(NULL)
, _videoSettings(NULL)
{
}
void SettingsManager::setToolbox(QGCToolbox *toolbox)
{
QGCTool::setToolbox(toolbox);
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<SettingsManager>("QGroundControl.SettingsManager", 1, 0, "SettingsManager", "Reference only");
_unitsSettings = new UnitsSettings(this); // Must be first since AppSettings references it
_appSettings = new AppSettings(this);
_autoConnectSettings = new AutoConnectSettings(this);
_videoSettings = new VideoSettings(this);
}
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#ifndef SettingsManager_H
#define SettingsManager_H
#include "QGCLoggingCategory.h"
#include "Joystick.h"
#include "MultiVehicleManager.h"
#include "QGCToolbox.h"
#include "AppSettings.h"
#include "UnitsSettings.h"
#include "AutoConnectSettings.h"
#include "VideoSettings.h"
#include <QVariantList>
/// Provides access to all app settings
class SettingsManager : public QGCTool
{
Q_OBJECT
public:
SettingsManager(QGCApplication* app);
Q_PROPERTY(QObject* appSettings READ appSettings CONSTANT)
Q_PROPERTY(QObject* unitsSettings READ unitsSettings CONSTANT)
Q_PROPERTY(QObject* autoConnectSettings READ autoConnectSettings CONSTANT)
Q_PROPERTY(QObject* videoSettings READ videoSettings CONSTANT)
// Override from QGCTool
virtual void setToolbox(QGCToolbox *toolbox);
AppSettings* appSettings (void) { return _appSettings; }
UnitsSettings* unitsSettings (void) { return _unitsSettings; }
AutoConnectSettings* autoConnectSettings (void) { return _autoConnectSettings; }
VideoSettings* videoSettings (void) { return _videoSettings; }
private:
AppSettings* _appSettings;
UnitsSettings* _unitsSettings;
AutoConnectSettings* _autoConnectSettings;
VideoSettings* _videoSettings;
};
#endif
......@@ -7,147 +7,27 @@
*
****************************************************************************/
#include "SettingsManager.h"
#include "QGCApplication.h"
QGC_LOGGING_CATEGORY(SettingsManagerLog, "SettingsManagerLog")
const char* SettingsManager::offlineEditingFirmwareTypeSettingsName = "OfflineEditingFirmwareType";
const char* SettingsManager::offlineEditingVehicleTypeSettingsName = "OfflineEditingVehicleType";
const char* SettingsManager::offlineEditingCruiseSpeedSettingsName = "OfflineEditingCruiseSpeed";
const char* SettingsManager::offlineEditingHoverSpeedSettingsName = "OfflineEditingHoverSpeed";
const char* SettingsManager::distanceUnitsSettingsName = "DistanceUnits";
const char* SettingsManager::areaUnitsSettingsName = "AreaUnits";
const char* SettingsManager::speedUnitsSettingsName = "SpeedUnits";
const char* SettingsManager::batteryPercentRemainingAnnounceSettingsName = "batteryPercentRemainingAnnounce";
const char* SettingsManager::defaultMissionItemAltitudeSettingsName = "DefaultMissionItemAltitude";
const char* SettingsManager::missionAutoLoadDirSettingsName = "MissionAutoLoadDir";
const char* SettingsManager::promptFlightTelemetrySaveName = "PromptFLightDataSave";
const char* SettingsManager::promptFlightTelemetrySaveNotArmedName = "PromptFLightDataSaveNotArmed";
const char* SettingsManager::audioMutedName = "AudioMuted";
SettingsManager::SettingsManager(QGCApplication* app)
: QGCTool(app)
, _offlineEditingFirmwareTypeFact(NULL)
, _offlineEditingVehicleTypeFact(NULL)
, _offlineEditingCruiseSpeedFact(NULL)
, _offlineEditingHoverSpeedFact(NULL)
#include "UnitsSettings.h"
#include <QQmlEngine>
#include <QtQml>
const char* UnitsSettings::unitsSettingsGroupName = "units";
const char* UnitsSettings::distanceUnitsSettingsName = "DistanceUnits";
const char* UnitsSettings::areaUnitsSettingsName = "AreaUnits";
const char* UnitsSettings::speedUnitsSettingsName = "SpeedUnits";
UnitsSettings::UnitsSettings(QObject* parent)
: SettingsGroup(unitsSettingsGroupName, QString() /* root settings group */, parent)
, _distanceUnitsFact(NULL)
, _areaUnitsFact(NULL)
, _speedUnitsFact(NULL)
, _batteryPercentRemainingAnnounceFact(NULL)
, _defaultMissionItemAltitudeFact(NULL)
, _missionAutoLoadDirFact(NULL)
, _promptFlightTelemetrySave(NULL)
, _promptFlightTelemetrySaveNotArmed(NULL)
, _audioMuted(NULL)
{
}
void SettingsManager::setToolbox(QGCToolbox *toolbox)
{
QGCTool::setToolbox(toolbox);
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<SettingsManager>("QGroundControl.SettingsManager", 1, 0, "SettingsManager", "Reference only");
_nameToMetaDataMap = FactMetaData::createMapFromJsonFile(":/json/SettingsManager.json", this);
}
SettingsFact* SettingsManager::_createSettingsFact(const QString& name)
{
return new SettingsFact(QString() /* no settings group */, _nameToMetaDataMap[name], this);
}
Fact* SettingsManager::offlineEditingFirmwareType(void)
{
if (!_offlineEditingFirmwareTypeFact) {
_offlineEditingFirmwareTypeFact = _createSettingsFact(offlineEditingFirmwareTypeSettingsName);
}
return _offlineEditingFirmwareTypeFact;
}
Fact* SettingsManager::offlineEditingVehicleType(void)
{
if (!_offlineEditingVehicleTypeFact) {
_offlineEditingVehicleTypeFact = _createSettingsFact(offlineEditingVehicleTypeSettingsName);
}
return _offlineEditingVehicleTypeFact;
}
Fact* SettingsManager::offlineEditingCruiseSpeed(void)
{
if (!_offlineEditingCruiseSpeedFact) {
_offlineEditingCruiseSpeedFact = _createSettingsFact(offlineEditingCruiseSpeedSettingsName);
}
return _offlineEditingCruiseSpeedFact;
}
Fact* SettingsManager::offlineEditingHoverSpeed(void)
{
if (!_offlineEditingHoverSpeedFact) {
_offlineEditingHoverSpeedFact = _createSettingsFact(offlineEditingHoverSpeedSettingsName);
}
return _offlineEditingHoverSpeedFact;
}
Fact* SettingsManager::batteryPercentRemainingAnnounce(void)
{
if (!_batteryPercentRemainingAnnounceFact) {
_batteryPercentRemainingAnnounceFact = _createSettingsFact(batteryPercentRemainingAnnounceSettingsName);
}
return _batteryPercentRemainingAnnounceFact;
}
Fact* SettingsManager::defaultMissionItemAltitude(void)
{
if (!_defaultMissionItemAltitudeFact) {
_defaultMissionItemAltitudeFact = _createSettingsFact(defaultMissionItemAltitudeSettingsName);
}
return _defaultMissionItemAltitudeFact;
}
Fact* SettingsManager::missionAutoLoadDir(void)
{
if (!_missionAutoLoadDirFact) {
_missionAutoLoadDirFact = _createSettingsFact(missionAutoLoadDirSettingsName);
}
return _missionAutoLoadDirFact;
}
Fact* SettingsManager::promptFlightTelemetrySave(void)
{
if (!_promptFlightTelemetrySave) {
_promptFlightTelemetrySave = _createSettingsFact(promptFlightTelemetrySaveName);
}
return _promptFlightTelemetrySave;
}
Fact* SettingsManager::promptFlightTelemetrySaveNotArmed(void)
{
if (!_promptFlightTelemetrySaveNotArmed) {
_promptFlightTelemetrySaveNotArmed = _createSettingsFact(promptFlightTelemetrySaveNotArmedName);
}
return _promptFlightTelemetrySaveNotArmed;
}
Fact* SettingsManager::audioMuted(void)
{
if (!_audioMuted) {
_audioMuted = _createSettingsFact(audioMutedName);
}
return _audioMuted;
qmlRegisterUncreatableType<UnitsSettings>("QGroundControl.SettingsManager", 1, 0, "UnitsSettings", "Reference only");
}
Fact* SettingsManager::distanceUnits(void)
Fact* UnitsSettings::distanceUnits(void)
{
if (!_distanceUnitsFact) {
// Distance/Area/Speed units settings can't be loaded from json since it creates an infinite loop of meta data loading.
......@@ -170,7 +50,7 @@ Fact* SettingsManager::distanceUnits(void)
}
Fact* SettingsManager::areaUnits(void)
Fact* UnitsSettings::areaUnits(void)
{
if (!_areaUnitsFact) {
// Distance/Area/Speed units settings can't be loaded from json since it creates an infinite loop of meta data loading.
......@@ -192,7 +72,7 @@ Fact* SettingsManager::areaUnits(void)
}
Fact* SettingsManager::speedUnits(void)
Fact* UnitsSettings::speedUnits(void)
{
if (!_speedUnitsFact) {
// Distance/Area/Speed units settings can't be loaded from json since it creates an infinite loop of meta data loading.
......
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#ifndef UnitsSettings_H
#define UnitsSettings_H
#include "SettingsGroup.h"
class UnitsSettings : public SettingsGroup
{
Q_OBJECT
public:
UnitsSettings(QObject* parent = NULL);
enum DistanceUnits {
DistanceUnitsFeet = 0,
DistanceUnitsMeters
};
enum AreaUnits {
AreaUnitsSquareFeet = 0,
AreaUnitsSquareMeters,
AreaUnitsSquareKilometers,
AreaUnitsHectares,
AreaUnitsAcres,
AreaUnitsSquareMiles,
};
enum SpeedUnits {
SpeedUnitsFeetPerSecond = 0,
SpeedUnitsMetersPerSecond,
SpeedUnitsMilesPerHour,
SpeedUnitsKilometersPerHour,
SpeedUnitsKnots,
};
Q_ENUMS(DistanceUnits)
Q_ENUMS(AreaUnits)
Q_ENUMS(SpeedUnits)
Q_PROPERTY(Fact* distanceUnits READ distanceUnits CONSTANT)
Q_PROPERTY(Fact* areaUnits READ areaUnits CONSTANT)
Q_PROPERTY(Fact* speedUnits READ speedUnits CONSTANT)
Fact* distanceUnits (void);
Fact* areaUnits (void);
Fact* speedUnits (void);
static const char* unitsSettingsGroupName;
static const char* distanceUnitsSettingsName;
static const char* areaUnitsSettingsName;
static const char* speedUnitsSettingsName;
private:
SettingsFact* _distanceUnitsFact;
SettingsFact* _areaUnitsFact;
SettingsFact* _speedUnitsFact;
};
#endif
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "VideoSettings.h"
#include <QQmlEngine>
#include <QtQml>
const char* VideoSettings::VideoSettingsGroupName = "video";
VideoSettings::VideoSettings(QObject* parent)
: SettingsGroup(VideoSettingsGroupName, QString() /* root settings group */, parent)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<VideoSettings>("QGroundControl.SettingsManager", 1, 0, "VideoSettings", "Reference only");
}
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#ifndef VideoSettings_H
#define VideoSettings_H
#include "SettingsGroup.h"
class VideoSettings : public SettingsGroup
{
Q_OBJECT
public:
VideoSettings(QObject* parent = NULL);
static const char* VideoSettingsGroupName;
private:
};
#endif
......@@ -64,8 +64,8 @@ void MultiVehicleManager::setToolbox(QGCToolbox *toolbox)
connect(_mavlinkProtocol, &MAVLinkProtocol::vehicleHeartbeatInfo, this, &MultiVehicleManager::_vehicleHeartbeatInfo);
SettingsManager* settingsManager = toolbox->settingsManager();
_offlineEditingVehicle = new Vehicle(static_cast<MAV_AUTOPILOT>(settingsManager->offlineEditingFirmwareType()->rawValue().toInt()),
static_cast<MAV_TYPE>(settingsManager->offlineEditingVehicleType()->rawValue().toInt()),
_offlineEditingVehicle = new Vehicle(static_cast<MAV_AUTOPILOT>(settingsManager->appSettings()->offlineEditingFirmwareType()->rawValue().toInt()),
static_cast<MAV_TYPE>(settingsManager->appSettings()->offlineEditingVehicleType()->rawValue().toInt()),
_firmwarePluginManager,
this);
}
......
......@@ -101,8 +101,8 @@ Vehicle::Vehicle(LinkInterface* link,
, _onboardControlSensorsUnhealthy(0)
, _gpsRawIntMessageAvailable(false)
, _globalPositionIntMessageAvailable(false)
, _cruiseSpeed(_settingsManager->offlineEditingCruiseSpeed()->rawValue().toDouble())
, _hoverSpeed(_settingsManager->offlineEditingHoverSpeed()->rawValue().toDouble())
, _cruiseSpeed(_settingsManager->appSettings()->offlineEditingCruiseSpeed()->rawValue().toDouble())
, _hoverSpeed(_settingsManager->appSettings()->offlineEditingHoverSpeed()->rawValue().toDouble())
, _telemetryRRSSI(0)
, _telemetryLRSSI(0)
, _telemetryRXErrors(0)
......@@ -260,8 +260,8 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType,
, _onboardControlSensorsUnhealthy(0)
, _gpsRawIntMessageAvailable(false)
, _globalPositionIntMessageAvailable(false)
, _cruiseSpeed(_settingsManager->offlineEditingCruiseSpeed()->rawValue().toDouble())
, _hoverSpeed(_settingsManager->offlineEditingHoverSpeed()->rawValue().toDouble())
, _cruiseSpeed(_settingsManager->appSettings()->offlineEditingCruiseSpeed()->rawValue().toDouble())
, _hoverSpeed(_settingsManager->appSettings()->offlineEditingHoverSpeed()->rawValue().toDouble())
, _connectionLost(false)
, _connectionLostEnabled(true)
, _missionManager(NULL)
......@@ -323,10 +323,10 @@ void Vehicle::_commonInit(void)
connect(_rallyPointManager, &RallyPointManager::error, this, &Vehicle::_rallyPointManagerError);
// Offline editing vehicle tracks settings changes for offline editing settings
connect(_settingsManager->offlineEditingFirmwareType(), &Fact::rawValueChanged, this, &Vehicle::_offlineFirmwareTypeSettingChanged);
connect(_settingsManager->offlineEditingVehicleType(), &Fact::rawValueChanged, this, &Vehicle::_offlineVehicleTypeSettingChanged);
connect(_settingsManager->offlineEditingCruiseSpeed(), &Fact::rawValueChanged, this, &Vehicle::_offlineCruiseSpeedSettingChanged);
connect(_settingsManager->offlineEditingHoverSpeed(), &Fact::rawValueChanged, this, &Vehicle::_offlineHoverSpeedSettingChanged);
connect(_settingsManager->appSettings()->offlineEditingFirmwareType(), &Fact::rawValueChanged, this, &Vehicle::_offlineFirmwareTypeSettingChanged);
connect(_settingsManager->appSettings()->offlineEditingVehicleType(), &Fact::rawValueChanged, this, &Vehicle::_offlineVehicleTypeSettingChanged);
connect(_settingsManager->appSettings()->offlineEditingCruiseSpeed(), &Fact::rawValueChanged, this, &Vehicle::_offlineCruiseSpeedSettingChanged);
connect(_settingsManager->appSettings()->offlineEditingHoverSpeed(), &Fact::rawValueChanged, this, &Vehicle::_offlineHoverSpeedSettingChanged);
// Build FactGroup object model
......@@ -791,7 +791,7 @@ void Vehicle::_handleSysStatus(mavlink_message_t& message)
}
_batteryFactGroup.percentRemaining()->setRawValue(sysStatus.battery_remaining);
if (sysStatus.battery_remaining > 0 && sysStatus.battery_remaining < _settingsManager->batteryPercentRemainingAnnounce()->rawValue().toInt()) {
if (sysStatus.battery_remaining > 0 && sysStatus.battery_remaining < _settingsManager->appSettings()->batteryPercentRemainingAnnounce()->rawValue().toInt()) {
if (!_lowBatteryAnnounceTimer.isValid() || _lowBatteryAnnounceTimer.elapsed() > _lowBatteryAnnounceRepeatMSecs) {
_lowBatteryAnnounceTimer.restart();
_say(QString("%1 low battery: %2 percent remaining").arg(_vehicleIdSpeech()).arg(sysStatus.battery_remaining));
......@@ -1579,7 +1579,7 @@ void Vehicle::_parametersReady(bool parametersReady)
{
if (parametersReady && !_missionManagerInitialRequestSent) {
_missionManagerInitialRequestSent = true;
QString missionAutoLoadDirPath = _settingsManager->missionAutoLoadDir()->rawValue().toString();
QString missionAutoLoadDirPath = _settingsManager->appSettings()->missionAutoLoadDir()->rawValue().toString();
if (missionAutoLoadDirPath.isEmpty()) {
_missionManager->requestMissionItems();
} else {
......
......@@ -159,3 +159,11 @@ QVariantList& QGCCorePlugin::toolBarIndicators()
}
return _p->toolBarIndicatorList;
}
bool QGCCorePlugin::overrideSettingsGroupVisibility(QString name)
{
Q_UNUSED(name);
// Always show all
return true;
}
......@@ -53,6 +53,11 @@ public:
/// @return An instance of QGCOptions
virtual QGCOptions* options ();
/// 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);
/// Allows the core plugin to override the default value for the specified setting
/// @param name - Setting name
/// @param defaultValue - Standard default value for setting
......
......@@ -424,7 +424,7 @@ void MAVLinkProtocol::_stopLogging(void)
if (_closeLogFile()) {
// If the signals are not connected it means we are running a unit test. In that case just delete log files
SettingsManager* settingsManager = _app->toolbox()->settingsManager();
if ((_vehicleWasArmed || settingsManager->promptFlightTelemetrySaveNotArmed()->rawValue().toBool()) && settingsManager->promptFlightTelemetrySave()->rawValue().toBool()) {
if ((_vehicleWasArmed || settingsManager->appSettings()->promptFlightTelemetrySaveNotArmed()->rawValue().toBool()) && settingsManager->appSettings()->promptFlightTelemetrySave()->rawValue().toBool()) {
emit saveTempFlightDataLog(_tempLogFile.fileName());
} else {
QFile::remove(_tempLogFile.fileName());
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment