diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro
index 99a7e3278cd60980a7ae0504a6d35d90ad7a8c16..083cd9f419e3e90d93baa55c44bcf5ef9087d17f 100644
--- a/qgroundcontrol.pro
+++ b/qgroundcontrol.pro
@@ -443,7 +443,6 @@ HEADERS += \
src/CmdLineOptParser.h \
src/FirmwarePlugin/PX4/px4_custom_mode.h \
src/FlightDisplay/VideoManager.h \
- src/FlightMap/FlightMapSettings.h \
src/FlightMap/Widgets/ValuesWidgetController.h \
src/FollowMe/FollowMe.h \
src/GAudioOutput.h \
@@ -502,6 +501,7 @@ HEADERS += \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \
src/Settings/AppSettings.h \
src/Settings/AutoConnectSettings.h \
+ src/Settings/FlightMapSettings.h \
src/Settings/SettingsGroup.h \
src/Settings/SettingsManager.h \
src/Settings/UnitsSettings.h \
@@ -622,7 +622,6 @@ SOURCES += \
src/AnalyzeView/ExifParser.cc \
src/CmdLineOptParser.cc \
src/FlightDisplay/VideoManager.cc \
- src/FlightMap/FlightMapSettings.cc \
src/FlightMap/Widgets/ValuesWidgetController.cc \
src/FollowMe/FollowMe.cc \
src/GAudioOutput.cc \
@@ -678,6 +677,7 @@ SOURCES += \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \
src/Settings/AppSettings.cc \
src/Settings/AutoConnectSettings.cc \
+ src/Settings/FlightMapSettings.cc \
src/Settings/SettingsGroup.cc \
src/Settings/SettingsManager.cc \
src/Settings/UnitsSettings.cc \
diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index fcdf43b5342f9ec4ea6c9ab54cea42a571d7552a..584a96c04ea8afdfbe86a60c1eb24477672e6657 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -188,6 +188,7 @@
src/MissionManager/MavCmdInfoVTOL.json
src/Settings/App.SettingsGroup.json
src/Settings/AutoConnect.SettingsGroup.json
+ src/Settings/FlightMap.SettingsGroup.json
src/MissionManager/Survey.SettingsGroup.json
src/Settings/Units.SettingsGroup.json
src/Settings/Video.SettingsGroup.json
diff --git a/src/FlightDisplay/FlightDisplayViewMap.qml b/src/FlightDisplay/FlightDisplayViewMap.qml
index 14ef37dd2d97efa5ae22e940660d45f62b1bb07a..602b9057eab3b0d881e569775ae52442d27c1ce1 100644
--- a/src/FlightDisplay/FlightDisplayViewMap.qml
+++ b/src/FlightDisplay/FlightDisplayViewMap.qml
@@ -164,7 +164,7 @@ FlightMap {
color: qgcPal.window
title: qsTr("Fly")
z: QGroundControl.zOrderWidgets
- buttonVisible: [ true, true, _showZoom, _showZoom ]
+ buttonVisible: [ true, _showZoom, _showZoom ]
maxHeight: (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y // Massive reach across hack
property bool _showZoom: !ScreenTools.isMobile
@@ -175,11 +175,6 @@ FlightMap {
iconSource: "/qmlimages/MapCenter.svg",
dropPanelComponent: centerMapDropPanel
},
- {
- name: "Map",
- iconSource: "/qmlimages/MapType.svg",
- dropPanelComponent: mapTypeDropPanel
- },
{
name: "In",
iconSource: "/qmlimages/ZoomPlus.svg"
@@ -229,33 +224,6 @@ FlightMap {
}
}
- Component {
- id: mapTypeDropPanel
-
- Column {
- spacing: ScreenTools.defaultFontPixelHeight / 2
-
- QGCLabel { text: qsTr("Map type:") }
- Row {
- spacing: ScreenTools.defaultFontPixelWidth
- Repeater {
- model: QGroundControl.flightMapSettings.mapTypes
-
- QGCButton {
- checkable: true
- checked: QGroundControl.flightMapSettings.mapType === text
- text: modelData
- exclusiveGroup: _mapTypeButtonsExclusiveGroup
- onClicked: {
- QGroundControl.flightMapSettings.mapType = text
- dropPanel.hide()
- }
- }
- }
- }
- }
- }
-
// Add trajectory points to the map
MapItemView {
model: _mainIsMap ? _activeVehicle ? _activeVehicle.trajectoryPoints : 0 : 0
diff --git a/src/FlightMap/FlightMap.qml b/src/FlightMap/FlightMap.qml
index 5f689620edb87cb225fc4cbcac3d865351f51f08..af6aed338dc4153ba9f2d1959b2ed971dabffd56 100644
--- a/src/FlightMap/FlightMap.qml
+++ b/src/FlightMap/FlightMap.qml
@@ -85,7 +85,8 @@ Map {
}
function updateActiveMapType() {
- var fullMapName = QGroundControl.flightMapSettings.mapProvider + " " + QGroundControl.flightMapSettings.mapType
+ var settings = QGroundControl.settingsManager.flightMapSettings
+ var fullMapName = settings.mapProvider.enumStringValue + " " + settings.mapType.enumStringValue
for (var i = 0; i < _map.supportedMapTypes.length; i++) {
if (fullMapName === _map.supportedMapTypes[i].name) {
_map.activeMapType = _map.supportedMapTypes[i]
@@ -97,8 +98,13 @@ Map {
Component.onCompleted: updateActiveMapType()
Connections {
- target: QGroundControl.flightMapSettings
- onMapTypeChanged: updateActiveMapType()
+ target: QGroundControl.settingsManager.flightMapSettings.mapType
+ onRawValueChanged: updateActiveMapType()
+ }
+
+ Connections {
+ target: QGroundControl.settingsManager.flightMapSettings.mapProvider
+ onRawValueChanged: updateActiveMapType()
}
/// Ground Station location
diff --git a/src/FlightMap/FlightMapSettings.cc b/src/FlightMap/FlightMapSettings.cc
deleted file mode 100644
index 462a48fef3fc1c69ec170359f4825118a9906a99..0000000000000000000000000000000000000000
--- a/src/FlightMap/FlightMapSettings.cc
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
- *
- * (c) 2009-2016 QGROUNDCONTROL PROJECT
- *
- * QGroundControl is licensed according to the terms in the file
- * COPYING.md in the root of the source code directory.
- *
- ****************************************************************************/
-
-
-#include "FlightMapSettings.h"
-
-#include
-#include
-
-const char* FlightMapSettings::_defaultMapProvider = "Bing"; // Bing is default since it support full street/satellite/hybrid set
-const char* FlightMapSettings::_settingsGroup = "FlightMapSettings";
-const char* FlightMapSettings::_mapProviderKey = "MapProvider";
-const char* FlightMapSettings::_mapTypeKey = "MapType";
-
-FlightMapSettings::FlightMapSettings(QGCApplication* app)
- : QGCTool(app)
- , _mapProvider(_defaultMapProvider)
-{
-}
-
-void FlightMapSettings::setToolbox(QGCToolbox *toolbox)
-{
- QGCTool::setToolbox(toolbox);
- qmlRegisterUncreatableType ("QGroundControl", 1, 0, "FlightMapSetting", "Reference only");
- _supportedMapProviders << "Bing";
-#ifndef QGC_NO_GOOGLE_MAPS
- _supportedMapProviders << "Google";
-#endif
- _supportedMapProviders << "Statkart";
- _loadSettings();
-}
-
-void FlightMapSettings::_storeSettings(void)
-{
- QSettings settings;
- settings.beginGroup(_settingsGroup);
- settings.setValue(_mapProviderKey, _supportedMapProviders.contains(_mapProvider) ? _mapProvider : _defaultMapProvider);
-}
-
-void FlightMapSettings::_loadSettings(void)
-{
-#ifdef QGC_NO_GOOGLE_MAPS
- _mapProvider = _defaultMapProvider;
-#else
- QSettings settings;
- settings.beginGroup(_settingsGroup);
- _mapProvider = settings.value(_mapProviderKey, _defaultMapProvider).toString();
- if (!_supportedMapProviders.contains(_mapProvider)) {
- _mapProvider = _defaultMapProvider;
- }
-#endif
- _setMapTypesForCurrentProvider();
-}
-
-QString FlightMapSettings::mapProvider(void)
-{
- return _mapProvider;
-}
-
-void FlightMapSettings::setMapProvider(const QString& mapProvider)
-{
- if (_supportedMapProviders.contains(mapProvider)) {
- _mapProvider = mapProvider;
- _storeSettings();
- _setMapTypesForCurrentProvider();
- emit mapProviderChanged(mapProvider);
- }
-}
-
-void FlightMapSettings::_setMapTypesForCurrentProvider(void)
-{
- _mapTypes.clear();
-#ifdef QGC_NO_GOOGLE_MAPS
- _mapTypes << "Street Map" << "Satellite Map" << "Hybrid Map";
-#else
- if (_mapProvider == "Bing") {
- _mapTypes << "Street Map" << "Satellite Map" << "Hybrid Map";
- } else if (_mapProvider == "Google") {
- _mapTypes << "Street Map" << "Satellite Map" << "Terrain Map";
- } else if (_mapProvider == "Statkart") {
- _mapTypes << "Topo2";
- }
-#endif
- emit mapTypesChanged(_mapTypes);
-}
-
-QString FlightMapSettings::mapType(void)
-{
- QSettings settings;
- settings.beginGroup(_settingsGroup);
- settings.beginGroup(_mapProvider);
- return settings.value(_mapTypeKey, "Satellite Map").toString();
-}
-
-void FlightMapSettings::setMapType(const QString& mapType)
-{
- QSettings settings;
- settings.beginGroup(_settingsGroup);
- settings.beginGroup(_mapProvider);
- settings.setValue(_mapTypeKey, mapType);
- emit mapTypeChanged(mapType);
-}
-
-void FlightMapSettings::saveMapSetting (const QString &mapName, const QString& key, const QString& value)
-{
- QSettings settings;
- settings.beginGroup(_settingsGroup);
- settings.beginGroup(mapName);
- settings.setValue(key, value);
-}
-
-QString FlightMapSettings::loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue)
-{
- QSettings settings;
- settings.beginGroup(_settingsGroup);
- settings.beginGroup(mapName);
- return settings.value(key, defaultValue).toString();
-}
-
-void FlightMapSettings::saveBoolMapSetting (const QString &mapName, const QString& key, bool value)
-{
- QSettings settings;
- settings.beginGroup(_settingsGroup);
- settings.beginGroup(mapName);
- settings.setValue(key, value);
-}
-
-bool FlightMapSettings::loadBoolMapSetting (const QString &mapName, const QString& key, bool defaultValue)
-{
- QSettings settings;
- settings.beginGroup(_settingsGroup);
- settings.beginGroup(mapName);
- return settings.value(key, defaultValue).toBool();
-}
diff --git a/src/FlightMap/FlightMapSettings.h b/src/FlightMap/FlightMapSettings.h
deleted file mode 100644
index 66e7b396480fe9325b800548923ec464e1463bf8..0000000000000000000000000000000000000000
--- a/src/FlightMap/FlightMapSettings.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
- *
- * (c) 2009-2016 QGROUNDCONTROL PROJECT
- *
- * QGroundControl is licensed according to the terms in the file
- * COPYING.md in the root of the source code directory.
- *
- ****************************************************************************/
-
-
-#ifndef FlightMapSettings_H
-#define FlightMapSettings_H
-
-#include "QGCToolbox.h"
-
-#include
-#include
-
-/*
- TODO: Map settings should come from QGCMapEngineManager. What is currently in
- FlightMapSettings should be moved there so all map related funtions are in
- one place.
- */
-
-class FlightMapSettings : public QGCTool
-{
- Q_OBJECT
-
-public:
- FlightMapSettings(QGCApplication* app);
-
- /// mapProvider is either Bing, Google or Open to specify to set of maps available
- Q_PROPERTY(QString mapProvider READ mapProvider WRITE setMapProvider NOTIFY mapProviderChanged)
-
- /// Map providers
- Q_PROPERTY(QStringList mapProviders READ mapProviders CONSTANT)
-
- /// Map types associated with current map provider
- Q_PROPERTY(QStringList mapTypes MEMBER _mapTypes NOTIFY mapTypesChanged)
-
- /// Map type to be used for all maps
- Q_PROPERTY(QString mapType READ mapType WRITE setMapType NOTIFY mapTypeChanged)
-
- /// Is Google Maps Enabled
- Q_PROPERTY(bool googleMapEnabled READ googleMapEnabled CONSTANT)
-
- Q_INVOKABLE void saveMapSetting (const QString &mapName, const QString& key, const QString& value);
- Q_INVOKABLE QString loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue);
- Q_INVOKABLE void saveBoolMapSetting (const QString &mapName, const QString& key, bool value);
- Q_INVOKABLE bool loadBoolMapSetting (const QString &mapName, const QString& key, bool defaultValue);
-
- // Property accessors
-
- QString mapProvider(void);
- void setMapProvider(const QString& mapProvider);
-
- QString mapType(void);
- void setMapType(const QString& mapType);
-
- // Override from QGCTool
- virtual void setToolbox(QGCToolbox *toolbox);
-
- QStringList mapProviders() { return _supportedMapProviders; }
-
-#ifdef QGC_NO_GOOGLE_MAPS
- bool googleMapEnabled () { return false; }
-#else
- bool googleMapEnabled () { return true; }
-#endif
-
-
-signals:
- void mapProviderChanged (const QString& mapProvider);
- void mapTypesChanged (const QStringList& mapTypes);
- void mapTypeChanged (const QString& mapType);
-
-private:
- void _storeSettings (void);
- void _loadSettings (void);
-
- void _setMapTypesForCurrentProvider(void);
-
- QString _mapProvider; ///< Current map provider
- QStringList _supportedMapProviders;
- QStringList _mapTypes; ///< Map types associated with current map provider
-
- static const char* _defaultMapProvider;
- static const char* _settingsGroup;
- static const char* _mapProviderKey;
- static const char* _mapTypeKey;
-};
-
-#endif
diff --git a/src/MissionEditor/MissionEditor.qml b/src/MissionEditor/MissionEditor.qml
index 61f599d41b50ef28ed9679a6c465bc3b0d8818d8..207ec51de4abd126e5a65212caff332285afce5d 100644
--- a/src/MissionEditor/MissionEditor.qml
+++ b/src/MissionEditor/MissionEditor.qml
@@ -679,11 +679,11 @@ QGCView {
color: qgcPal.window
title: qsTr("Plan")
z: QGroundControl.zOrderWidgets
- showAlternateIcon: [ false, false, _syncDropDownController.dirty, false, false, false, false ]
- rotateImage: [ false, false, _syncDropDownController.syncInProgress, false, false, false, false ]
- animateImage: [ false, false, _syncDropDownController.dirty, false, false, false, false ]
- buttonEnabled: [ true, true, !_syncDropDownController.syncInProgress, true, true, true, true ]
- buttonVisible: [ true, true, true, true, true, _showZoom, _showZoom ]
+ showAlternateIcon: [ false, false, _syncDropDownController.dirty, false, false, false ]
+ rotateImage: [ false, false, _syncDropDownController.syncInProgress, false, false, false ]
+ animateImage: [ false, false, _syncDropDownController.dirty, false, false, false ]
+ buttonEnabled: [ true, true, !_syncDropDownController.syncInProgress, true, true, true ]
+ buttonVisible: [ true, true, true, true, _showZoom, _showZoom ]
maxHeight: mapScale.y - toolStrip.y
property bool _showZoom: !ScreenTools.isMobile
@@ -710,11 +710,6 @@ QGCView {
iconSource: "/qmlimages/MapCenter.svg",
dropPanelComponent: centerMapDropPanel
},
- {
- name: "Map",
- iconSource: "/qmlimages/MapType.svg",
- dropPanelComponent: mapTypeDropPanel
- },
{
name: "In",
iconSource: "/qmlimages/ZoomPlus.svg"
@@ -904,34 +899,6 @@ QGCView {
}
}
- Component {
- id: mapTypeDropPanel
-
- Column {
- spacing: _margin
-
- QGCLabel { text: qsTr("Map type:") }
- Row {
- spacing: ScreenTools.defaultFontPixelWidth
- Repeater {
- model: QGroundControl.flightMapSettings.mapTypes
-
- QGCButton {
- checkable: true
- checked: QGroundControl.flightMapSettings.mapType === text
- text: modelData
- exclusiveGroup: _mapTypeButtonsExclusiveGroup
-
- onClicked: {
- QGroundControl.flightMapSettings.mapType = text
- dropPanel.hide()
- }
- }
- }
- }
- }
- }
-
Component {
id: patternDropPanel
diff --git a/src/QGCToolbox.cc b/src/QGCToolbox.cc
index f67e57bae205a62072ebe9769b9ee3be564c1753..d6371bdf66119a5fb3d565f2a5e26e028d052582 100644
--- a/src/QGCToolbox.cc
+++ b/src/QGCToolbox.cc
@@ -10,7 +10,6 @@
#include "FactSystem.h"
#include "FirmwarePluginManager.h"
-#include "FlightMapSettings.h"
#include "GAudioOutput.h"
#ifndef __mobile__
#include "GPSManager.h"
@@ -39,7 +38,6 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
: _audioOutput(NULL)
, _factSystem(NULL)
, _firmwarePluginManager(NULL)
- , _flightMapSettings(NULL)
#ifndef __mobile__
, _gpsManager(NULL)
#endif
@@ -66,7 +64,6 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
_audioOutput = new GAudioOutput(app);
_factSystem = new FactSystem(app);
_firmwarePluginManager = new FirmwarePluginManager(app);
- _flightMapSettings = new FlightMapSettings(app);
#ifndef __mobile__
_gpsManager = new GPSManager(app);
#endif
@@ -93,7 +90,6 @@ void QGCToolbox::setChildToolboxes(void)
_audioOutput->setToolbox(this);
_factSystem->setToolbox(this);
_firmwarePluginManager->setToolbox(this);
- _flightMapSettings->setToolbox(this);
#ifndef __mobile__
_gpsManager->setToolbox(this);
#endif
@@ -118,7 +114,6 @@ QGCToolbox::~QGCToolbox()
delete _audioOutput;
delete _factSystem;
delete _firmwarePluginManager;
- delete _flightMapSettings;
delete _joystickManager;
delete _linkManager;
delete _mavlinkProtocol;
diff --git a/src/QGCToolbox.h b/src/QGCToolbox.h
index 762996fd522828ae76db1c10366cbdcc37774427..85d6a615191845c1e77f8466263cbc9b38e24bd4 100644
--- a/src/QGCToolbox.h
+++ b/src/QGCToolbox.h
@@ -15,7 +15,6 @@
class FactSystem;
class FirmwarePluginManager;
-class FlightMapSettings;
class GAudioOutput;
class GPSManager;
class JoystickManager;
@@ -42,7 +41,6 @@ public:
~QGCToolbox();
FirmwarePluginManager* firmwarePluginManager(void) { return _firmwarePluginManager; }
- FlightMapSettings* flightMapSettings(void) { return _flightMapSettings; }
GAudioOutput* audioOutput(void) { return _audioOutput; }
JoystickManager* joystickManager(void) { return _joystickManager; }
LinkManager* linkManager(void) { return _linkManager; }
@@ -71,7 +69,6 @@ private:
GAudioOutput* _audioOutput;
FactSystem* _factSystem;
FirmwarePluginManager* _firmwarePluginManager;
- FlightMapSettings* _flightMapSettings;
#ifndef __mobile__
GPSManager* _gpsManager;
#endif
diff --git a/src/QmlControls/QGroundControlQmlGlobal.cc b/src/QmlControls/QGroundControlQmlGlobal.cc
index 9a00807e0d4f8148b1e676b7fa03d2f1b65c4384..7152dde642faf991b02e47fb91f3a93c35bb5591 100644
--- a/src/QmlControls/QGroundControlQmlGlobal.cc
+++ b/src/QmlControls/QGroundControlQmlGlobal.cc
@@ -21,7 +21,6 @@ static const char* kQmlGlobalKeyName = "QGCQml";
QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app)
: QGCTool(app)
- , _flightMapSettings(NULL)
, _linkManager(NULL)
, _multiVehicleManager(NULL)
, _mapEngineManager(NULL)
@@ -47,7 +46,6 @@ void QGroundControlQmlGlobal::setToolbox(QGCToolbox* toolbox)
{
QGCTool::setToolbox(toolbox);
- _flightMapSettings = toolbox->flightMapSettings();
_linkManager = toolbox->linkManager();
_multiVehicleManager = toolbox->multiVehicleManager();
_mapEngineManager = toolbox->mapEngineManager();
diff --git a/src/QmlControls/QGroundControlQmlGlobal.h b/src/QmlControls/QGroundControlQmlGlobal.h
index 4f9ea6e82e92d7d9b83f1e1aad7d954ca0cc72d2..0914aaa69ad60da0e5bcf2824a3c5815bac16017 100644
--- a/src/QmlControls/QGroundControlQmlGlobal.h
+++ b/src/QmlControls/QGroundControlQmlGlobal.h
@@ -17,7 +17,6 @@
#include "QGCToolbox.h"
#include "QGCApplication.h"
#include "LinkManager.h"
-#include "FlightMapSettings.h"
#include "SettingsFact.h"
#include "FactMetaData.h"
#include "SimulatedPosition.h"
@@ -39,7 +38,6 @@ public:
Q_PROPERTY(QString appName READ appName CONSTANT)
- Q_PROPERTY(FlightMapSettings* flightMapSettings READ flightMapSettings CONSTANT)
Q_PROPERTY(LinkManager* linkManager READ linkManager CONSTANT)
Q_PROPERTY(MultiVehicleManager* multiVehicleManager READ multiVehicleManager CONSTANT)
Q_PROPERTY(QGCMapEngineManager* mapEngineManager READ mapEngineManager CONSTANT)
@@ -126,7 +124,6 @@ public:
// Property accesors
QString appName () { return qgcApp()->applicationName(); }
- FlightMapSettings* flightMapSettings () { return _flightMapSettings; }
LinkManager* linkManager () { return _linkManager; }
MultiVehicleManager* multiVehicleManager () { return _multiVehicleManager; }
QGCMapEngineManager* mapEngineManager () { return _mapEngineManager; }
@@ -172,7 +169,6 @@ signals:
void skipSetupPageChanged ();
private:
- FlightMapSettings* _flightMapSettings;
LinkManager* _linkManager;
MultiVehicleManager* _multiVehicleManager;
QGCMapEngineManager* _mapEngineManager;
diff --git a/src/QtLocationPlugin/QMLControl/OfflineMap.qml b/src/QtLocationPlugin/QMLControl/OfflineMap.qml
index 6fc91a610daff0b2c9884fc8cad0a68a75e41139..5bd45f92ffcf5cdf0b2afb231e18984a22e823f3 100644
--- a/src/QtLocationPlugin/QMLControl/OfflineMap.qml
+++ b/src/QtLocationPlugin/QMLControl/OfflineMap.qml
@@ -31,7 +31,7 @@ QGCView {
property string mapKey: "lastMapType"
- property string mapType: QGroundControl.flightMapSettings.mapProvider + " " + QGroundControl.flightMapSettings.mapType
+ property string mapType: _settings.mapProvider.enumStringValue + " " + _settings.mapType.enumStringValue
property bool isMapInteractive: false
property var savedCenter: undefined
property real savedZoom: 3
@@ -47,6 +47,7 @@ QGCView {
property var _mapAdjustedColor: _map.isSatelliteMap ? "white" : "black"
property bool _tooManyTiles: QGroundControl.mapEngineManager.tileCount > _maxTilesForDownload
+ property var _settings: QGroundControl.settingsManager.flightMapSettings
readonly property real minZoomLevel: 3
readonly property real maxZoomLevel: 20
@@ -97,7 +98,7 @@ QGCView {
function addNewSet() {
isMapInteractive = true
- mapType = QGroundControl.flightMapSettings.mapProvider + " " + QGroundControl.flightMapSettings.mapType
+ mapType = _settings.mapProvider.enumStringValue + " " + _settings.mapType.enumStringValue
resetMapToDefaults()
handleChanges()
_map.visible = true
diff --git a/src/Settings/FlightMap.SettingsGroup.json b/src/Settings/FlightMap.SettingsGroup.json
new file mode 100644
index 0000000000000000000000000000000000000000..f76bf56fde93d407a5752a82c2db19527610e6bc
--- /dev/null
+++ b/src/Settings/FlightMap.SettingsGroup.json
@@ -0,0 +1,18 @@
+[
+{
+ "name": "MapProvider",
+ "shortDescription": "Currently selected map provider for flight maps",
+ "type": "uint32",
+ "enumStrings": "Bing,Google,Statkart",
+ "enumValues": "0,1,2",
+ "defaultValue": 0
+},
+{
+ "name": "MapType",
+ "shortDescription": "Currently selected map type for flight maps",
+ "type": "uint32",
+ "enumStrings": "Street Map,Satellite Map,Hybrid Map,Terrain Map",
+ "enumValues": "0,1,2,3",
+ "defaultValue": 2
+}
+]
diff --git a/src/Settings/FlightMapSettings.cc b/src/Settings/FlightMapSettings.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e904f18f2040c4622770e6e8c4cdc1397598fdc7
--- /dev/null
+++ b/src/Settings/FlightMapSettings.cc
@@ -0,0 +1,116 @@
+/****************************************************************************
+ *
+ * (c) 2009-2016 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+#include "FlightMapSettings.h"
+
+#include
+#include
+
+const char* FlightMapSettings::flightMapSettingsGroupName = "FlightMap";
+const char* FlightMapSettings::mapProviderSettingsName = "MapProvider";
+const char* FlightMapSettings::mapTypeSettingsName = "MapType";
+const char* FlightMapSettings::_settingsGroupName = "FlightMap";
+
+FlightMapSettings::FlightMapSettings(QObject* parent)
+ : SettingsGroup(flightMapSettingsGroupName, QString(_settingsGroupName) /* root settings group */, parent)
+ , _mapProviderFact(NULL)
+ , _mapTypeFact(NULL)
+{
+ QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
+ qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "FlightMapSettings", "Reference only");
+
+ // Save the original version since we modify based on map provider
+ _savedMapTypeStrings = _nameToMetaDataMap[mapTypeSettingsName]->enumStrings();
+ _savedMapTypeValues = _nameToMetaDataMap[mapTypeSettingsName]->enumValues();
+
+#ifdef QGC_NO_GOOGLE_MAPS
+ // Find google in the list and remove it
+ FactMetaData* metaData = _nameToMetaDataMap[mapProviderSettingsName];
+ QVariantList enumValues = metaData->enumValues();
+ QStringList enumStrings = metaData->enumStrings();
+ _removeEnumValue(mapProviderGoogle, enumStrings, enumValues);
+ metaData->setEnumInfo(enumStrings, enumValues);
+#endif
+
+ _newMapProvider(mapProvider()->rawValue());
+}
+
+Fact* FlightMapSettings::mapProvider(void)
+{
+ if (!_mapProviderFact) {
+ _mapProviderFact = _createSettingsFact(mapProviderSettingsName);
+ connect(_mapProviderFact, &Fact::rawValueChanged, this, &FlightMapSettings::_newMapProvider);
+ }
+
+ return _mapProviderFact;
+}
+
+Fact* FlightMapSettings::mapType(void)
+{
+ if (!_mapTypeFact) {
+ _mapTypeFact = _createSettingsFact(mapTypeSettingsName);
+ }
+
+ return _mapTypeFact;
+}
+
+void FlightMapSettings::_removeEnumValue(int value, QStringList& enumStrings, QVariantList& enumValues)
+{
+ bool found = false;
+ int removeIndex;
+ for (removeIndex=0; removeIndexsetEnumInfo(enumStrings, enumValues);
+ emit mapTypeChanged();
+
+ // Check that map type is still valid for this new map provider
+
+ bool found = false;
+ int currentMapType = mapType()->rawValue().toInt();
+ for (int i=0; isetRawValue(0);
+ }
+}
diff --git a/src/Settings/FlightMapSettings.h b/src/Settings/FlightMapSettings.h
new file mode 100644
index 0000000000000000000000000000000000000000..85c7ea623fea78176da862a6054c5600baca50b3
--- /dev/null
+++ b/src/Settings/FlightMapSettings.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+ *
+ * (c) 2009-2016 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+#ifndef FlightMapSettings_H
+#define FlightMapSettings_H
+
+#include "SettingsGroup.h"
+
+class FlightMapSettings : public SettingsGroup
+{
+ Q_OBJECT
+
+public:
+ FlightMapSettings(QObject* parent = NULL);
+
+ // This enum must match the json meta data
+ typedef enum {
+ mapProviderBing,
+ mapProviderGoogle,
+ mapProviderStarkart
+ } MapProvider_t;
+
+ // This enum must match the json meta data
+ typedef enum {
+ mapTypeStreet,
+ mapTypeSatellite,
+ mapTypeHybrid,
+ mapTypeTerrain
+ } MapType_t;
+
+ Q_PROPERTY(Fact* mapProvider READ mapProvider CONSTANT) ///< Currently selected map provider
+ Q_PROPERTY(Fact* mapType READ mapType NOTIFY mapTypeChanged) ///< Current selected map type
+
+ Fact* mapProvider (void);
+ Fact* mapType (void);
+
+ static const char* flightMapSettingsGroupName;
+ static const char* mapProviderSettingsName;
+ static const char* mapTypeSettingsName;
+
+signals:
+ void mapTypeChanged(void);
+
+private slots:
+ void _newMapProvider(QVariant value);
+
+private:
+ void _removeEnumValue(int value, QStringList& enumStrings, QVariantList& enumValues);
+
+ SettingsFact* _mapProviderFact;
+ SettingsFact* _mapTypeFact;
+ QStringList _savedMapTypeStrings;
+ QVariantList _savedMapTypeValues;
+
+ static const char* _settingsGroupName;
+};
+
+#endif
diff --git a/src/Settings/SettingsManager.cc b/src/Settings/SettingsManager.cc
index 226976f28e2d7b9ca33940b211a483fa2739d4f9..11f913e8b9f6845a2f4a1c019042b86d85405266 100644
--- a/src/Settings/SettingsManager.cc
+++ b/src/Settings/SettingsManager.cc
@@ -18,6 +18,7 @@ SettingsManager::SettingsManager(QGCApplication* app)
, _unitsSettings(NULL)
, _autoConnectSettings(NULL)
, _videoSettings(NULL)
+ , _flightMapSettings(NULL)
{
}
@@ -32,4 +33,5 @@ void SettingsManager::setToolbox(QGCToolbox *toolbox)
_appSettings = new AppSettings(this);
_autoConnectSettings = new AutoConnectSettings(this);
_videoSettings = new VideoSettings(this);
+ _flightMapSettings = new FlightMapSettings(this);
}
diff --git a/src/Settings/SettingsManager.h b/src/Settings/SettingsManager.h
index 40e67555c4a1881ec96c3a2b2a8de5c1e2c690ff..ec65d9bd13762d20c48f711828ec96e4fe2812f3 100644
--- a/src/Settings/SettingsManager.h
+++ b/src/Settings/SettingsManager.h
@@ -18,6 +18,7 @@
#include "UnitsSettings.h"
#include "AutoConnectSettings.h"
#include "VideoSettings.h"
+#include "FlightMapSettings.h"
#include
@@ -33,6 +34,7 @@ public:
Q_PROPERTY(QObject* unitsSettings READ unitsSettings CONSTANT)
Q_PROPERTY(QObject* autoConnectSettings READ autoConnectSettings CONSTANT)
Q_PROPERTY(QObject* videoSettings READ videoSettings CONSTANT)
+ Q_PROPERTY(QObject* flightMapSettings READ flightMapSettings CONSTANT)
// Override from QGCTool
virtual void setToolbox(QGCToolbox *toolbox);
@@ -41,12 +43,14 @@ public:
UnitsSettings* unitsSettings (void) { return _unitsSettings; }
AutoConnectSettings* autoConnectSettings (void) { return _autoConnectSettings; }
VideoSettings* videoSettings (void) { return _videoSettings; }
+ FlightMapSettings* flightMapSettings (void) { return _flightMapSettings; }
private:
AppSettings* _appSettings;
UnitsSettings* _unitsSettings;
AutoConnectSettings* _autoConnectSettings;
VideoSettings* _videoSettings;
+ FlightMapSettings* _flightMapSettings;
};
#endif
diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml
index 6ca4a16c84d07b2a40fb434c2757d26db357990f..0d6e9ac31230a80df1dce7607fdf3f7971c75428 100644
--- a/src/ui/preferences/GeneralSettings.qml
+++ b/src/ui/preferences/GeneralSettings.qml
@@ -39,6 +39,8 @@ QGCView {
property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 30
property Fact _telemPath: QGroundControl.settingsManager.appSettings.telemetrySavePath
property Fact _videoPath: QGroundControl.settingsManager.videoSettings.videoSavePath
+ property Fact _mapProvider: QGroundControl.settingsManager.flightMapSettings.mapProvider
+ property Fact _mapType: QGroundControl.settingsManager.flightMapSettings.mapType
readonly property string _requiresRestart: qsTr("(Requires Restart)")
@@ -375,39 +377,49 @@ QGCView {
}
}
}
+
//-----------------------------------------------------------------
- //-- Map Providers
+ //-- Map Provider
Row {
- /*
- TODO: Map settings should come from QGroundControl.mapEngineManager. What is currently in
- QGroundControl.flightMapSettings should be moved there so all map related funtions are in
- one place.
- */
spacing: ScreenTools.defaultFontPixelWidth
- visible: QGroundControl.flightMapSettings.googleMapEnabled
+ visible: _mapProvider.visible
+
QGCLabel {
- id: mapProvidersLabel
anchors.baseline: mapProviders.baseline
text: qsTr("Map Provider:")
width: _labelWidth
}
- QGCComboBox {
- id: mapProviders
- width: _editFieldWidth
- model: QGroundControl.flightMapSettings.mapProviders
- Component.onCompleted: {
- var index = mapProviders.find(QGroundControl.flightMapSettings.mapProvider)
- if (index < 0) {
- console.warn(qsTr("Active map provider not in combobox"), QGroundControl.flightMapSettings.mapProvider)
- } else {
- mapProviders.currentIndex = index
- }
- }
- onActivated: {
- if (index != -1) {
- currentIndex = index
- console.log(qsTr("New map provider: ") + model[index])
- QGroundControl.flightMapSettings.mapProvider = model[index]
+
+ FactComboBox {
+ id: mapProviders
+ width: _editFieldWidth
+ fact: _mapProvider
+ indexModel: false
+ }
+ }
+
+ //-----------------------------------------------------------------
+ //-- Map Type
+ Row {
+ spacing: ScreenTools.defaultFontPixelWidth
+ visible: _mapType.visible
+
+ QGCLabel {
+ anchors.baseline: mapTypes.baseline
+ text: qsTr("Map Type:")
+ width: _labelWidth
+ }
+
+ FactComboBox {
+ id: mapTypes
+ width: _editFieldWidth
+ fact: _mapType
+ indexModel: false
+
+ Connections {
+ target: QGroundControl.settingsManager.flightMapSettings
+ onMapTypeChanged: {
+ mapTypes.model = _mapType.enumStrings
}
}
}