Unverified Commit 18a9b13a authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #5867 from gigorvd/slowmap

'manual control lost' when connected joystick with armed UAV
parents 6a75949d e944d4fa
...@@ -24,6 +24,9 @@ const char* QGroundControlQmlGlobal::_flightMapPositionLatitudeSettingsKey = ...@@ -24,6 +24,9 @@ const char* QGroundControlQmlGlobal::_flightMapPositionLatitudeSettingsKey =
const char* QGroundControlQmlGlobal::_flightMapPositionLongitudeSettingsKey = "Longitude"; const char* QGroundControlQmlGlobal::_flightMapPositionLongitudeSettingsKey = "Longitude";
const char* QGroundControlQmlGlobal::_flightMapZoomSettingsKey = "FlightMapZoom"; const char* QGroundControlQmlGlobal::_flightMapZoomSettingsKey = "FlightMapZoom";
QGeoCoordinate QGroundControlQmlGlobal::_coord = QGeoCoordinate(0.0,0.0);
double QGroundControlQmlGlobal::_zoom = 17;
QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app, QGCToolbox* toolbox) QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app, QGCToolbox* toolbox)
: QGCTool(app, toolbox) : QGCTool(app, toolbox)
, _flightMapInitialZoom(17.0) , _flightMapInitialZoom(17.0)
...@@ -41,11 +44,26 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app, QGCToolbox ...@@ -41,11 +44,26 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app, QGCToolbox
{ {
// We clear the parent on this object since we run into shutdown problems caused by hybrid qml app. Instead we let it leak on shutdown. // We clear the parent on this object since we run into shutdown problems caused by hybrid qml app. Instead we let it leak on shutdown.
setParent(NULL); setParent(NULL);
// Load last coordinates and zoom from config file
QSettings settings;
settings.beginGroup(_flightMapPositionSettingsGroup);
_coord.setLatitude(settings.value(_flightMapPositionLatitudeSettingsKey, 0).toDouble());
_coord.setLongitude(settings.value(_flightMapPositionLongitudeSettingsKey, 0).toDouble());
_zoom = settings.value(_flightMapZoomSettingsKey, 2).toDouble();
//if config file is clear
if(_zoom == 0) _zoom = 17.0;
} }
QGroundControlQmlGlobal::~QGroundControlQmlGlobal() QGroundControlQmlGlobal::~QGroundControlQmlGlobal()
{ {
// Save last coordinates and zoom to config file
QSettings settings;
settings.beginGroup(_flightMapPositionSettingsGroup);
settings.setValue(_flightMapPositionLatitudeSettingsKey, _coord.latitude());
settings.setValue(_flightMapPositionLongitudeSettingsKey, _coord.longitude());
settings.setValue(_flightMapZoomSettingsKey, _zoom);
} }
void QGroundControlQmlGlobal::setToolbox(QGCToolbox* toolbox) void QGroundControlQmlGlobal::setToolbox(QGCToolbox* toolbox)
...@@ -198,34 +216,12 @@ void QGroundControlQmlGlobal::setSkipSetupPage(bool skip) ...@@ -198,34 +216,12 @@ void QGroundControlQmlGlobal::setSkipSetupPage(bool skip)
} }
} }
QGeoCoordinate QGroundControlQmlGlobal::flightMapPosition(void)
{
QSettings settings;
QGeoCoordinate coord;
settings.beginGroup(_flightMapPositionSettingsGroup);
coord.setLatitude(settings.value(_flightMapPositionLatitudeSettingsKey, 0).toDouble());
coord.setLongitude(settings.value(_flightMapPositionLongitudeSettingsKey, 0).toDouble());
return coord;
}
double QGroundControlQmlGlobal::flightMapZoom(void)
{
QSettings settings;
settings.beginGroup(_flightMapPositionSettingsGroup);
return settings.value(_flightMapZoomSettingsKey, 2).toDouble();
}
void QGroundControlQmlGlobal::setFlightMapPosition(QGeoCoordinate& coordinate) void QGroundControlQmlGlobal::setFlightMapPosition(QGeoCoordinate& coordinate)
{ {
if (coordinate != flightMapPosition()) { if (coordinate != flightMapPosition()) {
QSettings settings; _coord.setLatitude(coordinate.latitude());
_coord.setLongitude(coordinate.longitude());
settings.beginGroup(_flightMapPositionSettingsGroup);
settings.setValue(_flightMapPositionLatitudeSettingsKey, coordinate.latitude());
settings.setValue(_flightMapPositionLongitudeSettingsKey, coordinate.longitude());
emit flightMapPositionChanged(coordinate); emit flightMapPositionChanged(coordinate);
} }
} }
...@@ -233,10 +229,7 @@ void QGroundControlQmlGlobal::setFlightMapPosition(QGeoCoordinate& coordinate) ...@@ -233,10 +229,7 @@ void QGroundControlQmlGlobal::setFlightMapPosition(QGeoCoordinate& coordinate)
void QGroundControlQmlGlobal::setFlightMapZoom(double zoom) void QGroundControlQmlGlobal::setFlightMapZoom(double zoom)
{ {
if (zoom != flightMapZoom()) { if (zoom != flightMapZoom()) {
QSettings settings; _zoom = zoom;
settings.beginGroup(_flightMapPositionSettingsGroup);
settings.setValue(_flightMapZoomSettingsKey, zoom);
emit flightMapZoomChanged(zoom); emit flightMapZoomChanged(zoom);
} }
} }
......
...@@ -142,8 +142,8 @@ public: ...@@ -142,8 +142,8 @@ public:
QGCCorePlugin* corePlugin () { return _corePlugin; } QGCCorePlugin* corePlugin () { return _corePlugin; }
SettingsManager* settingsManager () { return _settingsManager; } SettingsManager* settingsManager () { return _settingsManager; }
FactGroup* gpsRtkFactGroup () { return &_gpsRtkFactGroup; } FactGroup* gpsRtkFactGroup () { return &_gpsRtkFactGroup; }
static QGeoCoordinate flightMapPosition (); static QGeoCoordinate flightMapPosition () { return _coord; }
static double flightMapZoom (); static double flightMapZoom () { return _zoom; }
qreal zOrderTopMost () { return 1000; } qreal zOrderTopMost () { return 1000; }
qreal zOrderWidgets () { return 100; } qreal zOrderWidgets () { return 100; }
...@@ -209,6 +209,9 @@ private: ...@@ -209,6 +209,9 @@ private:
static const char* _flightMapPositionLatitudeSettingsKey; static const char* _flightMapPositionLatitudeSettingsKey;
static const char* _flightMapPositionLongitudeSettingsKey; static const char* _flightMapPositionLongitudeSettingsKey;
static const char* _flightMapZoomSettingsKey; static const char* _flightMapZoomSettingsKey;
static QGeoCoordinate _coord;
static double _zoom;
}; };
#endif #endif
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