Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
5ef80c52
Commit
5ef80c52
authored
May 15, 2017
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Esri and MapBox tokens to AppSettings.
parent
c7a9943c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
73 additions
and
103 deletions
+73
-103
QGCMapEngine.cpp
src/QtLocationPlugin/QGCMapEngine.cpp
+5
-44
QGCMapEngine.h
src/QtLocationPlugin/QGCMapEngine.h
+0
-6
QGCMapUrlEngine.cpp
src/QtLocationPlugin/QGCMapUrlEngine.cpp
+5
-2
OfflineMap.qml
src/QtLocationPlugin/QMLControl/OfflineMap.qml
+13
-12
QGCMapEngineManager.cc
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc
+0
-28
QGCMapEngineManager.h
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h
+0
-8
App.SettingsGroup.json
src/Settings/App.SettingsGroup.json
+14
-0
AppSettings.cc
src/Settings/AppSettings.cc
+22
-0
AppSettings.h
src/Settings/AppSettings.h
+9
-1
FlightMapSettings.cc
src/Settings/FlightMapSettings.cc
+5
-2
No files found.
src/QtLocationPlugin/QGCMapEngine.cpp
View file @
5ef80c52
...
...
@@ -15,6 +15,9 @@
* @author Gus Grubba <mavlink@grubba.com>
*
*/
#include "QGCApplication.h"
#include "AppSettings.h"
#include "SettingsManager.h"
#include <math.h>
#include <QSettings>
...
...
@@ -88,8 +91,6 @@ stQGeoTileCacheQGCMapTypes kEsriTypes[] = {
#define NUM_ESRIMAPS (sizeof(kEsriTypes) / sizeof(stQGeoTileCacheQGCMapTypes))
static
const
char
*
kMapBoxTokenKey
=
"MapBoxToken"
;
static
const
char
*
kEsriTokenKey
=
"EsriToken"
;
static
const
char
*
kMaxDiskCacheKey
=
"MaxDiskCache"
;
static
const
char
*
kMaxMemCacheKey
=
"MaxMemoryCache"
;
...
...
@@ -346,12 +347,12 @@ QGCMapEngine::getMapNameList()
for
(
size_t
i
=
0
;
i
<
NUM_MAPS
;
i
++
)
{
mapList
<<
kMapTypes
[
i
].
name
;
}
if
(
!
getMapBoxToken
().
isEmpty
())
{
if
(
!
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
mapboxToken
()
->
rawValue
().
toString
().
isEmpty
())
{
for
(
size_t
i
=
0
;
i
<
NUM_MAPBOXMAPS
;
i
++
)
{
mapList
<<
kMapBoxTypes
[
i
].
name
;
}
}
if
(
!
getEsriToken
().
isEmpty
())
{
if
(
!
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
esriToken
()
->
rawValue
().
toString
().
isEmpty
())
{
for
(
size_t
i
=
0
;
i
<
NUM_ESRIMAPS
;
i
++
)
{
mapList
<<
kEsriTypes
[
i
].
name
;
}
...
...
@@ -359,46 +360,6 @@ QGCMapEngine::getMapNameList()
return
mapList
;
}
//-----------------------------------------------------------------------------
void
QGCMapEngine
::
setMapBoxToken
(
const
QString
&
token
)
{
QSettings
settings
;
settings
.
setValue
(
kMapBoxTokenKey
,
token
);
_mapBoxToken
=
token
;
}
//-----------------------------------------------------------------------------
void
QGCMapEngine
::
setEsriToken
(
const
QString
&
token
)
{
QSettings
settings
;
settings
.
setValue
(
kEsriTokenKey
,
token
);
_esriToken
=
token
;
}
//-----------------------------------------------------------------------------
QString
QGCMapEngine
::
getMapBoxToken
()
{
if
(
_mapBoxToken
.
isEmpty
())
{
QSettings
settings
;
_mapBoxToken
=
settings
.
value
(
kMapBoxTokenKey
).
toString
();
}
return
_mapBoxToken
;
}
//-----------------------------------------------------------------------------
QString
QGCMapEngine
::
getEsriToken
()
{
if
(
_esriToken
.
isEmpty
())
{
QSettings
settings
;
_esriToken
=
settings
.
value
(
kEsriTokenKey
).
toString
();
}
return
_esriToken
;
}
//-----------------------------------------------------------------------------
quint32
QGCMapEngine
::
getMaxDiskCache
()
...
...
src/QtLocationPlugin/QGCMapEngine.h
View file @
5ef80c52
...
...
@@ -78,10 +78,6 @@ public:
const
QString
userAgent
()
{
return
_userAgent
;
}
void
setUserAgent
(
const
QString
&
ua
)
{
_userAgent
=
ua
;
}
UrlFactory
::
MapType
hashToType
(
const
QString
&
hash
);
QString
getMapBoxToken
();
QString
getEsriToken
();
void
setMapBoxToken
(
const
QString
&
token
);
void
setEsriToken
(
const
QString
&
token
);
quint32
getMaxDiskCache
();
void
setMaxDiskCache
(
quint32
size
);
quint32
getMaxMemCache
();
...
...
@@ -121,8 +117,6 @@ private:
QGCCacheWorker
_worker
;
QString
_cachePath
;
QString
_cacheFile
;
QString
_mapBoxToken
;
QString
_esriToken
;
UrlFactory
*
_urlFactory
;
QString
_userAgent
;
quint32
_maxDiskCache
;
...
...
src/QtLocationPlugin/QGCMapUrlEngine.cpp
View file @
5ef80c52
...
...
@@ -16,7 +16,10 @@
//#define DEBUG_GOOGLE_MAPS
#include "QGCApplication.h"
#include "QGCMapEngine.h"
#include "AppSettings.h"
#include "SettingsManager.h"
#include <QRegExp>
#include <QNetworkReply>
...
...
@@ -168,7 +171,7 @@ UrlFactory::getTileURL(MapType type, int x, int y, int zoom, QNetworkAccessManag
case
EsriWorldStreet
:
case
EsriWorldSatellite
:
case
EsriTerrain
:
{
QByteArray
token
=
getQGCMapEngine
()
->
getEsriToken
().
toLatin1
();
QByteArray
token
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
esriToken
()
->
rawValue
().
toString
().
toLatin1
();
request
.
setRawHeader
(
"User-Agent"
,
QByteArrayLiteral
(
"Qt Location based application"
));
request
.
setRawHeader
(
"User-Token"
,
token
);
}
...
...
@@ -335,7 +338,7 @@ UrlFactory::_getURL(MapType type, int x, int y, int zoom, QNetworkAccessManager*
case
MapBoxEmerald
:
case
MapBoxHighContrast
:
{
QString
mapBoxToken
=
getQGCMapEngine
()
->
getMapBoxToken
();
QString
mapBoxToken
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
mapboxToken
()
->
rawValue
().
toString
();
if
(
!
mapBoxToken
.
isEmpty
())
{
QString
server
=
"https://api.mapbox.com/v4/"
;
switch
(
type
)
{
...
...
src/QtLocationPlugin/QMLControl/OfflineMap.qml
View file @
5ef80c52
...
...
@@ -21,6 +21,8 @@ import QGroundControl.ScreenTools 1.0
import
QGroundControl
.
Palette
1.0
import
QGroundControl
.
FlightMap
1.0
import
QGroundControl
.
QGCMapEngineManager
1.0
import
QGroundControl
.
FactSystem
1.0
import
QGroundControl
.
FactControls
1.0
QGCView
{
id
:
offlineMapView
...
...
@@ -31,6 +33,9 @@ QGCView {
property
string
mapKey
:
"
lastMapType
"
property
Fact
_mapboxFact
:
QGroundControl
.
settingsManager
.
appSettings
.
mapboxToken
property
Fact
_esriFact
:
QGroundControl
.
settingsManager
.
appSettings
.
esriToken
property
string
mapType
:
_settings
.
mapProvider
.
enumStringValue
+
"
"
+
_settings
.
mapType
.
enumStringValue
property
bool
isMapInteractive
:
false
property
var
savedCenter
:
undefined
...
...
@@ -227,8 +232,6 @@ QGCView {
id
:
optionDialog
function
accept
()
{
QGroundControl
.
mapEngineManager
.
mapboxToken
=
mapBoxToken
.
text
QGroundControl
.
mapEngineManager
.
esriToken
=
esriToken
.
text
QGroundControl
.
mapEngineManager
.
maxDiskCache
=
parseInt
(
maxCacheSize
.
text
)
QGroundControl
.
mapEngineManager
.
maxMemCache
=
parseInt
(
maxCacheMemSize
.
text
)
optionDialog
.
hideDialog
()
...
...
@@ -277,11 +280,10 @@ QGCView {
QGCLabel
{
text
:
qsTr
(
"
MapBox Access Token
"
)
}
QGCTextField
{
id
:
mapBoxToken
maximumLength
:
256
width
:
ScreenTools
.
defaultFontPixelWidth
*
30
text
:
QGroundControl
.
mapEngineManager
.
mapboxToken
FactTextField
{
fact
:
_mapboxFact
maximumLength
:
256
width
:
ScreenTools
.
defaultFontPixelWidth
*
30
}
QGCLabel
{
...
...
@@ -293,11 +295,10 @@ QGCView {
QGCLabel
{
text
:
qsTr
(
"
Esri Access Token
"
)
}
QGCTextField
{
id
:
esriToken
maximumLength
:
256
width
:
ScreenTools
.
defaultFontPixelWidth
*
30
text
:
QGroundControl
.
mapEngineManager
.
esriToken
FactTextField
{
fact
:
_esriFact
maximumLength
:
256
width
:
ScreenTools
.
defaultFontPixelWidth
*
30
}
QGCLabel
{
...
...
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc
View file @
5ef80c52
...
...
@@ -195,34 +195,6 @@ QGCMapEngineManager::mapList()
return
getQGCMapEngine
()
->
getMapNameList
();
}
//-----------------------------------------------------------------------------
QString
QGCMapEngineManager
::
mapboxToken
()
{
return
getQGCMapEngine
()
->
getMapBoxToken
();
}
//-----------------------------------------------------------------------------
void
QGCMapEngineManager
::
setMapboxToken
(
QString
token
)
{
getQGCMapEngine
()
->
setMapBoxToken
(
token
);
}
//-----------------------------------------------------------------------------
QString
QGCMapEngineManager
::
esriToken
()
{
return
getQGCMapEngine
()
->
getEsriToken
();
}
//-----------------------------------------------------------------------------
void
QGCMapEngineManager
::
setEsriToken
(
QString
token
)
{
getQGCMapEngine
()
->
setEsriToken
(
token
);
}
//-----------------------------------------------------------------------------
quint32
QGCMapEngineManager
::
maxMemCache
()
...
...
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h
View file @
5ef80c52
...
...
@@ -47,8 +47,6 @@ public:
Q_PROPERTY
(
QString
tileSizeStr
READ
tileSizeStr
NOTIFY
tileSizeChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
tileSets
READ
tileSets
NOTIFY
tileSetsChanged
)
Q_PROPERTY
(
QStringList
mapList
READ
mapList
CONSTANT
)
Q_PROPERTY
(
QString
mapboxToken
READ
mapboxToken
WRITE
setMapboxToken
NOTIFY
mapboxTokenChanged
)
Q_PROPERTY
(
QString
esriToken
READ
esriToken
WRITE
setEsriToken
NOTIFY
esriTokenChanged
)
Q_PROPERTY
(
quint32
maxMemCache
READ
maxMemCache
WRITE
setMaxMemCache
NOTIFY
maxMemCacheChanged
)
Q_PROPERTY
(
quint32
maxDiskCache
READ
maxDiskCache
WRITE
setMaxDiskCache
NOTIFY
maxDiskCacheChanged
)
Q_PROPERTY
(
QString
errorMessage
READ
errorMessage
NOTIFY
errorMessageChanged
)
...
...
@@ -85,8 +83,6 @@ public:
quint64
tileSize
()
{
return
_totalSet
.
tileSize
;
}
QString
tileSizeStr
();
QStringList
mapList
();
QString
mapboxToken
();
QString
esriToken
();
QmlObjectListModel
*
tileSets
()
{
return
&
_tileSets
;
}
quint32
maxMemCache
();
quint32
maxDiskCache
();
...
...
@@ -98,8 +94,6 @@ public:
ImportAction
importAction
()
{
return
_importAction
;
}
bool
importReplace
()
{
return
_importReplace
;
}
void
setMapboxToken
(
QString
token
);
void
setEsriToken
(
QString
token
);
void
setMaxMemCache
(
quint32
size
);
void
setMaxDiskCache
(
quint32
size
);
void
setImportReplace
(
bool
replace
)
{
_importReplace
=
replace
;
emit
importReplaceChanged
();
}
...
...
@@ -116,8 +110,6 @@ signals:
void
tileY1Changed
();
void
tileCountChanged
();
void
tileSizeChanged
();
void
mapboxTokenChanged
();
void
esriTokenChanged
();
void
tileSetsChanged
();
void
maxMemCacheChanged
();
void
maxDiskCacheChanged
();
...
...
src/Settings/App.SettingsGroup.json
View file @
5ef80c52
...
...
@@ -122,5 +122,19 @@
"longDescription"
:
"Directory to which all data files are saved/loaded from"
,
"type"
:
"string"
,
"defaultValue"
:
""
},
{
"name"
:
"MapBoxToken"
,
"shortDescription"
:
"Access token to MapBox maps"
,
"longDescription"
:
"Your personal access token for MapBox maps"
,
"type"
:
"string"
,
"defaultValue"
:
""
},
{
"name"
:
"EsriToken"
,
"shortDescription"
:
"Access token to Esri maps"
,
"longDescription"
:
"Your personal access token for Esri maps"
,
"type"
:
"string"
,
"defaultValue"
:
""
}
]
src/Settings/AppSettings.cc
View file @
5ef80c52
...
...
@@ -31,6 +31,8 @@ const char* AppSettings::indoorPaletteName = "StyleIs
const
char
*
AppSettings
::
showLargeCompassName
=
"ShowLargeCompass"
;
const
char
*
AppSettings
::
savePathName
=
"SavePath"
;
const
char
*
AppSettings
::
autoLoadMissionsName
=
"AutoLoadMissions"
;
const
char
*
AppSettings
::
mapboxTokenName
=
"MapBoxToken"
;
const
char
*
AppSettings
::
esriTokenName
=
"EsriToken"
;
const
char
*
AppSettings
::
parameterFileExtension
=
"params"
;
const
char
*
AppSettings
::
planFileExtension
=
"plan"
;
...
...
@@ -61,6 +63,8 @@ AppSettings::AppSettings(QObject* parent)
,
_showLargeCompassFact
(
NULL
)
,
_savePathFact
(
NULL
)
,
_autoLoadMissionsFact
(
NULL
)
,
_mapboxTokenFact
(
NULL
)
,
_esriTokenFact
(
NULL
)
{
QQmlEngine
::
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
qmlRegisterUncreatableType
<
AppSettings
>
(
"QGroundControl.SettingsManager"
,
1
,
0
,
"AppSettings"
,
"Reference only"
);
...
...
@@ -278,6 +282,24 @@ Fact* AppSettings::autoLoadMissions(void)
return
_autoLoadMissionsFact
;
}
Fact
*
AppSettings
::
mapboxToken
(
void
)
{
if
(
!
_mapboxTokenFact
)
{
_mapboxTokenFact
=
_createSettingsFact
(
mapboxTokenName
);
}
return
_mapboxTokenFact
;
}
Fact
*
AppSettings
::
esriToken
(
void
)
{
if
(
!
_esriTokenFact
)
{
_esriTokenFact
=
_createSettingsFact
(
esriTokenName
);
}
return
_esriTokenFact
;
}
MAV_AUTOPILOT
AppSettings
::
offlineEditingFirmwareTypeFromFirmwareType
(
MAV_AUTOPILOT
firmwareType
)
{
if
(
firmwareType
!=
MAV_AUTOPILOT_PX4
&&
firmwareType
!=
MAV_AUTOPILOT_ARDUPILOTMEGA
)
{
...
...
src/Settings/AppSettings.h
View file @
5ef80c52
...
...
@@ -35,12 +35,14 @@ public:
Q_PROPERTY
(
Fact
*
showLargeCompass
READ
showLargeCompass
CONSTANT
)
Q_PROPERTY
(
Fact
*
savePath
READ
savePath
CONSTANT
)
Q_PROPERTY
(
Fact
*
autoLoadMissions
READ
autoLoadMissions
CONSTANT
)
Q_PROPERTY
(
Fact
*
mapboxToken
READ
mapboxToken
CONSTANT
)
Q_PROPERTY
(
Fact
*
esriToken
READ
esriToken
CONSTANT
)
Q_PROPERTY
(
QString
missionSavePath
READ
missionSavePath
NOTIFY
savePathsChanged
)
Q_PROPERTY
(
QString
parameterSavePath
READ
parameterSavePath
NOTIFY
savePathsChanged
)
Q_PROPERTY
(
QString
telemetrySavePath
READ
telemetrySavePath
NOTIFY
savePathsChanged
)
Q_PROPERTY
(
QString
planFileExtension
MEMBER
planFileExtension
CONSTANT
)
Q_PROPERTY
(
QString
planFileExtension
MEMBER
planFileExtension
CONSTANT
)
Q_PROPERTY
(
QString
missionFileExtension
MEMBER
missionFileExtension
CONSTANT
)
Q_PROPERTY
(
QString
waypointsFileExtension
MEMBER
waypointsFileExtension
CONSTANT
)
Q_PROPERTY
(
QString
parameterFileExtension
MEMBER
parameterFileExtension
CONSTANT
)
...
...
@@ -61,6 +63,8 @@ public:
Fact
*
showLargeCompass
(
void
);
Fact
*
savePath
(
void
);
Fact
*
autoLoadMissions
(
void
);
Fact
*
mapboxToken
(
void
);
Fact
*
esriToken
(
void
);
QString
missionSavePath
(
void
);
QString
parameterSavePath
(
void
);
...
...
@@ -86,6 +90,8 @@ public:
static
const
char
*
showLargeCompassName
;
static
const
char
*
savePathName
;
static
const
char
*
autoLoadMissionsName
;
static
const
char
*
mapboxTokenName
;
static
const
char
*
esriTokenName
;
// Application wide file extensions
static
const
char
*
parameterFileExtension
;
...
...
@@ -124,6 +130,8 @@ private:
SettingsFact
*
_showLargeCompassFact
;
SettingsFact
*
_savePathFact
;
SettingsFact
*
_autoLoadMissionsFact
;
SettingsFact
*
_mapboxTokenFact
;
SettingsFact
*
_esriTokenFact
;
};
#endif
src/Settings/FlightMapSettings.cc
View file @
5ef80c52
...
...
@@ -7,8 +7,11 @@
*
****************************************************************************/
#include "QGCApplication.h"
#include "FlightMapSettings.h"
#include "QGCMapEngine.h"
#include "AppSettings.h"
#include "SettingsManager.h"
#include <QQmlEngine>
#include <QtQml>
...
...
@@ -34,10 +37,10 @@ FlightMapSettings::FlightMapSettings(QObject* parent)
//-- Remove Google
_excludeProvider
(
mapProviderGoogle
);
#endif
if
(
getQGCMapEngine
()
->
getMapBoxToken
().
isEmpty
())
{
if
(
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
mapboxToken
()
->
rawValue
().
toString
().
isEmpty
())
{
_excludeProvider
(
mapProviderMapBox
);
}
if
(
getQGCMapEngine
()
->
getEsriToken
().
isEmpty
())
{
if
(
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
esriToken
()
->
rawValue
().
toString
().
isEmpty
())
{
_excludeProvider
(
mapProviderEsri
);
}
_newMapProvider
(
mapProvider
()
->
rawValue
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment