|
|
@ -27,33 +27,33 @@ FlightMapSettings::FlightMapSettings(QGCApplication* app) |
|
|
|
void FlightMapSettings::setToolbox(QGCToolbox *toolbox) |
|
|
|
void FlightMapSettings::setToolbox(QGCToolbox *toolbox) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QGCTool::setToolbox(toolbox); |
|
|
|
QGCTool::setToolbox(toolbox); |
|
|
|
|
|
|
|
|
|
|
|
qmlRegisterUncreatableType<FlightMapSettings> ("QGroundControl", 1, 0, "FlightMapSetting", "Reference only"); |
|
|
|
qmlRegisterUncreatableType<FlightMapSettings> ("QGroundControl", 1, 0, "FlightMapSetting", "Reference only"); |
|
|
|
|
|
|
|
_supportedMapProviders << "Bing"; |
|
|
|
_supportedMapProviders << "Bing" << "Google"; // << "OpenStreetMap";
|
|
|
|
#ifndef QGC_NO_GOOGLE_MAPS |
|
|
|
|
|
|
|
_supportedMapProviders << "Google"; |
|
|
|
|
|
|
|
#endif |
|
|
|
_loadSettings(); |
|
|
|
_loadSettings(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void FlightMapSettings::_storeSettings(void) |
|
|
|
void FlightMapSettings::_storeSettings(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSettings settings; |
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.setValue(_mapProviderKey, _supportedMapProviders.contains(_mapProvider) ? _mapProvider : _defaultMapProvider); |
|
|
|
settings.setValue(_mapProviderKey, _supportedMapProviders.contains(_mapProvider) ? _mapProvider : _defaultMapProvider); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void FlightMapSettings::_loadSettings(void) |
|
|
|
void FlightMapSettings::_loadSettings(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef QGC_NO_GOOGLE_MAPS |
|
|
|
|
|
|
|
_mapProvider = _defaultMapProvider; |
|
|
|
|
|
|
|
#else |
|
|
|
QSettings settings; |
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
_mapProvider = settings.value(_mapProviderKey, _defaultMapProvider).toString(); |
|
|
|
_mapProvider = settings.value(_mapProviderKey, _defaultMapProvider).toString(); |
|
|
|
|
|
|
|
|
|
|
|
if (!_supportedMapProviders.contains(_mapProvider)) { |
|
|
|
if (!_supportedMapProviders.contains(_mapProvider)) { |
|
|
|
_mapProvider = _defaultMapProvider; |
|
|
|
_mapProvider = _defaultMapProvider; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
_setMapTypesForCurrentProvider(); |
|
|
|
_setMapTypesForCurrentProvider(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -75,24 +75,21 @@ void FlightMapSettings::setMapProvider(const QString& mapProvider) |
|
|
|
void FlightMapSettings::_setMapTypesForCurrentProvider(void) |
|
|
|
void FlightMapSettings::_setMapTypesForCurrentProvider(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_mapTypes.clear(); |
|
|
|
_mapTypes.clear(); |
|
|
|
|
|
|
|
#ifdef QGC_NO_GOOGLE_MAPS |
|
|
|
|
|
|
|
_mapTypes << "Street Map" << "Satellite Map" << "Hybrid Map"; |
|
|
|
|
|
|
|
#else |
|
|
|
if (_mapProvider == "Bing") { |
|
|
|
if (_mapProvider == "Bing") { |
|
|
|
_mapTypes << "Street Map" << "Satellite Map" << "Hybrid Map"; |
|
|
|
_mapTypes << "Street Map" << "Satellite Map" << "Hybrid Map"; |
|
|
|
} else if (_mapProvider == "Google") { |
|
|
|
} else if (_mapProvider == "Google") { |
|
|
|
_mapTypes << "Street Map" << "Satellite Map" << "Terrain Map"; |
|
|
|
_mapTypes << "Street Map" << "Satellite Map" << "Terrain Map"; |
|
|
|
/*
|
|
|
|
|
|
|
|
} else if (_mapProvider == "OpenStreetMap") { |
|
|
|
|
|
|
|
_mapTypes << "Street Map"; |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
emit mapTypesChanged(_mapTypes); |
|
|
|
emit mapTypesChanged(_mapTypes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString FlightMapSettings::mapType(void) |
|
|
|
QString FlightMapSettings::mapType(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSettings settings; |
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(_mapProvider); |
|
|
|
settings.beginGroup(_mapProvider); |
|
|
|
return settings.value(_mapTypeKey, "Satellite Map").toString(); |
|
|
|
return settings.value(_mapTypeKey, "Satellite Map").toString(); |
|
|
@ -101,18 +98,15 @@ QString FlightMapSettings::mapType(void) |
|
|
|
void FlightMapSettings::setMapType(const QString& mapType) |
|
|
|
void FlightMapSettings::setMapType(const QString& mapType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSettings settings; |
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(_mapProvider); |
|
|
|
settings.beginGroup(_mapProvider); |
|
|
|
settings.setValue(_mapTypeKey, mapType); |
|
|
|
settings.setValue(_mapTypeKey, mapType); |
|
|
|
|
|
|
|
|
|
|
|
emit mapTypeChanged(mapType); |
|
|
|
emit mapTypeChanged(mapType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void FlightMapSettings::saveMapSetting (const QString &mapName, const QString& key, const QString& value) |
|
|
|
void FlightMapSettings::saveMapSetting (const QString &mapName, const QString& key, const QString& value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSettings settings; |
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(mapName); |
|
|
|
settings.beginGroup(mapName); |
|
|
|
settings.setValue(key, value); |
|
|
|
settings.setValue(key, value); |
|
|
@ -121,7 +115,6 @@ void FlightMapSettings::saveMapSetting (const QString &mapName, const QString& k |
|
|
|
QString FlightMapSettings::loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue) |
|
|
|
QString FlightMapSettings::loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSettings settings; |
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(mapName); |
|
|
|
settings.beginGroup(mapName); |
|
|
|
return settings.value(key, defaultValue).toString(); |
|
|
|
return settings.value(key, defaultValue).toString(); |
|
|
@ -130,7 +123,6 @@ QString FlightMapSettings::loadMapSetting (const QString &mapName, const QString |
|
|
|
void FlightMapSettings::saveBoolMapSetting (const QString &mapName, const QString& key, bool value) |
|
|
|
void FlightMapSettings::saveBoolMapSetting (const QString &mapName, const QString& key, bool value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSettings settings; |
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(mapName); |
|
|
|
settings.beginGroup(mapName); |
|
|
|
settings.setValue(key, value); |
|
|
|
settings.setValue(key, value); |
|
|
@ -139,7 +131,6 @@ void FlightMapSettings::saveBoolMapSetting (const QString &mapName, const QStrin |
|
|
|
bool FlightMapSettings::loadBoolMapSetting (const QString &mapName, const QString& key, bool defaultValue) |
|
|
|
bool FlightMapSettings::loadBoolMapSetting (const QString &mapName, const QString& key, bool defaultValue) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSettings settings; |
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
|
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(_settingsGroup); |
|
|
|
settings.beginGroup(mapName); |
|
|
|
settings.beginGroup(mapName); |
|
|
|
return settings.value(key, defaultValue).toBool(); |
|
|
|
return settings.value(key, defaultValue).toBool(); |
|
|
|