Commit b754891c authored by dogmaphobic's avatar dogmaphobic

Merge remote-tracking branch 'MavLink/master' into esp8266Component

* MavLink/master:
  New initial map position handling
  Default map position support
  Bad english, plus unit test check
  Add Reboot Required fact meta data
parents 6e12a7e8 f9874376
...@@ -482,3 +482,13 @@ QString Fact::validate(const QString& cookedValue, bool convertOnly) ...@@ -482,3 +482,13 @@ QString Fact::validate(const QString& cookedValue, bool convertOnly)
return QString("Internal error: Meta data pointer missing"); return QString("Internal error: Meta data pointer missing");
} }
} }
bool Fact::rebootRequired(void) const
{
if (_metaData) {
return _metaData->rebootRequired();
} else {
qWarning() << "Meta data pointer missing";
return false;
}
}
...@@ -66,6 +66,7 @@ public: ...@@ -66,6 +66,7 @@ public:
Q_PROPERTY(QString minString READ cookedMinString CONSTANT) Q_PROPERTY(QString minString READ cookedMinString CONSTANT)
Q_PROPERTY(bool minIsDefaultForType READ minIsDefaultForType CONSTANT) Q_PROPERTY(bool minIsDefaultForType READ minIsDefaultForType CONSTANT)
Q_PROPERTY(QString name READ name CONSTANT) Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(bool rebootRequired READ rebootRequired CONSTANT)
Q_PROPERTY(QString shortDescription READ shortDescription CONSTANT) Q_PROPERTY(QString shortDescription READ shortDescription CONSTANT)
Q_PROPERTY(FactMetaData::ValueType_t type READ type CONSTANT) Q_PROPERTY(FactMetaData::ValueType_t type READ type CONSTANT)
Q_PROPERTY(QString units READ cookedUnits CONSTANT) Q_PROPERTY(QString units READ cookedUnits CONSTANT)
...@@ -109,6 +110,7 @@ public: ...@@ -109,6 +110,7 @@ public:
QString rawValueString (void) const; QString rawValueString (void) const;
QString cookedValueString (void) const; QString cookedValueString (void) const;
bool valueEqualsDefault (void) const; bool valueEqualsDefault (void) const;
bool rebootRequired (void) const;
void setRawValue (const QVariant& value); void setRawValue (const QVariant& value);
void setCookedValue (const QVariant& value); void setCookedValue (const QVariant& value);
......
...@@ -51,6 +51,7 @@ FactMetaData::FactMetaData(QObject* parent) ...@@ -51,6 +51,7 @@ FactMetaData::FactMetaData(QObject* parent)
, _minIsDefaultForType(true) , _minIsDefaultForType(true)
, _rawTranslator(_defaultTranslator) , _rawTranslator(_defaultTranslator)
, _cookedTranslator(_defaultTranslator) , _cookedTranslator(_defaultTranslator)
, _rebootRequired(false)
{ {
} }
...@@ -68,6 +69,7 @@ FactMetaData::FactMetaData(ValueType_t type, QObject* parent) ...@@ -68,6 +69,7 @@ FactMetaData::FactMetaData(ValueType_t type, QObject* parent)
, _minIsDefaultForType(true) , _minIsDefaultForType(true)
, _rawTranslator(_defaultTranslator) , _rawTranslator(_defaultTranslator)
, _cookedTranslator(_defaultTranslator) , _cookedTranslator(_defaultTranslator)
, _rebootRequired(false)
{ {
} }
...@@ -100,6 +102,7 @@ const FactMetaData& FactMetaData::operator=(const FactMetaData& other) ...@@ -100,6 +102,7 @@ const FactMetaData& FactMetaData::operator=(const FactMetaData& other)
_cookedUnits = other._cookedUnits; _cookedUnits = other._cookedUnits;
_rawTranslator = other._rawTranslator; _rawTranslator = other._rawTranslator;
_cookedTranslator = other._cookedTranslator; _cookedTranslator = other._cookedTranslator;
_rebootRequired = other._rebootRequired;
return *this; return *this;
} }
......
...@@ -81,6 +81,7 @@ public: ...@@ -81,6 +81,7 @@ public:
ValueType_t type (void) const { return _type; } ValueType_t type (void) const { return _type; }
QString rawUnits (void) const { return _rawUnits; } QString rawUnits (void) const { return _rawUnits; }
QString cookedUnits (void) const { return _cookedUnits; } QString cookedUnits (void) const { return _cookedUnits; }
bool rebootRequired (void) const { return _rebootRequired; }
Translator rawTranslator (void) const { return _rawTranslator; } Translator rawTranslator (void) const { return _rawTranslator; }
Translator cookedTranslator (void) const { return _cookedTranslator; } Translator cookedTranslator (void) const { return _cookedTranslator; }
...@@ -102,6 +103,7 @@ public: ...@@ -102,6 +103,7 @@ public:
void setName (const QString& name) { _name = name; } void setName (const QString& name) { _name = name; }
void setShortDescription(const QString& shortDescription) { _shortDescription = shortDescription; } void setShortDescription(const QString& shortDescription) { _shortDescription = shortDescription; }
void setRawUnits (const QString& rawUnits); void setRawUnits (const QString& rawUnits);
void setRebootRequired (bool rebootRequired) { _rebootRequired = rebootRequired; }
void setTranslators(Translator rawTranslator, Translator cookedTranslator); void setTranslators(Translator rawTranslator, Translator cookedTranslator);
...@@ -150,6 +152,7 @@ private: ...@@ -150,6 +152,7 @@ private:
QString _cookedUnits; QString _cookedUnits;
Translator _rawTranslator; Translator _rawTranslator;
Translator _cookedTranslator; Translator _cookedTranslator;
bool _rebootRequired;
struct BuiltInTranslation_s { struct BuiltInTranslation_s {
const char* rawUnits; const char* rawUnits;
......
...@@ -295,6 +295,10 @@ void ParameterLoader::_valueUpdated(const QVariant& value) ...@@ -295,6 +295,10 @@ void ParameterLoader::_valueUpdated(const QVariant& value)
_writeParameterRaw(componentId, fact->name(), value); _writeParameterRaw(componentId, fact->name(), value);
qCDebug(ParameterLoaderLog) << "Set parameter (componentId:" << componentId << "name:" << name << value << ")"; qCDebug(ParameterLoaderLog) << "Set parameter (componentId:" << componentId << "name:" << name << value << ")";
if (fact->rebootRequired() && !qgcApp()->runningUnitTests()) {
qgcApp()->showMessage(QStringLiteral("Change of parameter %1 requires a Vehicle reboot to take effect").arg(name));
}
} }
void ParameterLoader::refreshAllParameters(uint8_t componentID) void ParameterLoader::refreshAllParameters(uint8_t componentID)
......
...@@ -342,6 +342,7 @@ bool APMParameterMetaData::parseParameterAttributes(QXmlStreamReader& xml, APMFa ...@@ -342,6 +342,7 @@ bool APMParameterMetaData::parseParameterAttributes(QXmlStreamReader& xml, APMFa
// skip empty elements. Somehow I am getting lot of these. Dont know what to do with them. // skip empty elements. Somehow I am getting lot of these. Dont know what to do with them.
} else if (elementName == "field") { } else if (elementName == "field") {
QString attributeName = xml.attributes().value("name").toString(); QString attributeName = xml.attributes().value("name").toString();
if ( attributeName == "Range") { if ( attributeName == "Range") {
QString range = xml.readElementText().trimmed(); QString range = xml.readElementText().trimmed();
QStringList rangeList = range.split(' '); QStringList rangeList = range.split(' ');
...@@ -402,6 +403,11 @@ bool APMParameterMetaData::parseParameterAttributes(QXmlStreamReader& xml, APMFa ...@@ -402,6 +403,11 @@ bool APMParameterMetaData::parseParameterAttributes(QXmlStreamReader& xml, APMFa
if (parseError) { if (parseError) {
rawMetaData->bitmask.clear(); rawMetaData->bitmask.clear();
} }
} else if (attributeName == "RebootRequired") {
QString strValue = xml.readElementText().trimmed();
if (strValue.compare("true", Qt::CaseInsensitive) == 0) {
rawMetaData->rebootRequired = true;
}
} }
} else if (elementName == "values") { } else if (elementName == "values") {
// doing nothing individual value will follow anyway. May be used for sanity checking. // doing nothing individual value will follow anyway. May be used for sanity checking.
...@@ -447,6 +453,7 @@ void APMParameterMetaData::addMetaDataToFact(Fact* fact, MAV_TYPE vehicleType) ...@@ -447,6 +453,7 @@ void APMParameterMetaData::addMetaDataToFact(Fact* fact, MAV_TYPE vehicleType)
metaData->setName(rawMetaData->name); metaData->setName(rawMetaData->name);
metaData->setGroup(rawMetaData->group); metaData->setGroup(rawMetaData->group);
metaData->setRebootRequired(rawMetaData->rebootRequired);
if (!rawMetaData->shortDescription.isEmpty()) { if (!rawMetaData->shortDescription.isEmpty()) {
metaData->setShortDescription(rawMetaData->shortDescription); metaData->setShortDescription(rawMetaData->shortDescription);
......
...@@ -37,14 +37,19 @@ ...@@ -37,14 +37,19 @@
class APMFactMetaDataRaw class APMFactMetaDataRaw
{ {
public: public:
QString name; APMFactMetaDataRaw(void)
QString group; : rebootRequired(false)
QString shortDescription; { }
QString longDescription;
QString min; QString name;
QString max; QString group;
QString incrementSize; QString shortDescription;
QString units; QString longDescription;
QString min;
QString max;
QString incrementSize;
QString units;
bool rebootRequired;
QList<QPair<QString, QString> > values; QList<QPair<QString, QString> > values;
QList<QPair<QString, QString> > bitmask; QList<QPair<QString, QString> > bitmask;
}; };
......
...@@ -312,6 +312,14 @@ void PX4ParameterMetaData::_loadParameterFactMetaData(void) ...@@ -312,6 +312,14 @@ void PX4ParameterMetaData::_loadParameterFactMetaData(void)
qCWarning(PX4ParameterMetaDataLog) << "Invalid decimals value, name:" << metaData->name() << " type:" << metaData->type() << " decimals:" << text << " error: invalid number"; qCWarning(PX4ParameterMetaDataLog) << "Invalid decimals value, name:" << metaData->name() << " type:" << metaData->type() << " decimals:" << text << " error: invalid number";
} }
} else if (elementName == "reboot_required") {
Q_ASSERT(metaData);
QString text = xml.readElementText();
qCDebug(PX4ParameterMetaDataLog) << "RebootRequired:" << text;
if (text.compare("true", Qt::CaseInsensitive) == 0) {
metaData->setRebootRequired(true);
}
} else { } else {
qDebug() << "Unknown element in XML: " << elementName; qDebug() << "Unknown element in XML: " << elementName;
} }
......
...@@ -50,7 +50,6 @@ Item { ...@@ -50,7 +50,6 @@ Item {
property var _activeVehicle: multiVehicleManager.activeVehicle property var _activeVehicle: multiVehicleManager.activeVehicle
readonly property var _defaultVehicleCoordinate: mainWindow.tabletPosition
readonly property real _defaultRoll: 0 readonly property real _defaultRoll: 0
readonly property real _defaultPitch: 0 readonly property real _defaultPitch: 0
readonly property real _defaultHeading: 0 readonly property real _defaultHeading: 0
...@@ -71,8 +70,6 @@ Item { ...@@ -71,8 +70,6 @@ Item {
property real _pitch: _activeVehicle ? (isNaN(_activeVehicle.pitch) ? _defaultPitch : _activeVehicle.pitch) : _defaultPitch property real _pitch: _activeVehicle ? (isNaN(_activeVehicle.pitch) ? _defaultPitch : _activeVehicle.pitch) : _defaultPitch
property real _heading: _activeVehicle ? (isNaN(_activeVehicle.heading) ? _defaultHeading : _activeVehicle.heading) : _defaultHeading property real _heading: _activeVehicle ? (isNaN(_activeVehicle.heading) ? _defaultHeading : _activeVehicle.heading) : _defaultHeading
property var _vehicleCoordinate: _activeVehicle ? (_activeVehicle.coordinateValid ? _activeVehicle.coordinate : _defaultVehicleCoordinate) : _defaultVehicleCoordinate
property real _altitudeWGS84: _activeVehicle ? _activeVehicle.altitudeWGS84 : _defaultAltitudeWGS84 property real _altitudeWGS84: _activeVehicle ? _activeVehicle.altitudeWGS84 : _defaultAltitudeWGS84
property real _groundSpeed: _activeVehicle ? _activeVehicle.groundSpeed : _defaultGroundSpeed property real _groundSpeed: _activeVehicle ? _activeVehicle.groundSpeed : _defaultGroundSpeed
property real _airSpeed: _activeVehicle ? _activeVehicle.airSpeed : _defaultAirSpeed property real _airSpeed: _activeVehicle ? _activeVehicle.airSpeed : _defaultAirSpeed
...@@ -120,7 +117,6 @@ Item { ...@@ -120,7 +117,6 @@ Item {
_flightMap.zoomLevel = _savedZoomLevel _flightMap.zoomLevel = _savedZoomLevel
else else
_savedZoomLevel = _flightMap.zoomLevel _savedZoomLevel = _flightMap.zoomLevel
_flightMap.updateMapPosition(true /* force */)
} else { } else {
_flightVideo = item _flightVideo = item
} }
......
...@@ -39,18 +39,15 @@ FlightMap { ...@@ -39,18 +39,15 @@ FlightMap {
id: flightMap id: flightMap
anchors.fill: parent anchors.fill: parent
mapName: _mapName mapName: _mapName
latitude: mainWindow.tabletPosition.latitude
longitude: mainWindow.tabletPosition.longitude
property var rootVehicleCoordinate: _vehicleCoordinate property bool _followVehicle: true
property bool _followVehicle: true property bool _activeVehicleCoordinateValid: multiVehicleManager.activeVehicle ? multiVehicleManager.activeVehicle.coordinateValid : false
property var activeVehicleCoordinate: multiVehicleManager.activeVehicle ? multiVehicleManager.activeVehicle.coordinate : QtPositioning.coordinate()
onRootVehicleCoordinateChanged: updateMapPosition(false /* force */) onActiveVehicleCoordinateChanged: {
if (_followVehicle && activeVehicleCoordinate.isValid) {
function updateMapPosition(force) { _initialMapPositionSet = true
if (_followVehicle || force) { flightMap.center = activeVehicleCoordinate
flightMap.latitude = root._vehicleCoordinate.latitude
flightMap.longitude = root._vehicleCoordinate.longitude
} }
} }
......
...@@ -43,22 +43,16 @@ import QGroundControl.Mavlink 1.0 ...@@ -43,22 +43,16 @@ import QGroundControl.Mavlink 1.0
Map { Map {
id: _map id: _map
property real latitude: 64.154549 //-- If you find yourself here on startup, something went wrong :)
property real longitude: -22.023540
property real heading: 0
property bool interactive: true property bool interactive: true
property string mapName: 'defaultMap' property string mapName: 'defaultMap'
property string mapType: QGroundControl.flightMapSettings.mapTypeForMapName(mapName) property string mapType: QGroundControl.flightMapSettings.mapTypeForMapName(mapName)
// property alias mapWidgets: controlWidgets // property alias mapWidgets: controlWidgets
property bool isSatelliteMap: mapType == "Satellite Map" || mapType == "Hybrid Map" property bool isSatelliteMap: mapType == "Satellite Map" || mapType == "Hybrid Map"
property real lon: (longitude >= -180 && longitude <= 180) ? longitude : 0
property real lat: (latitude >= -90 && latitude <= 90) ? latitude : 0
readonly property real maxZoomLevel: 20 readonly property real maxZoomLevel: 20
zoomLevel: 18 zoomLevel: 18
center: QtPositioning.coordinate(lat, lon) center: QGroundControl.defaultMapPosition
gesture.flickDeceleration: 3000 gesture.flickDeceleration: 3000
gesture.enabled: interactive gesture.enabled: interactive
gesture.activeGestures: MapGestureArea.ZoomGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture gesture.activeGestures: MapGestureArea.ZoomGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture
...@@ -69,6 +63,18 @@ Map { ...@@ -69,6 +63,18 @@ Map {
Component.onCompleted: onMapTypeChanged Component.onCompleted: onMapTypeChanged
property bool _initialMapPositionSet: false
Connections {
target: mainWindow
onGcsPositionChanged: {
if (!_initialMapPositionSet) {
_initialMapPositionSet = true
flightMap.center = mainWindow.gcsPosition
}
}
}
onMapTypeChanged: { onMapTypeChanged: {
QGroundControl.flightMapSettings.setMapTypeForMapName(mapName, mapType) QGroundControl.flightMapSettings.setMapTypeForMapName(mapName, mapType)
var fullMapName = QGroundControl.flightMapSettings.mapProvider + " " + mapType var fullMapName = QGroundControl.flightMapSettings.mapProvider + " " + mapType
...@@ -80,7 +86,18 @@ Map { ...@@ -80,7 +86,18 @@ Map {
} }
} }
/********************************************* MapQuickItem {
anchorPoint.x: sourceItem.width / 2
anchorPoint.y: sourceItem.height / 2
visible: mainWindow.gcsPosition.isValid
coordinate: mainWindow.gcsPosition
sourceItem: MissionItemIndexLabel {
label: "Q"
}
}
/*********************************************
/// Map control widgets /// Map control widgets
Column { Column {
id: controlWidgets id: controlWidgets
......
...@@ -62,13 +62,8 @@ QGCView { ...@@ -62,13 +62,8 @@ QGCView {
property var _missionItems: controller.missionItems property var _missionItems: controller.missionItems
property var _currentMissionItem property var _currentMissionItem
property bool _firstVehiclePosition: true
property bool gpsLock: _activeVehicle ? _activeVehicle.coordinateValid : false property var activeVehiclePosition: _activeVehicle ? _activeVehicle.coordinate : QtPositioning.coordinate()
property bool _firstGpsLock: true
//property var _homePositionManager: QGroundControl.homePositionManager
//property string _homePositionName: _homePositionManager.homePositions.get(0).name
//property var offlineHomePosition: _homePositionManager.homePositions.get(0).coordinate
property var liveHomePosition: controller.liveHomePosition property var liveHomePosition: controller.liveHomePosition
property var liveHomePositionAvailable: controller.liveHomePositionAvailable property var liveHomePositionAvailable: controller.liveHomePositionAvailable
...@@ -76,17 +71,23 @@ QGCView { ...@@ -76,17 +71,23 @@ QGCView {
property bool _syncInProgress: _activeVehicle ? _activeVehicle.missionManager.inProgress : false property bool _syncInProgress: _activeVehicle ? _activeVehicle.missionManager.inProgress : false
onGpsLockChanged: updateMapToVehiclePosition() Component.onCompleted: updateMapToVehiclePosition()
onActiveVehiclePositionChanged: updateMapToVehiclePosition()
Component.onCompleted: { Connections {
updateMapToVehiclePosition() target: multiVehicleManager
onActiveVehicleChanged: {
// When the active vehicle changes we need to allow the first vehicle position to move the map again
_firstVehiclePosition = true
updateMapToVehiclePosition()
}
} }
function updateMapToVehiclePosition() { function updateMapToVehiclePosition() {
if (gpsLock && _firstGpsLock) { if (_activeVehicle && _activeVehicle.coordinateValid && _firstVehiclePosition) {
_firstGpsLock = false _firstVehiclePosition = false
editorMap.latitude = _activeVehicle.latitude editorMap.center = _activeVehicle.coordinate
editorMap.longitude = _activeVehicle.longitude
} }
} }
...@@ -178,8 +179,6 @@ QGCView { ...@@ -178,8 +179,6 @@ QGCView {
id: editorMap id: editorMap
anchors.fill: parent anchors.fill: parent
mapName: "MissionEditor" mapName: "MissionEditor"
latitude: mainWindow.tabletPosition.latitude
longitude: mainWindow.tabletPosition.longitude
readonly property real animationDuration: 500 readonly property real animationDuration: 500
...@@ -190,20 +189,6 @@ QGCView { ...@@ -190,20 +189,6 @@ QGCView {
} }
} }
Behavior on latitude {
NumberAnimation {
duration: editorMap.animationDuration
easing.type: Easing.InOutQuad
}
}
Behavior on longitude {
NumberAnimation {
duration: editorMap.animationDuration
easing.type: Easing.InOutQuad
}
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
......
...@@ -122,6 +122,8 @@ const char* QGCApplication::_settingsVersionKey = "SettingsVersion"; ...@@ -122,6 +122,8 @@ const char* QGCApplication::_settingsVersionKey = "SettingsVersion";
const char* QGCApplication::_promptFlightDataSave = "PromptFLightDataSave"; const char* QGCApplication::_promptFlightDataSave = "PromptFLightDataSave";
const char* QGCApplication::_promptFlightDataSaveNotArmed = "PromptFLightDataSaveNotArmed"; const char* QGCApplication::_promptFlightDataSaveNotArmed = "PromptFLightDataSaveNotArmed";
const char* QGCApplication::_styleKey = "StyleIsDark"; const char* QGCApplication::_styleKey = "StyleIsDark";
const char* QGCApplication::_defaultMapPositionLatKey = "DefaultMapPositionLat";
const char* QGCApplication::_defaultMapPositionLonKey = "DefaultMapPositionLon";
const char* QGCApplication::_darkStyleFile = ":/res/styles/style-dark.css"; const char* QGCApplication::_darkStyleFile = ":/res/styles/style-dark.css";
const char* QGCApplication::_lightStyleFile = ":/res/styles/style-light.css"; const char* QGCApplication::_lightStyleFile = ":/res/styles/style-light.css";
...@@ -177,6 +179,7 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) ...@@ -177,6 +179,7 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
#endif #endif
, _toolbox(NULL) , _toolbox(NULL)
, _bluetoothAvailable(false) , _bluetoothAvailable(false)
, _defaultMapPosition(37.803784, -122.462276)
{ {
Q_ASSERT(_app == NULL); Q_ASSERT(_app == NULL);
_app = this; _app = this;
...@@ -319,6 +322,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) ...@@ -319,6 +322,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
settings.setValue(_settingsVersionKey, QGC_SETTINGS_VERSION); settings.setValue(_settingsVersionKey, QGC_SETTINGS_VERSION);
} }
_defaultMapPosition.setLatitude(settings.value(_defaultMapPositionLatKey, 37.803784).toDouble());
_defaultMapPosition.setLongitude(settings.value(_defaultMapPositionLonKey, -122.462276).toDouble());
// Initialize Bluetooth // Initialize Bluetooth
#ifdef QGC_ENABLE_BLUETOOTH #ifdef QGC_ENABLE_BLUETOOTH
QBluetoothLocalDevice localDevice; QBluetoothLocalDevice localDevice;
...@@ -713,3 +719,12 @@ void QGCApplication::_showSetupVehicleComponent(VehicleComponent* vehicleCompone ...@@ -713,3 +719,12 @@ void QGCApplication::_showSetupVehicleComponent(VehicleComponent* vehicleCompone
QMetaObject::invokeMethod(_rootQmlObject(), "showSetupVehicleComponent", Q_RETURN_ARG(QVariant, varReturn), Q_ARG(QVariant, varComponent)); QMetaObject::invokeMethod(_rootQmlObject(), "showSetupVehicleComponent", Q_RETURN_ARG(QVariant, varReturn), Q_ARG(QVariant, varComponent));
} }
void QGCApplication::setDefaultMapPosition(QGeoCoordinate& defaultMapPosition)
{
QSettings settings;
settings.setValue(_defaultMapPositionLatKey, defaultMapPosition.latitude());
settings.setValue(_defaultMapPositionLonKey, defaultMapPosition.longitude());
_defaultMapPosition = defaultMapPosition;
}
...@@ -121,6 +121,9 @@ public: ...@@ -121,6 +121,9 @@ public:
/// Do we have Bluetooth Support? /// Do we have Bluetooth Support?
bool isBluetoothAvailable() { return _bluetoothAvailable; } bool isBluetoothAvailable() { return _bluetoothAvailable; }
QGeoCoordinate defaultMapPosition(void) { return _defaultMapPosition; }
void setDefaultMapPosition(QGeoCoordinate& defaultMapPosition);
public slots: public slots:
/// You can connect to this slot to show an information message box from a different thread. /// You can connect to this slot to show an information message box from a different thread.
void informationMessageBoxOnMainThread(const QString& title, const QString& msg); void informationMessageBoxOnMainThread(const QString& title, const QString& msg);
...@@ -184,12 +187,6 @@ private: ...@@ -184,12 +187,6 @@ private:
QQmlApplicationEngine* _qmlAppEngine; QQmlApplicationEngine* _qmlAppEngine;
#endif #endif
static const char* _settingsVersionKey; ///< Settings key which hold settings version
static const char* _deleteAllSettingsKey; ///< If this settings key is set on boot, all settings will be deleted
static const char* _promptFlightDataSave; ///< Settings key for promptFlightDataSave
static const char* _promptFlightDataSaveNotArmed; ///< Settings key for promptFlightDataSaveNotArmed
static const char* _styleKey; ///< Settings key for UI style
bool _runningUnitTests; ///< true: running unit tests, false: normal app bool _runningUnitTests; ///< true: running unit tests, false: normal app
static const char* _darkStyleFile; static const char* _darkStyleFile;
...@@ -210,6 +207,16 @@ private: ...@@ -210,6 +207,16 @@ private:
bool _bluetoothAvailable; bool _bluetoothAvailable;
QGeoCoordinate _defaultMapPosition; ///< Map position when all other sources fail
static const char* _settingsVersionKey; ///< Settings key which hold settings version
static const char* _deleteAllSettingsKey; ///< If this settings key is set on boot, all settings will be deleted
static const char* _promptFlightDataSave; ///< Settings key for promptFlightDataSave
static const char* _promptFlightDataSaveNotArmed; ///< Settings key for promptFlightDataSaveNotArmed
static const char* _styleKey; ///< Settings key for UI style
static const char* _defaultMapPositionLatKey; ///< Settings key for default map location
static const char* _defaultMapPositionLonKey; ///< Settings key for default map location
/// Unit Test have access to creating and destroying singletons /// Unit Test have access to creating and destroying singletons
friend class UnitTest; friend class UnitTest;
}; };
......
...@@ -42,7 +42,6 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app) ...@@ -42,7 +42,6 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app)
, _virtualTabletJoystick(false) , _virtualTabletJoystick(false)
, _offlineEditingFirmwareTypeFact(QString(), "OfflineEditingFirmwareType", FactMetaData::valueTypeUint32, (uint32_t)MAV_AUTOPILOT_ARDUPILOTMEGA) , _offlineEditingFirmwareTypeFact(QString(), "OfflineEditingFirmwareType", FactMetaData::valueTypeUint32, (uint32_t)MAV_AUTOPILOT_ARDUPILOTMEGA)
, _offlineEditingFirmwareTypeMetaData(FactMetaData::valueTypeUint32) , _offlineEditingFirmwareTypeMetaData(FactMetaData::valueTypeUint32)
{ {
QSettings settings; QSettings settings;
_virtualTabletJoystick = settings.value(_virtualTabletJoystickKey, false). toBool(); _virtualTabletJoystick = settings.value(_virtualTabletJoystickKey, false). toBool();
......
...@@ -76,6 +76,8 @@ public: ...@@ -76,6 +76,8 @@ public:
Q_PROPERTY(Fact* offlineEditingFirmwareType READ offlineEditingFirmwareType CONSTANT) Q_PROPERTY(Fact* offlineEditingFirmwareType READ offlineEditingFirmwareType CONSTANT)
Q_PROPERTY(QGeoCoordinate defaultMapPosition READ defaultMapPosition CONSTANT)
Q_INVOKABLE void saveGlobalSetting (const QString& key, const QString& value); Q_INVOKABLE void saveGlobalSetting (const QString& key, const QString& value);
Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue); Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue);
Q_INVOKABLE void saveBoolGlobalSetting (const QString& key, bool value); Q_INVOKABLE void saveBoolGlobalSetting (const QString& key, bool value);
...@@ -113,6 +115,8 @@ public: ...@@ -113,6 +115,8 @@ public:
bool isVersionCheckEnabled () { return _toolbox->mavlinkProtocol()->versionCheckEnabled(); } bool isVersionCheckEnabled () { return _toolbox->mavlinkProtocol()->versionCheckEnabled(); }
int mavlinkSystemID () { return _toolbox->mavlinkProtocol()->getSystemId(); } int mavlinkSystemID () { return _toolbox->mavlinkProtocol()->getSystemId(); }
QGeoCoordinate defaultMapPosition() { return qgcApp()->defaultMapPosition(); }
Fact* offlineEditingFirmwareType () { return &_offlineEditingFirmwareTypeFact; } Fact* offlineEditingFirmwareType () { return &_offlineEditingFirmwareTypeFact; }
//-- TODO: Make this into an actual preference. //-- TODO: Make this into an actual preference.
...@@ -144,7 +148,6 @@ signals: ...@@ -144,7 +148,6 @@ signals:
void mavlinkSystemIDChanged (int id); void mavlinkSystemIDChanged (int id);
private: private:
FlightMapSettings* _flightMapSettings; FlightMapSettings* _flightMapSettings;
HomePositionManager* _homePositionManager; HomePositionManager* _homePositionManager;
LinkManager* _linkManager; LinkManager* _linkManager;
......
...@@ -281,6 +281,7 @@ void Vehicle::_handleHomePosition(mavlink_message_t& message) ...@@ -281,6 +281,7 @@ void Vehicle::_handleHomePosition(mavlink_message_t& message)
if (emitHomePositionChanged) { if (emitHomePositionChanged) {
qCDebug(VehicleLog) << "New home position" << newHomePosition; qCDebug(VehicleLog) << "New home position" << newHomePosition;
qgcApp()->setDefaultMapPosition(_homePosition);
emit homePositionChanged(_homePosition); emit homePositionChanged(_homePosition);
} }
if (emitHomePositionAvailableChanged) { if (emitHomePositionAvailableChanged) {
......
...@@ -33,9 +33,9 @@ import QGroundControl.FlightDisplay 1.0 ...@@ -33,9 +33,9 @@ import QGroundControl.FlightDisplay 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
import QGroundControl.MultiVehicleManager 1.0 import QGroundControl.MultiVehicleManager 1.0
/// Inner common QML for MainWindow /// Inner common QML for mainWindow
Item { Item {
id: mainWindow id: mainWindow
signal reallyClose signal reallyClose
...@@ -50,10 +50,7 @@ Item { ...@@ -50,10 +50,7 @@ Item {
property real tbButtonWidth: tbCellHeight * 1.35 property real tbButtonWidth: tbCellHeight * 1.35
property real availableHeight: height - tbHeight property real availableHeight: height - tbHeight
property real menuButtonWidth: (tbButtonWidth * 2) + (tbSpacing * 4) + 1 property real menuButtonWidth: (tbButtonWidth * 2) + (tbSpacing * 4) + 1
property var gcsPosition: QtPositioning.coordinate() // Starts as invalid coordinate
property var defaultPosition: QtPositioning.coordinate(37.803784, -122.462276)
property var tabletPosition: defaultPosition
property var currentPopUp: null property var currentPopUp: null
property real currentCenterX: 0 property real currentCenterX: 0
property var activeVehicle: multiVehicleManager.activeVehicle property var activeVehicle: multiVehicleManager.activeVehicle
...@@ -179,20 +176,20 @@ Item { ...@@ -179,20 +176,20 @@ Item {
PositionSource { PositionSource {
id: positionSource id: positionSource
updateInterval: 1000 updateInterval: 1000
active: false active: true
onPositionChanged: { onPositionChanged: {
if(positionSource.valid) { if(positionSource.valid) {
if(positionSource.position.coordinate.latitude) { if(positionSource.position.coordinate.latitude) {
if(Math.abs(positionSource.position.coordinate.latitude) > 0.001) { if(Math.abs(positionSource.position.coordinate.latitude) > 0.001) {
if(positionSource.position.coordinate.longitude) { if(positionSource.position.coordinate.longitude) {
if(Math.abs(positionSource.position.coordinate.longitude) > 0.001) { if(Math.abs(positionSource.position.coordinate.longitude) > 0.001) {
tabletPosition = positionSource.position.coordinate gcsPosition = positionSource.position.coordinate
} }
} }
} }
} }
} }
positionSource.stop()
} }
} }
...@@ -299,9 +296,6 @@ Item { ...@@ -299,9 +296,6 @@ Item {
anchors.fill: parent anchors.fill: parent
availableHeight: mainWindow.availableHeight availableHeight: mainWindow.availableHeight
visible: true visible: true
Component.onCompleted: {
positionSource.start()
}
} }
Loader { Loader {
......
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