diff --git a/plugins/channelrx/demodadsb/adsbdemodgui.cpp b/plugins/channelrx/demodadsb/adsbdemodgui.cpp index e3bd44d1c..49821ee89 100644 --- a/plugins/channelrx/demodadsb/adsbdemodgui.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodgui.cpp @@ -2409,7 +2409,13 @@ void ADSBDemodGUI::applyMapSettings() // Use our repo, so we can append API key and redefine transmit maps parameters["osm.mapping.providersrepository.address"] = QString("http://127.0.0.1:%1/").arg(m_osmPort); // Use ADS-B specific cache, as we use different transmit maps - parameters["osm.mapping.cache.directory"] = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/QtLocation/osm/sdrangel/adsb"; + QString cachePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/QtLocation/5.8/tiles/osm/sdrangel_adsb"; + parameters["osm.mapping.cache.directory"] = cachePath; + // On Linux, we need to create the directory + QDir dir(cachePath); + if (!dir.exists()) { + dir.mkpath(cachePath); + } QString mapType; switch (m_settings.m_mapType) @@ -2427,17 +2433,49 @@ void ADSBDemodGUI::applyMapSettings() mapType = "Satellite Map"; break; } - QMetaObject::invokeMethod(item, "createMap", + + QVariant retVal; + if (!QMetaObject::invokeMethod(item, "createMap", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, retVal), Q_ARG(QVariant, QVariant::fromValue(parameters)), Q_ARG(QVariant, mapType), - Q_ARG(QVariant, QVariant::fromValue(this))); + Q_ARG(QVariant, QVariant::fromValue(this)))) + { + qCritical() << "ADSBDemodGUI::applyMapSettings - Failed to invoke createMap"; + } + QObject *newMap = retVal.value(); // Restore position of map - object = item->findChild("map"); - if ((object != nullptr) && coords.isValid()) + if (newMap != nullptr) { - object->setProperty("zoomLevel", QVariant::fromValue(zoom)); - object->setProperty("center", QVariant::fromValue(coords)); + if (coords.isValid()) + { + newMap->setProperty("zoomLevel", QVariant::fromValue(zoom)); + newMap->setProperty("center", QVariant::fromValue(coords)); + } + } + else + { + qDebug() << "ADSBDemodGUI::applyMapSettings - createMap returned a nullptr"; + } + + // Move antenna icon to My Position + QObject *stationObject = newMap->findChild("station"); + if(stationObject != NULL) + { + Real stationLatitude = MainCore::instance()->getSettings().getLatitude(); + Real stationLongitude = MainCore::instance()->getSettings().getLongitude(); + Real stationAltitude = MainCore::instance()->getSettings().getAltitude(); + QGeoCoordinate coords = stationObject->property("coordinate").value(); + coords.setLatitude(stationLatitude); + coords.setLongitude(stationLongitude); + coords.setAltitude(stationAltitude); + stationObject->setProperty("coordinate", QVariant::fromValue(coords)); + stationObject->setProperty("stationName", QVariant::fromValue(MainCore::instance()->getSettings().getStationName())); + } + else + { + qDebug() << "ADSBDemodGUI::applyMapSettings - Couldn't find station"; } } @@ -2580,17 +2618,6 @@ ADSBDemodGUI::ADSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb coords.setLongitude(stationLongitude); object->setProperty("center", QVariant::fromValue(coords)); } - // Move antenna icon to My Position - QObject *stationObject = item->findChild("station"); - if(stationObject != NULL) - { - QGeoCoordinate coords = stationObject->property("coordinate").value(); - coords.setLatitude(stationLatitude); - coords.setLongitude(stationLongitude); - coords.setAltitude(stationAltitude); - stationObject->setProperty("coordinate", QVariant::fromValue(coords)); - stationObject->setProperty("stationName", QVariant::fromValue(MainCore::instance()->getSettings().getStationName())); - } // Add airports within range of My Position if (m_airportInfo != nullptr) { updateAirports(); diff --git a/plugins/channelrx/demodadsb/adsbdemodsettings.cpp b/plugins/channelrx/demodadsb/adsbdemodsettings.cpp index 4b3e57464..dca9efaec 100644 --- a/plugins/channelrx/demodadsb/adsbdemodsettings.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodsettings.cpp @@ -74,7 +74,7 @@ void ADSBDemodSettings::resetToDefaults() } m_logFilename = "adsb_log.csv"; m_logEnabled = false; - m_airspaces = QStringList({"A", "C", "TMZ"}); + m_airspaces = QStringList({"A", "D", "TMZ"}); m_airspaceRange = 500.0f; m_mapType = AVIATION_LIGHT; m_displayNavAids = true; @@ -225,7 +225,7 @@ bool ADSBDemodSettings::deserialize(const QByteArray& data) d.readString(36, &m_logFilename, "adsb_log.csv"); d.readBool(37, &m_logEnabled, false); - d.readString(38, &string, "A C TMZ"); + d.readString(38, &string, "A D TMZ"); m_airspaces = string.split(" "); d.readFloat(39, &m_airspaceRange, 500.0f); d.readS32(40, (int *)&m_mapType, (int)AVIATION_LIGHT); diff --git a/plugins/channelrx/demodadsb/map/map.qml b/plugins/channelrx/demodadsb/map/map.qml index 42da39edc..d18c00ba7 100644 --- a/plugins/channelrx/demodadsb/map/map.qml +++ b/plugins/channelrx/demodadsb/map/map.qml @@ -27,17 +27,14 @@ Item { var plugin = Qt.createQmlObject (pluginString, qmlMap) if (mapPtr) { - // Objects aren't destroyed immediately, so rename the old - // map, so any C++ code that calls findChild("map") doesn't find - // the old map - mapPtr.objectName = "oldMap"; + // Objects aren't destroyed immediately, so don't call findChild("map") mapPtr.destroy() mapPtr = null } mapPtr = actualMapComponent.createObject(page) - mapPtr.plugin = plugin; + mapPtr.plugin = plugin mapPtr.forceActiveFocus() - mapPtr.objectName = "map"; + return mapPtr } Item { @@ -50,6 +47,7 @@ Item { Map { id: map + objectName: "map" anchors.fill: parent center: QtPositioning.coordinate(51.5, 0.125) // London zoomLevel: 10 @@ -68,7 +66,6 @@ Item { id: station objectName: "station" stationName: "Home" - coordinate: QtPositioning.coordinate(51.5, 0.125) } MapItemView {