Merge pull request #2072 from srcejon/freq_scanner

ADS-B: Fix map centering and station icon on Qt6
pull/2073/head
Edouard Griffiths 2024-04-16 18:15:57 +02:00 zatwierdzone przez GitHub
commit 3795b72855
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 28 dodań i 16 usunięć

Wyświetl plik

@ -4802,6 +4802,25 @@ void ADSBDemodGUI::applyMapSettings()
// Restore position of map // Restore position of map
if (newMap != nullptr) if (newMap != nullptr)
{ {
// Move antenna icon to My Position
QObject *stationObject = newMap->findChild<QObject*>("station");
if(stationObject != NULL)
{
QGeoCoordinate coords = stationObject->property("coordinate").value<QGeoCoordinate>();
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";
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
newMap = newMap->findChild<QObject*>("map");
#endif
if (coords.isValid()) if (coords.isValid())
{ {
newMap->setProperty("zoomLevel", QVariant::fromValue(zoom)); newMap->setProperty("zoomLevel", QVariant::fromValue(zoom));
@ -4812,22 +4831,6 @@ void ADSBDemodGUI::applyMapSettings()
{ {
qDebug() << "ADSBDemodGUI::applyMapSettings - createMap returned a nullptr"; qDebug() << "ADSBDemodGUI::applyMapSettings - createMap returned a nullptr";
} }
// Move antenna icon to My Position
QObject *stationObject = newMap->findChild<QObject*>("station");
if(stationObject != NULL)
{
QGeoCoordinate coords = stationObject->property("coordinate").value<QGeoCoordinate>();
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";
}
} }
// Called from QML when empty space clicked // Called from QML when empty space clicked
@ -6000,7 +6003,11 @@ void ADSBDemodGUI::preferenceChanged(int elementType)
// Update icon position on Map // Update icon position on Map
QQuickItem *item = ui->map->rootObject(); QQuickItem *item = ui->map->rootObject();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QObject *map = item->findChild<QObject*>("map"); QObject *map = item->findChild<QObject*>("map");
#else
QObject *map = item->findChild<QObject*>("mapView");
#endif
if (map != nullptr) if (map != nullptr)
{ {
QObject *stationObject = map->findChild<QObject*>("station"); QObject *stationObject = map->findChild<QObject*>("station");
@ -6019,7 +6026,11 @@ void ADSBDemodGUI::preferenceChanged(int elementType)
{ {
// Update icon label on Map // Update icon label on Map
QQuickItem *item = ui->map->rootObject(); QQuickItem *item = ui->map->rootObject();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QObject *map = item->findChild<QObject*>("map"); QObject *map = item->findChild<QObject*>("map");
#else
QObject *map = item->findChild<QObject*>("mapView");
#endif
if (map != nullptr) if (map != nullptr)
{ {
QObject *stationObject = map->findChild<QObject*>("station"); QObject *stationObject = map->findChild<QObject*>("station");

Wyświetl plik

@ -74,6 +74,7 @@ Item {
id: station id: station
objectName: "station" objectName: "station"
stationName: "Home" stationName: "Home"
parent: mapView.map
} }
MapItemView { MapItemView {