Commit 50984522 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4830 from DonLakeFlyer/MapType

Map provider and type move to SettingsManager
parents 98b317d3 31ab9fff
...@@ -443,7 +443,6 @@ HEADERS += \ ...@@ -443,7 +443,6 @@ HEADERS += \
src/CmdLineOptParser.h \ src/CmdLineOptParser.h \
src/FirmwarePlugin/PX4/px4_custom_mode.h \ src/FirmwarePlugin/PX4/px4_custom_mode.h \
src/FlightDisplay/VideoManager.h \ src/FlightDisplay/VideoManager.h \
src/FlightMap/FlightMapSettings.h \
src/FlightMap/Widgets/ValuesWidgetController.h \ src/FlightMap/Widgets/ValuesWidgetController.h \
src/FollowMe/FollowMe.h \ src/FollowMe/FollowMe.h \
src/GAudioOutput.h \ src/GAudioOutput.h \
...@@ -502,6 +501,7 @@ HEADERS += \ ...@@ -502,6 +501,7 @@ HEADERS += \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \ src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \
src/Settings/AppSettings.h \ src/Settings/AppSettings.h \
src/Settings/AutoConnectSettings.h \ src/Settings/AutoConnectSettings.h \
src/Settings/FlightMapSettings.h \
src/Settings/SettingsGroup.h \ src/Settings/SettingsGroup.h \
src/Settings/SettingsManager.h \ src/Settings/SettingsManager.h \
src/Settings/UnitsSettings.h \ src/Settings/UnitsSettings.h \
...@@ -622,7 +622,6 @@ SOURCES += \ ...@@ -622,7 +622,6 @@ SOURCES += \
src/AnalyzeView/ExifParser.cc \ src/AnalyzeView/ExifParser.cc \
src/CmdLineOptParser.cc \ src/CmdLineOptParser.cc \
src/FlightDisplay/VideoManager.cc \ src/FlightDisplay/VideoManager.cc \
src/FlightMap/FlightMapSettings.cc \
src/FlightMap/Widgets/ValuesWidgetController.cc \ src/FlightMap/Widgets/ValuesWidgetController.cc \
src/FollowMe/FollowMe.cc \ src/FollowMe/FollowMe.cc \
src/GAudioOutput.cc \ src/GAudioOutput.cc \
...@@ -678,6 +677,7 @@ SOURCES += \ ...@@ -678,6 +677,7 @@ SOURCES += \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \ src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \
src/Settings/AppSettings.cc \ src/Settings/AppSettings.cc \
src/Settings/AutoConnectSettings.cc \ src/Settings/AutoConnectSettings.cc \
src/Settings/FlightMapSettings.cc \
src/Settings/SettingsGroup.cc \ src/Settings/SettingsGroup.cc \
src/Settings/SettingsManager.cc \ src/Settings/SettingsManager.cc \
src/Settings/UnitsSettings.cc \ src/Settings/UnitsSettings.cc \
......
...@@ -188,6 +188,7 @@ ...@@ -188,6 +188,7 @@
<file alias="MavCmdInfoVTOL.json">src/MissionManager/MavCmdInfoVTOL.json</file> <file alias="MavCmdInfoVTOL.json">src/MissionManager/MavCmdInfoVTOL.json</file>
<file alias="App.SettingsGroup.json">src/Settings/App.SettingsGroup.json</file> <file alias="App.SettingsGroup.json">src/Settings/App.SettingsGroup.json</file>
<file alias="AutoConnect.SettingsGroup.json">src/Settings/AutoConnect.SettingsGroup.json</file> <file alias="AutoConnect.SettingsGroup.json">src/Settings/AutoConnect.SettingsGroup.json</file>
<file alias="FlightMap.SettingsGroup.json">src/Settings/FlightMap.SettingsGroup.json</file>
<file alias="Survey.SettingsGroup.json">src/MissionManager/Survey.SettingsGroup.json</file> <file alias="Survey.SettingsGroup.json">src/MissionManager/Survey.SettingsGroup.json</file>
<file alias="Units.SettingsGroup.json">src/Settings/Units.SettingsGroup.json</file> <file alias="Units.SettingsGroup.json">src/Settings/Units.SettingsGroup.json</file>
<file alias="Video.SettingsGroup.json">src/Settings/Video.SettingsGroup.json</file> <file alias="Video.SettingsGroup.json">src/Settings/Video.SettingsGroup.json</file>
......
...@@ -164,7 +164,7 @@ FlightMap { ...@@ -164,7 +164,7 @@ FlightMap {
color: qgcPal.window color: qgcPal.window
title: qsTr("Fly") title: qsTr("Fly")
z: QGroundControl.zOrderWidgets 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 maxHeight: (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y // Massive reach across hack
property bool _showZoom: !ScreenTools.isMobile property bool _showZoom: !ScreenTools.isMobile
...@@ -175,11 +175,6 @@ FlightMap { ...@@ -175,11 +175,6 @@ FlightMap {
iconSource: "/qmlimages/MapCenter.svg", iconSource: "/qmlimages/MapCenter.svg",
dropPanelComponent: centerMapDropPanel dropPanelComponent: centerMapDropPanel
}, },
{
name: "Map",
iconSource: "/qmlimages/MapType.svg",
dropPanelComponent: mapTypeDropPanel
},
{ {
name: "In", name: "In",
iconSource: "/qmlimages/ZoomPlus.svg" iconSource: "/qmlimages/ZoomPlus.svg"
...@@ -229,33 +224,6 @@ FlightMap { ...@@ -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 // Add trajectory points to the map
MapItemView { MapItemView {
model: _mainIsMap ? _activeVehicle ? _activeVehicle.trajectoryPoints : 0 : 0 model: _mainIsMap ? _activeVehicle ? _activeVehicle.trajectoryPoints : 0 : 0
......
...@@ -85,7 +85,8 @@ Map { ...@@ -85,7 +85,8 @@ Map {
} }
function updateActiveMapType() { 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++) { for (var i = 0; i < _map.supportedMapTypes.length; i++) {
if (fullMapName === _map.supportedMapTypes[i].name) { if (fullMapName === _map.supportedMapTypes[i].name) {
_map.activeMapType = _map.supportedMapTypes[i] _map.activeMapType = _map.supportedMapTypes[i]
...@@ -97,8 +98,13 @@ Map { ...@@ -97,8 +98,13 @@ Map {
Component.onCompleted: updateActiveMapType() Component.onCompleted: updateActiveMapType()
Connections { Connections {
target: QGroundControl.flightMapSettings target: QGroundControl.settingsManager.flightMapSettings.mapType
onMapTypeChanged: updateActiveMapType() onRawValueChanged: updateActiveMapType()
}
Connections {
target: QGroundControl.settingsManager.flightMapSettings.mapProvider
onRawValueChanged: updateActiveMapType()
} }
/// Ground Station location /// Ground Station location
......
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "FlightMapSettings.h"
#include <QSettings>
#include <QtQml>
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<FlightMapSettings> ("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();
}
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* 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 <QObject>
#include <QStringList>
/*
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
...@@ -678,11 +678,11 @@ QGCView { ...@@ -678,11 +678,11 @@ QGCView {
color: qgcPal.window color: qgcPal.window
title: qsTr("Plan") title: qsTr("Plan")
z: QGroundControl.zOrderWidgets z: QGroundControl.zOrderWidgets
showAlternateIcon: [ false, false, _syncDropDownController.dirty, false, false, false, false ] showAlternateIcon: [ false, false, _syncDropDownController.dirty, false, false, false ]
rotateImage: [ false, false, _syncDropDownController.syncInProgress, false, false, false, false ] rotateImage: [ false, false, _syncDropDownController.syncInProgress, false, false, false ]
animateImage: [ false, false, _syncDropDownController.dirty, false, false, false, false ] animateImage: [ false, false, _syncDropDownController.dirty, false, false, false ]
buttonEnabled: [ true, true, !_syncDropDownController.syncInProgress, true, true, true, true ] buttonEnabled: [ true, true, !_syncDropDownController.syncInProgress, true, true, true ]
buttonVisible: [ true, true, true, true, true, _showZoom, _showZoom ] buttonVisible: [ true, true, true, true, _showZoom, _showZoom ]
maxHeight: mapScale.y - toolStrip.y maxHeight: mapScale.y - toolStrip.y
property bool _showZoom: !ScreenTools.isMobile property bool _showZoom: !ScreenTools.isMobile
...@@ -709,11 +709,6 @@ QGCView { ...@@ -709,11 +709,6 @@ QGCView {
iconSource: "/qmlimages/MapCenter.svg", iconSource: "/qmlimages/MapCenter.svg",
dropPanelComponent: centerMapDropPanel dropPanelComponent: centerMapDropPanel
}, },
{
name: "Map",
iconSource: "/qmlimages/MapType.svg",
dropPanelComponent: mapTypeDropPanel
},
{ {
name: "In", name: "In",
iconSource: "/qmlimages/ZoomPlus.svg" iconSource: "/qmlimages/ZoomPlus.svg"
...@@ -903,34 +898,6 @@ QGCView { ...@@ -903,34 +898,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 { Component {
id: patternDropPanel id: patternDropPanel
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "FactSystem.h" #include "FactSystem.h"
#include "FirmwarePluginManager.h" #include "FirmwarePluginManager.h"
#include "FlightMapSettings.h"
#include "GAudioOutput.h" #include "GAudioOutput.h"
#ifndef __mobile__ #ifndef __mobile__
#include "GPSManager.h" #include "GPSManager.h"
...@@ -39,7 +38,6 @@ QGCToolbox::QGCToolbox(QGCApplication* app) ...@@ -39,7 +38,6 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
: _audioOutput(NULL) : _audioOutput(NULL)
, _factSystem(NULL) , _factSystem(NULL)
, _firmwarePluginManager(NULL) , _firmwarePluginManager(NULL)
, _flightMapSettings(NULL)
#ifndef __mobile__ #ifndef __mobile__
, _gpsManager(NULL) , _gpsManager(NULL)
#endif #endif
...@@ -66,7 +64,6 @@ QGCToolbox::QGCToolbox(QGCApplication* app) ...@@ -66,7 +64,6 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
_audioOutput = new GAudioOutput(app); _audioOutput = new GAudioOutput(app);
_factSystem = new FactSystem(app); _factSystem = new FactSystem(app);
_firmwarePluginManager = new FirmwarePluginManager(app); _firmwarePluginManager = new FirmwarePluginManager(app);
_flightMapSettings = new FlightMapSettings(app);
#ifndef __mobile__ #ifndef __mobile__
_gpsManager = new GPSManager(app); _gpsManager = new GPSManager(app);
#endif #endif
...@@ -93,7 +90,6 @@ void QGCToolbox::setChildToolboxes(void) ...@@ -93,7 +90,6 @@ void QGCToolbox::setChildToolboxes(void)
_audioOutput->setToolbox(this); _audioOutput->setToolbox(this);
_factSystem->setToolbox(this); _factSystem->setToolbox(this);
_firmwarePluginManager->setToolbox(this); _firmwarePluginManager->setToolbox(this);
_flightMapSettings->setToolbox(this);
#ifndef __mobile__ #ifndef __mobile__
_gpsManager->setToolbox(this); _gpsManager->setToolbox(this);
#endif #endif
...@@ -118,7 +114,6 @@ QGCToolbox::~QGCToolbox() ...@@ -118,7 +114,6 @@ QGCToolbox::~QGCToolbox()
delete _audioOutput; delete _audioOutput;
delete _factSystem; delete _factSystem;
delete _firmwarePluginManager; delete _firmwarePluginManager;
delete _flightMapSettings;
delete _joystickManager; delete _joystickManager;
delete _linkManager; delete _linkManager;
delete _mavlinkProtocol; delete _mavlinkProtocol;
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
class FactSystem; class FactSystem;
class FirmwarePluginManager; class FirmwarePluginManager;
class FlightMapSettings;
class GAudioOutput; class GAudioOutput;
class GPSManager; class GPSManager;
class JoystickManager; class JoystickManager;
...@@ -42,7 +41,6 @@ public: ...@@ -42,7 +41,6 @@ public:
~QGCToolbox(); ~QGCToolbox();
FirmwarePluginManager* firmwarePluginManager(void) { return _firmwarePluginManager; } FirmwarePluginManager* firmwarePluginManager(void) { return _firmwarePluginManager; }
FlightMapSettings* flightMapSettings(void) { return _flightMapSettings; }
GAudioOutput* audioOutput(void) { return _audioOutput; } GAudioOutput* audioOutput(void) { return _audioOutput; }
JoystickManager* joystickManager(void) { return _joystickManager; } JoystickManager* joystickManager(void) { return _joystickManager; }
LinkManager* linkManager(void) { return _linkManager; } LinkManager* linkManager(void) { return _linkManager; }
...@@ -71,7 +69,6 @@ private: ...@@ -71,7 +69,6 @@ private:
GAudioOutput* _audioOutput; GAudioOutput* _audioOutput;
FactSystem* _factSystem; FactSystem* _factSystem;
FirmwarePluginManager* _firmwarePluginManager; FirmwarePluginManager* _firmwarePluginManager;
FlightMapSettings* _flightMapSettings;
#ifndef __mobile__ #ifndef __mobile__
GPSManager* _gpsManager; GPSManager* _gpsManager;
#endif #endif
......
...@@ -21,7 +21,6 @@ static const char* kQmlGlobalKeyName = "QGCQml"; ...@@ -21,7 +21,6 @@ static const char* kQmlGlobalKeyName = "QGCQml";
QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app) QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app)
: QGCTool(app) : QGCTool(app)
, _flightMapSettings(NULL)
, _linkManager(NULL) , _linkManager(NULL)
, _multiVehicleManager(NULL) , _multiVehicleManager(NULL)
, _mapEngineManager(NULL) , _mapEngineManager(NULL)
...@@ -47,7 +46,6 @@ void QGroundControlQmlGlobal::setToolbox(QGCToolbox* toolbox) ...@@ -47,7 +46,6 @@ void QGroundControlQmlGlobal::setToolbox(QGCToolbox* toolbox)
{ {
QGCTool::setToolbox(toolbox); QGCTool::setToolbox(toolbox);
_flightMapSettings = toolbox->flightMapSettings();
_linkManager = toolbox->linkManager(); _linkManager = toolbox->linkManager();
_multiVehicleManager = toolbox->multiVehicleManager(); _multiVehicleManager = toolbox->multiVehicleManager();
_mapEngineManager = toolbox->mapEngineManager(); _mapEngineManager = toolbox->mapEngineManager();
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "QGCToolbox.h" #include "QGCToolbox.h"
#include "QGCApplication.h" #include "QGCApplication.h"
#include "LinkManager.h" #include "LinkManager.h"
#include "FlightMapSettings.h"
#include "SettingsFact.h" #include "SettingsFact.h"
#include "FactMetaData.h" #include "FactMetaData.h"
#include "SimulatedPosition.h" #include "SimulatedPosition.h"
...@@ -39,7 +38,6 @@ public: ...@@ -39,7 +38,6 @@ public:
Q_PROPERTY(QString appName READ appName CONSTANT) Q_PROPERTY(QString appName READ appName CONSTANT)
Q_PROPERTY(FlightMapSettings* flightMapSettings READ flightMapSettings CONSTANT)
Q_PROPERTY(LinkManager* linkManager READ linkManager CONSTANT) Q_PROPERTY(LinkManager* linkManager READ linkManager CONSTANT)
Q_PROPERTY(MultiVehicleManager* multiVehicleManager READ multiVehicleManager CONSTANT) Q_PROPERTY(MultiVehicleManager* multiVehicleManager READ multiVehicleManager CONSTANT)
Q_PROPERTY(QGCMapEngineManager* mapEngineManager READ mapEngineManager CONSTANT) Q_PROPERTY(QGCMapEngineManager* mapEngineManager READ mapEngineManager CONSTANT)
...@@ -126,7 +124,6 @@ public: ...@@ -126,7 +124,6 @@ public:
// Property accesors // Property accesors
QString appName () { return qgcApp()->applicationName(); } QString appName () { return qgcApp()->applicationName(); }
FlightMapSettings* flightMapSettings () { return _flightMapSettings; }
LinkManager* linkManager () { return _linkManager; } LinkManager* linkManager () { return _linkManager; }
MultiVehicleManager* multiVehicleManager () { return _multiVehicleManager; } MultiVehicleManager* multiVehicleManager () { return _multiVehicleManager; }
QGCMapEngineManager* mapEngineManager () { return _mapEngineManager; } QGCMapEngineManager* mapEngineManager () { return _mapEngineManager; }
...@@ -172,7 +169,6 @@ signals: ...@@ -172,7 +169,6 @@ signals:
void skipSetupPageChanged (); void skipSetupPageChanged ();
private: private:
FlightMapSettings* _flightMapSettings;
LinkManager* _linkManager; LinkManager* _linkManager;
MultiVehicleManager* _multiVehicleManager; MultiVehicleManager* _multiVehicleManager;
QGCMapEngineManager* _mapEngineManager; QGCMapEngineManager* _mapEngineManager;
......
...@@ -31,7 +31,7 @@ QGCView { ...@@ -31,7 +31,7 @@ QGCView {
property string mapKey: "lastMapType" 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 bool isMapInteractive: false
property var savedCenter: undefined property var savedCenter: undefined
property real savedZoom: 3 property real savedZoom: 3
...@@ -47,6 +47,7 @@ QGCView { ...@@ -47,6 +47,7 @@ QGCView {
property var _mapAdjustedColor: _map.isSatelliteMap ? "white" : "black" property var _mapAdjustedColor: _map.isSatelliteMap ? "white" : "black"
property bool _tooManyTiles: QGroundControl.mapEngineManager.tileCount > _maxTilesForDownload property bool _tooManyTiles: QGroundControl.mapEngineManager.tileCount > _maxTilesForDownload
property var _settings: QGroundControl.settingsManager.flightMapSettings
readonly property real minZoomLevel: 3 readonly property real minZoomLevel: 3
readonly property real maxZoomLevel: 20 readonly property real maxZoomLevel: 20
...@@ -97,7 +98,7 @@ QGCView { ...@@ -97,7 +98,7 @@ QGCView {
function addNewSet() { function addNewSet() {
isMapInteractive = true isMapInteractive = true
mapType = QGroundControl.flightMapSettings.mapProvider + " " + QGroundControl.flightMapSettings.mapType mapType = _settings.mapProvider.enumStringValue + " " + _settings.mapType.enumStringValue
resetMapToDefaults() resetMapToDefaults()
handleChanges() handleChanges()
_map.visible = true _map.visible = true
......
[
{
"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
}
]
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "FlightMapSettings.h"
#include <QQmlEngine>
#include <QtQml>
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<FlightMapSettings>("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; removeIndex<enumValues.count(); removeIndex++) {
if (enumValues[removeIndex].toInt() == value) {
found = true;
break;
}
}
if (found) {
enumValues.removeAt(removeIndex);
enumStrings.removeAt(removeIndex);
}
}
void FlightMapSettings::_newMapProvider(QVariant value)
{
FactMetaData* metaData = _nameToMetaDataMap[mapTypeSettingsName];
QStringList enumStrings = _savedMapTypeStrings;
QVariantList enumValues = _savedMapTypeValues;
switch (value.toInt()) {
case mapProviderBing:
_removeEnumValue(mapTypeTerrain, enumStrings, enumValues);
break;
case mapProviderGoogle:
_removeEnumValue(mapTypeHybrid, enumStrings, enumValues);
break;
case mapProviderStarkart:
_removeEnumValue(mapTypeStreet, enumStrings, enumValues);
_removeEnumValue(mapTypeSatellite, enumStrings, enumValues);
_removeEnumValue(mapTypeHybrid, enumStrings, enumValues);
break;
}
metaData->setEnumInfo(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; i<enumValues.count(); i++) {
if (currentMapType == enumValues[i].toInt()) {
found = true;
break;
}
}
if (!found) {
mapType()->setRawValue(0);
}
}
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* 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
...@@ -18,6 +18,7 @@ SettingsManager::SettingsManager(QGCApplication* app) ...@@ -18,6 +18,7 @@ SettingsManager::SettingsManager(QGCApplication* app)
, _unitsSettings(NULL) , _unitsSettings(NULL)
, _autoConnectSettings(NULL) , _autoConnectSettings(NULL)
, _videoSettings(NULL) , _videoSettings(NULL)
, _flightMapSettings(NULL)
{ {
} }
...@@ -32,4 +33,5 @@ void SettingsManager::setToolbox(QGCToolbox *toolbox) ...@@ -32,4 +33,5 @@ void SettingsManager::setToolbox(QGCToolbox *toolbox)
_appSettings = new AppSettings(this); _appSettings = new AppSettings(this);
_autoConnectSettings = new AutoConnectSettings(this); _autoConnectSettings = new AutoConnectSettings(this);
_videoSettings = new VideoSettings(this); _videoSettings = new VideoSettings(this);
_flightMapSettings = new FlightMapSettings(this);
} }
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "UnitsSettings.h" #include "UnitsSettings.h"
#include "AutoConnectSettings.h" #include "AutoConnectSettings.h"
#include "VideoSettings.h" #include "VideoSettings.h"
#include "FlightMapSettings.h"
#include <QVariantList> #include <QVariantList>
...@@ -33,6 +34,7 @@ public: ...@@ -33,6 +34,7 @@ public:
Q_PROPERTY(QObject* unitsSettings READ unitsSettings CONSTANT) Q_PROPERTY(QObject* unitsSettings READ unitsSettings CONSTANT)
Q_PROPERTY(QObject* autoConnectSettings READ autoConnectSettings CONSTANT) Q_PROPERTY(QObject* autoConnectSettings READ autoConnectSettings CONSTANT)
Q_PROPERTY(QObject* videoSettings READ videoSettings CONSTANT) Q_PROPERTY(QObject* videoSettings READ videoSettings CONSTANT)
Q_PROPERTY(QObject* flightMapSettings READ flightMapSettings CONSTANT)
// Override from QGCTool // Override from QGCTool
virtual void setToolbox(QGCToolbox *toolbox); virtual void setToolbox(QGCToolbox *toolbox);
...@@ -41,12 +43,14 @@ public: ...@@ -41,12 +43,14 @@ public:
UnitsSettings* unitsSettings (void) { return _unitsSettings; } UnitsSettings* unitsSettings (void) { return _unitsSettings; }
AutoConnectSettings* autoConnectSettings (void) { return _autoConnectSettings; } AutoConnectSettings* autoConnectSettings (void) { return _autoConnectSettings; }
VideoSettings* videoSettings (void) { return _videoSettings; } VideoSettings* videoSettings (void) { return _videoSettings; }
FlightMapSettings* flightMapSettings (void) { return _flightMapSettings; }
private: private:
AppSettings* _appSettings; AppSettings* _appSettings;
UnitsSettings* _unitsSettings; UnitsSettings* _unitsSettings;
AutoConnectSettings* _autoConnectSettings; AutoConnectSettings* _autoConnectSettings;
VideoSettings* _videoSettings; VideoSettings* _videoSettings;
FlightMapSettings* _flightMapSettings;
}; };
#endif #endif
...@@ -39,6 +39,8 @@ QGCView { ...@@ -39,6 +39,8 @@ QGCView {
property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 30 property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 30
property Fact _telemPath: QGroundControl.settingsManager.appSettings.telemetrySavePath property Fact _telemPath: QGroundControl.settingsManager.appSettings.telemetrySavePath
property Fact _videoPath: QGroundControl.settingsManager.videoSettings.videoSavePath 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)") readonly property string _requiresRestart: qsTr("(Requires Restart)")
...@@ -375,39 +377,49 @@ QGCView { ...@@ -375,39 +377,49 @@ QGCView {
} }
} }
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Map Providers //-- Map Provider
Row { 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 spacing: ScreenTools.defaultFontPixelWidth
visible: QGroundControl.flightMapSettings.googleMapEnabled visible: _mapProvider.visible
QGCLabel { QGCLabel {
id: mapProvidersLabel
anchors.baseline: mapProviders.baseline anchors.baseline: mapProviders.baseline
text: qsTr("Map Provider:") text: qsTr("Map Provider:")
width: _labelWidth width: _labelWidth
} }
QGCComboBox {
id: mapProviders FactComboBox {
width: _editFieldWidth id: mapProviders
model: QGroundControl.flightMapSettings.mapProviders width: _editFieldWidth
Component.onCompleted: { fact: _mapProvider
var index = mapProviders.find(QGroundControl.flightMapSettings.mapProvider) indexModel: false
if (index < 0) { }
console.warn(qsTr("Active map provider not in combobox"), QGroundControl.flightMapSettings.mapProvider) }
} else {
mapProviders.currentIndex = index //-----------------------------------------------------------------
} //-- Map Type
} Row {
onActivated: { spacing: ScreenTools.defaultFontPixelWidth
if (index != -1) { visible: _mapType.visible
currentIndex = index
console.log(qsTr("New map provider: ") + model[index]) QGCLabel {
QGroundControl.flightMapSettings.mapProvider = model[index] 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
} }
} }
} }
......
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