|
|
|
@ -24,6 +24,9 @@ const char* QGroundControlQmlGlobal::_flightMapPositionLatitudeSettingsKey =
@@ -24,6 +24,9 @@ const char* QGroundControlQmlGlobal::_flightMapPositionLatitudeSettingsKey =
|
|
|
|
|
const char* QGroundControlQmlGlobal::_flightMapPositionLongitudeSettingsKey = "Longitude"; |
|
|
|
|
const char* QGroundControlQmlGlobal::_flightMapZoomSettingsKey = "FlightMapZoom"; |
|
|
|
|
|
|
|
|
|
QGeoCoordinate QGroundControlQmlGlobal::_coord = QGeoCoordinate(0.0,0.0); |
|
|
|
|
double QGroundControlQmlGlobal::_zoom = 17; |
|
|
|
|
|
|
|
|
|
QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app, QGCToolbox* toolbox) |
|
|
|
|
: QGCTool(app, toolbox) |
|
|
|
|
, _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.
|
|
|
|
|
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() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
// 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) |
|
|
|
@ -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) |
|
|
|
|
{ |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -233,10 +229,7 @@ void QGroundControlQmlGlobal::setFlightMapPosition(QGeoCoordinate& coordinate)
@@ -233,10 +229,7 @@ void QGroundControlQmlGlobal::setFlightMapPosition(QGeoCoordinate& coordinate)
|
|
|
|
|
void QGroundControlQmlGlobal::setFlightMapZoom(double zoom) |
|
|
|
|
{ |
|
|
|
|
if (zoom != flightMapZoom()) { |
|
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
|
|
settings.beginGroup(_flightMapPositionSettingsGroup); |
|
|
|
|
settings.setValue(_flightMapZoomSettingsKey, zoom); |
|
|
|
|
_zoom = zoom; |
|
|
|
|
emit flightMapZoomChanged(zoom); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|