Commit afc21e9e authored by Don Gagne's avatar Don Gagne

Default map position support

parent 8b99fc31
......@@ -121,6 +121,8 @@ const char* QGCApplication::_settingsVersionKey = "SettingsVersion";
const char* QGCApplication::_promptFlightDataSave = "PromptFLightDataSave";
const char* QGCApplication::_promptFlightDataSaveNotArmed = "PromptFLightDataSaveNotArmed";
const char* QGCApplication::_styleKey = "StyleIsDark";
const char* QGCApplication::_defaultMapPositionLatKey = "DefaultMapPositionLat";
const char* QGCApplication::_defaultMapPositionLonKey = "DefaultMapPositionLon";
const char* QGCApplication::_darkStyleFile = ":/res/styles/style-dark.css";
const char* QGCApplication::_lightStyleFile = ":/res/styles/style-light.css";
......@@ -176,6 +178,7 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
#endif
, _toolbox(NULL)
, _bluetoothAvailable(false)
, _defaultMapPosition(37.803784, -122.462276)
{
Q_ASSERT(_app == NULL);
_app = this;
......@@ -318,6 +321,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
settings.setValue(_settingsVersionKey, QGC_SETTINGS_VERSION);
}
_defaultMapPosition.setLatitude(settings.value(_defaultMapPositionLatKey, 37.803784).toDouble());
_defaultMapPosition.setLongitude(settings.value(_defaultMapPositionLonKey, -122.462276).toDouble());
// Initialize Bluetooth
#ifdef QGC_ENABLE_BLUETOOTH
QBluetoothLocalDevice localDevice;
......@@ -711,3 +717,12 @@ void QGCApplication::_showSetupVehicleComponent(VehicleComponent* vehicleCompone
QMetaObject::invokeMethod(_rootQmlObject(), "showSetupVehicleComponent", Q_RETURN_ARG(QVariant, varReturn), Q_ARG(QVariant, varComponent));
}
void QGCApplication::setDefaultMapPosition(QGeoCoordinate& defaultMapPosition)
{
QSettings settings;
settings.setValue(_defaultMapPositionLatKey, defaultMapPosition.latitude());
settings.setValue(_defaultMapPositionLonKey, defaultMapPosition.longitude());
_defaultMapPosition = defaultMapPosition;
}
......@@ -121,6 +121,9 @@ public:
/// Do we have Bluetooth Support?
bool isBluetoothAvailable() { return _bluetoothAvailable; }
QGeoCoordinate defaultMapPosition(void) { return _defaultMapPosition; }
void setDefaultMapPosition(QGeoCoordinate& defaultMapPosition);
public slots:
/// You can connect to this slot to show an information message box from a different thread.
void informationMessageBoxOnMainThread(const QString& title, const QString& msg);
......@@ -184,12 +187,6 @@ private:
QQmlApplicationEngine* _qmlAppEngine;
#endif
static const char* _settingsVersionKey; ///< Settings key which hold settings version
static const char* _deleteAllSettingsKey; ///< If this settings key is set on boot, all settings will be deleted
static const char* _promptFlightDataSave; ///< Settings key for promptFlightDataSave
static const char* _promptFlightDataSaveNotArmed; ///< Settings key for promptFlightDataSaveNotArmed
static const char* _styleKey; ///< Settings key for UI style
bool _runningUnitTests; ///< true: running unit tests, false: normal app
static const char* _darkStyleFile;
......@@ -210,6 +207,16 @@ private:
bool _bluetoothAvailable;
QGeoCoordinate _defaultMapPosition; ///< Map position when all other sources fail
static const char* _settingsVersionKey; ///< Settings key which hold settings version
static const char* _deleteAllSettingsKey; ///< If this settings key is set on boot, all settings will be deleted
static const char* _promptFlightDataSave; ///< Settings key for promptFlightDataSave
static const char* _promptFlightDataSaveNotArmed; ///< Settings key for promptFlightDataSaveNotArmed
static const char* _styleKey; ///< Settings key for UI style
static const char* _defaultMapPositionLatKey; ///< Settings key for default map location
static const char* _defaultMapPositionLonKey; ///< Settings key for default map location
/// Unit Test have access to creating and destroying singletons
friend class UnitTest;
};
......
......@@ -42,7 +42,6 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app)
, _virtualTabletJoystick(false)
, _offlineEditingFirmwareTypeFact(QString(), "OfflineEditingFirmwareType", FactMetaData::valueTypeUint32, (uint32_t)MAV_AUTOPILOT_ARDUPILOTMEGA)
, _offlineEditingFirmwareTypeMetaData(FactMetaData::valueTypeUint32)
{
QSettings settings;
_virtualTabletJoystick = settings.value(_virtualTabletJoystickKey, false). toBool();
......
......@@ -76,6 +76,8 @@ public:
Q_PROPERTY(Fact* offlineEditingFirmwareType READ offlineEditingFirmwareType CONSTANT)
Q_PROPERTY(QGeoCoordinate defaultMapPosition READ defaultMapPosition CONSTANT)
Q_INVOKABLE void saveGlobalSetting (const QString& key, const QString& value);
Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue);
Q_INVOKABLE void saveBoolGlobalSetting (const QString& key, bool value);
......@@ -113,6 +115,8 @@ public:
bool isVersionCheckEnabled () { return _toolbox->mavlinkProtocol()->versionCheckEnabled(); }
int mavlinkSystemID () { return _toolbox->mavlinkProtocol()->getSystemId(); }
QGeoCoordinate defaultMapPosition() { return qgcApp()->defaultMapPosition(); }
Fact* offlineEditingFirmwareType () { return &_offlineEditingFirmwareTypeFact; }
//-- TODO: Make this into an actual preference.
......@@ -144,7 +148,6 @@ signals:
void mavlinkSystemIDChanged (int id);
private:
FlightMapSettings* _flightMapSettings;
HomePositionManager* _homePositionManager;
LinkManager* _linkManager;
......
......@@ -281,6 +281,7 @@ void Vehicle::_handleHomePosition(mavlink_message_t& message)
if (emitHomePositionChanged) {
qCDebug(VehicleLog) << "New home position" << newHomePosition;
qgcApp()->setDefaultMapPosition(_homePosition);
emit homePositionChanged(_homePosition);
}
if (emitHomePositionAvailableChanged) {
......
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