Commit 06cf7dfa authored by Gus Grubba's avatar Gus Grubba Committed by Beat Küng

Added include and lib path for protobuf on maxOS (we need to make this automatic for all builds)

Added AirMap settings (SettingsGroup)
Added AirMap settings block to General Settings
Create macros to deal with the tedious repetitions within SettingsGroup
Removed old, hacked in setting for AirMapKey
Remove a few of the tons of build warnings
parent 1a0b158c
......@@ -564,6 +564,7 @@ HEADERS += \
src/QmlControls/RCChannelMonitorController.h \
src/QmlControls/ScreenToolsController.h \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \
src/Settings/AirMapSettings.h \
src/Settings/AppSettings.h \
src/Settings/AutoConnectSettings.h \
src/Settings/BrandImageSettings.h \
......@@ -591,7 +592,15 @@ HEADERS += \
src/AnalyzeView/LogDownloadController.h \
libs/thirdParty/tiny-AES128-C/aes.h \
# Protobuf
# Protobuf (AirMap)
# This should be optional. As is, QGC now requires protobuf to be installed.
MacBuild {
INCLUDEPATH += \
/usr/local/opt/protobuf/include
LIBS += \
-L/usr/local/opt/protobuf/lib
}
LIBS += -lprotobuf
PROTOS = src/protobuf/airmap_telemetry.proto
include(src/protobuf/proto_compile.pri)
......@@ -759,6 +768,7 @@ SOURCES += \
src/QmlControls/RCChannelMonitorController.cc \
src/QmlControls/ScreenToolsController.cc \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \
src/Settings/AirMapSettings.cc \
src/Settings/AppSettings.cc \
src/Settings/AutoConnectSettings.cc \
src/Settings/BrandImageSettings.cc \
......
......@@ -190,6 +190,7 @@
<file alias="MavCmdInfoRover.json">src/MissionManager/MavCmdInfoRover.json</file>
<file alias="MavCmdInfoSub.json">src/MissionManager/MavCmdInfoSub.json</file>
<file alias="MavCmdInfoVTOL.json">src/MissionManager/MavCmdInfoVTOL.json</file>
<file alias="AirMap.SettingsGroup.json">src/Settings/AirMap.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="FlightMap.SettingsGroup.json">src/Settings/FlightMap.SettingsGroup.json</file>
......
......@@ -13,6 +13,7 @@
#include "JsonHelper.h"
#include "SettingsManager.h"
#include "AppSettings.h"
#include "AirMapSettings.h"
#include "QGCQGeoCoordinate.h"
#include "QGCApplication.h"
......@@ -344,7 +345,7 @@ void AirspaceRestrictionManager::updateROI(const QGeoCoordinate& center, double
void AirspaceRestrictionManager::_parseAirspaceJson(QJsonParseError parseError, QJsonDocument airspaceDoc)
{
Q_UNUSED(parseError);
QJsonObject rootObject = airspaceDoc.object();
switch(_state) {
......@@ -637,7 +638,7 @@ void AirMapFlightManager::_sendBriefingRequest()
void AirMapFlightManager::_parseJson(QJsonParseError parseError, QJsonDocument doc)
{
Q_UNUSED(parseError);
QJsonObject rootObject = doc.object();
switch(_state) {
......@@ -899,7 +900,7 @@ void AirMapTelemetry::_handleGlobalPositionInt(const mavlink_message_t& message)
uint8_t* key = (uint8_t*)_key.data();
uint8_t iv[16];
for (int i = 0; i < sizeof(iv); ++i) {
for (size_t i = 0; i < sizeof(iv); ++i) {
iv[i] = (uint8_t)(qrand() & 0xff); // TODO: should use a secure random source
}
......@@ -967,8 +968,8 @@ void AirMapTelemetry::_handleGlobalPositionInt(const mavlink_message_t& message)
void AirMapTelemetry::_parseJson(QJsonParseError parseError, QJsonDocument doc)
{
Q_UNUSED(parseError);
QJsonObject rootObject = doc.object();
switch(_state) {
case State::StartCommunication:
{
......@@ -1189,18 +1190,12 @@ void AirMapManager::_vehicleArmedChanged(bool armed)
}
}
void AirMapManager::setToolbox(QGCToolbox* toolbox)
{
QGCTool::setToolbox(toolbox);
_networkingData.airmapAPIKey = toolbox->settingsManager()->appSettings()->airMapKey()->rawValueString();
// TODO: set login credentials from config
QString clientID = "";
QString userName = "";
QString password = "";
_networkingData.login.setCredentials(clientID, userName, password);
AirMapSettings* ap = toolbox->settingsManager()->airMapSettings();
_networkingData.airmapAPIKey = ap->apiKey()->rawValueString();
_networkingData.login.setCredentials(ap->clientID()->rawValueString(), ap->userName()->rawValueString(), ap->password()->rawValueString());
}
void AirMapManager::setROI(QGeoCoordinate& center, double radiusMeters)
......
[
{
"name": "apiKey",
"shortDescription": "AirMap API Key",
"type": "string",
"defaultValue": ""
},
{
"name": "clientID",
"shortDescription": "AirMap Client ID",
"type": "string",
"defaultValue": ""
},
{
"name": "userName",
"shortDescription": "AirMap User Name",
"type": "string",
"defaultValue": ""
},
{
"name": "password",
"shortDescription": "AirMap Password",
"type": "string",
"defaultValue": ""
},
{
"name": "sitaUavReg",
"shortDescription": "AirMap SITA UAV Registration",
"type": "string",
"defaultValue": ""
},
{
"name": "sitaUserReg",
"shortDescription": "AirMap SITA User Registration",
"type": "string",
"defaultValue": ""
}
]
/****************************************************************************
*
* (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 "AirMapSettings.h"
#include "QGCPalette.h"
#include "QGCApplication.h"
#include <QQmlEngine>
#include <QtQml>
DECLARE_SETTINGGROUP(AirMap)
{
INIT_SETTINGFACT(apiKey);
INIT_SETTINGFACT(clientID);
INIT_SETTINGFACT(userName);
INIT_SETTINGFACT(password);
INIT_SETTINGFACT(sitaUavReg);
INIT_SETTINGFACT(sitaUserReg);
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<AirMapSettings>("QGroundControl.SettingsManager", 1, 0, "AirMapSettings", "Reference only");
}
DECLARE_SETTINGSFACT(AirMapSettings, apiKey)
DECLARE_SETTINGSFACT(AirMapSettings, clientID)
DECLARE_SETTINGSFACT(AirMapSettings, userName)
DECLARE_SETTINGSFACT(AirMapSettings, password)
DECLARE_SETTINGSFACT(AirMapSettings, sitaUavReg)
DECLARE_SETTINGSFACT(AirMapSettings, sitaUserReg)
/****************************************************************************
*
* (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.
*
****************************************************************************/
#pragma once
#include "SettingsGroup.h"
#include "QGCMAVLink.h"
class AirMapSettings : public SettingsGroup
{
Q_OBJECT
public:
AirMapSettings(QObject* parent = NULL);
DEFINE_SETTINGGROUP(AirMap)
DEFINE_SETTINGFACT(apiKey)
DEFINE_SETTINGFACT(clientID)
DEFINE_SETTINGFACT(userName)
DEFINE_SETTINGFACT(password)
DEFINE_SETTINGFACT(sitaUavReg)
DEFINE_SETTINGFACT(sitaUserReg)
};
......@@ -176,10 +176,5 @@
"shortDescription": "Default firmware type for flashing",
"type": "uint32",
"defaultValue": 12
},
{
"name": "AirMapKey",
"type": "string",
"defaultValue": ""
}
]
......@@ -36,7 +36,6 @@ const char* AppSettings::autoLoadMissionsName = "AutoLoa
const char* AppSettings::mapboxTokenName = "MapboxToken";
const char* AppSettings::esriTokenName = "EsriToken";
const char* AppSettings::defaultFirmwareTypeName = "DefaultFirmwareType";
const char* AppSettings::airMapKeyName = "AirMapKey";
const char* AppSettings::parameterFileExtension = "params";
const char* AppSettings::planFileExtension = "plan";
......@@ -76,7 +75,6 @@ AppSettings::AppSettings(QObject* parent)
, _mapboxTokenFact(NULL)
, _esriTokenFact(NULL)
, _defaultFirmwareTypeFact(NULL)
, _airMapKeyFact(NULL)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<AppSettings>("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only");
......@@ -391,12 +389,3 @@ Fact* AppSettings::defaultFirmwareType(void)
return _defaultFirmwareTypeFact;
}
Fact* AppSettings::airMapKey(void)
{
if (!_airMapKeyFact) {
_airMapKeyFact = _createSettingsFact(airMapKeyName);
}
return _airMapKeyFact;
}
......@@ -40,7 +40,6 @@ public:
Q_PROPERTY(Fact* mapboxToken READ mapboxToken CONSTANT)
Q_PROPERTY(Fact* esriToken READ esriToken CONSTANT)
Q_PROPERTY(Fact* defaultFirmwareType READ defaultFirmwareType CONSTANT)
Q_PROPERTY(Fact* airMapKey READ airMapKey CONSTANT)
Q_PROPERTY(QString missionSavePath READ missionSavePath NOTIFY savePathsChanged)
Q_PROPERTY(QString parameterSavePath READ parameterSavePath NOTIFY savePathsChanged)
......@@ -76,13 +75,12 @@ public:
Fact* mapboxToken (void);
Fact* esriToken (void);
Fact* defaultFirmwareType (void);
Fact* airMapKey (void);
QString missionSavePath (void);
QString parameterSavePath (void);
QString telemetrySavePath (void);
QString logSavePath (void);
QString videoSavePath (void);
QString videoSavePath (void);
static MAV_AUTOPILOT offlineEditingFirmwareTypeFromFirmwareType(MAV_AUTOPILOT firmwareType);
static MAV_TYPE offlineEditingVehicleTypeFromVehicleType(MAV_TYPE vehicleType);
......@@ -109,7 +107,6 @@ public:
static const char* mapboxTokenName;
static const char* esriTokenName;
static const char* defaultFirmwareTypeName;
static const char* airMapKeyName;
// Application wide file extensions
static const char* parameterFileExtension;
......@@ -157,7 +154,6 @@ private:
SettingsFact* _mapboxTokenFact;
SettingsFact* _esriTokenFact;
SettingsFact* _defaultFirmwareTypeFact;
SettingsFact* _airMapKeyFact;
};
#endif
......@@ -17,6 +17,34 @@
#include <QVariantList>
#define DEFINE_SETTINGGROUP(CLASS) \
static const char* CLASS ## Settings ## GroupName;
#define DECLARE_SETTINGGROUP(CLASS) \
const char* CLASS ## Settings::CLASS ## Settings ## GroupName = #CLASS; \
CLASS ## Settings::CLASS ## Settings(QObject* parent) \
: SettingsGroup(CLASS ## Settings ## GroupName, QString() /* root settings group */, parent)
#define DECLARE_SETTINGSFACT(CLASS, NAME) \
const char* CLASS::NAME ## Name = #NAME; \
Fact* CLASS::NAME(void) \
{ \
if (!_ ## NAME ## Fact) { \
_ ## NAME ## Fact = _createSettingsFact(NAME ## Name); \
} \
return _ ## NAME ## Fact; \
}
#define DEFINE_SETTINGFACT(NAME) \
public: \
Q_PROPERTY(Fact* NAME READ NAME CONSTANT) \
Fact* NAME(); \
static const char* NAME ## Name; \
private: \
SettingsFact* _ ## NAME ## Fact;
#define INIT_SETTINGFACT(NAME) _ ## NAME ## Fact = NULL
/// Provides access to group of settings. The group is named and has a visible property associated with which can control whether the group
/// is shows in the ui.
class SettingsGroup : public QObject
......
......@@ -14,6 +14,7 @@
SettingsManager::SettingsManager(QGCApplication* app, QGCToolbox* toolbox)
: QGCTool(app, toolbox)
, _airMapSettings (NULL)
, _appSettings (NULL)
, _unitsSettings (NULL)
, _autoConnectSettings (NULL)
......@@ -40,4 +41,5 @@ void SettingsManager::setToolbox(QGCToolbox *toolbox)
_rtkSettings = new RTKSettings(this);
_guidedSettings = new GuidedSettings(this);
_brandImageSettings = new BrandImageSettings(this);
_airMapSettings = new AirMapSettings(this);
}
......@@ -22,6 +22,7 @@
#include "RTKSettings.h"
#include "GuidedSettings.h"
#include "BrandImageSettings.h"
#include "AirMapSettings.h"
#include <QVariantList>
......@@ -33,6 +34,7 @@ class SettingsManager : public QGCTool
public:
SettingsManager(QGCApplication* app, QGCToolbox* toolbox);
Q_PROPERTY(QObject* airMapSettings READ airMapSettings CONSTANT)
Q_PROPERTY(QObject* appSettings READ appSettings CONSTANT)
Q_PROPERTY(QObject* unitsSettings READ unitsSettings CONSTANT)
Q_PROPERTY(QObject* autoConnectSettings READ autoConnectSettings CONSTANT)
......@@ -45,6 +47,7 @@ public:
// Override from QGCTool
virtual void setToolbox(QGCToolbox *toolbox);
AirMapSettings* airMapSettings (void) { return _airMapSettings; }
AppSettings* appSettings (void) { return _appSettings; }
UnitsSettings* unitsSettings (void) { return _unitsSettings; }
AutoConnectSettings* autoConnectSettings (void) { return _autoConnectSettings; }
......@@ -55,6 +58,7 @@ public:
BrandImageSettings* brandImageSettings (void) { return _brandImageSettings; }
private:
AirMapSettings* _airMapSettings;
AppSettings* _appSettings;
UnitsSettings* _unitsSettings;
AutoConnectSettings* _autoConnectSettings;
......
......@@ -2921,6 +2921,7 @@ void Vehicle::_vehicleParamLoaded(bool ready)
void Vehicle::_trafficUpdate(QString traffic_id, QString vehicle_id, QGeoCoordinate location, float heading)
{
Q_UNUSED(vehicle_id);
// qDebug() << "traffic update:" << traffic_id << vehicle_id << heading << location;
// TODO: filter based on minimum altitude?
// TODO: remove a vehicle after a timeout?
......
......@@ -388,11 +388,6 @@ QGCView {
}
}
}
// FIXME: Hack
FactTextField {
fact: QGroundControl.settingsManager.appSettings.airMapKey
}
}
}
......@@ -492,6 +487,62 @@ QGCView {
}
}
//-----------------------------------------------------------------
//-- AirMap
Item {
width: _qgcView.width * 0.8
height: unitLabel.height
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
visible: QGroundControl.settingsManager.rtkSettings.visible
QGCLabel {
text: qsTr("AirMap")
font.family: ScreenTools.demiboldFontFamily
}
}
Rectangle {
height: airMapCol.height + (ScreenTools.defaultFontPixelHeight * 2)
width: _qgcView.width * 0.8
color: qgcPal.windowShade
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
visible: QGroundControl.settingsManager.airMapSettings.visible
Column {
id: airMapCol
spacing: ScreenTools.defaultFontPixelWidth
anchors.centerIn: parent
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {text: qsTr("API Key:"); width: _labelWidth; anchors.verticalCenter: parent.verticalCenter }
FactTextField {fact: QGroundControl.settingsManager.airMapSettings.apiKey; width: _editFieldWidth; anchors.verticalCenter: parent.verticalCenter }
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {text: qsTr("Client ID:"); width: _labelWidth; anchors.verticalCenter: parent.verticalCenter }
FactTextField {fact: QGroundControl.settingsManager.airMapSettings.clientID; width: _editFieldWidth; anchors.verticalCenter: parent.verticalCenter }
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {text: qsTr("User Name:"); width: _labelWidth; anchors.verticalCenter: parent.verticalCenter }
FactTextField {fact: QGroundControl.settingsManager.airMapSettings.userName; width: _editFieldWidth; anchors.verticalCenter: parent.verticalCenter }
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {text: qsTr("Password:"); width: _labelWidth; anchors.verticalCenter: parent.verticalCenter }
FactTextField {fact: QGroundControl.settingsManager.airMapSettings.password; width: _editFieldWidth; anchors.verticalCenter: parent.verticalCenter; echoMode: TextInput.Password }
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {text: qsTr("SITA UAV Reg:"); width: _labelWidth; anchors.verticalCenter: parent.verticalCenter }
FactTextField {fact: QGroundControl.settingsManager.airMapSettings.sitaUavReg; width: _editFieldWidth; anchors.verticalCenter: parent.verticalCenter }
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {text: qsTr("SITA User Reg:"); width: _labelWidth; anchors.verticalCenter: parent.verticalCenter }
FactTextField {fact: QGroundControl.settingsManager.airMapSettings.sitaUserReg; width: _editFieldWidth; anchors.verticalCenter: parent.verticalCenter }
}
}
}
//-----------------------------------------------------------------
//-- Video Source
Item {
......
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