diff --git a/plugins/feature/vorlocalizer/vorlocalizergui.cpp b/plugins/feature/vorlocalizer/vorlocalizergui.cpp index a00085a19..7ea8815b9 100644 --- a/plugins/feature/vorlocalizer/vorlocalizergui.cpp +++ b/plugins/feature/vorlocalizer/vorlocalizergui.cpp @@ -945,6 +945,9 @@ VORLocalizerGUI::VORLocalizerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISe ui->rrTurnTimeProgress->setValue(0); ui->rrTurnTimeProgress->setToolTip(tr("Round robin turn time %1s").arg(0)); + // Get updated when position changes + connect(&MainCore::instance()->getSettings(), &MainSettings::preferenceChanged, this, &VORLocalizerGUI::preferenceChanged); + displaySettings(); applySettings(true); makeUIConnections(); @@ -1064,6 +1067,56 @@ void VORLocalizerGUI::tick() } } +void VORLocalizerGUI::preferenceChanged(int elementType) +{ + Preferences::ElementType pref = (Preferences::ElementType)elementType; + if ((pref == Preferences::Latitude) || (pref == Preferences::Longitude) || (pref == Preferences::Altitude)) + { + Real stationLatitude = MainCore::instance()->getSettings().getLatitude(); + Real stationLongitude = MainCore::instance()->getSettings().getLongitude(); + Real stationAltitude = MainCore::instance()->getSettings().getAltitude(); + + if ( (stationLatitude != m_azEl.getLocationSpherical().m_latitude) + || (stationLongitude != m_azEl.getLocationSpherical().m_longitude) + || (stationAltitude != m_azEl.getLocationSpherical().m_altitude)) + { + m_azEl.setLocation(stationLatitude, stationLongitude, stationAltitude); + + // Update distances and what is visible + updateVORs(); + + // Update icon position on Map + QQuickItem *item = ui->map->rootObject(); + QObject *map = item->findChild("map"); + if (map != nullptr) + { + QObject *stationObject = map->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)); + } + } + } + } + if (pref == Preferences::StationName) + { + // Update icon label on Map + QQuickItem *item = ui->map->rootObject(); + QObject *map = item->findChild("map"); + if (map != nullptr) + { + QObject *stationObject = map->findChild("station"); + if(stationObject != NULL) { + stationObject->setProperty("stationName", QVariant::fromValue(MainCore::instance()->getSettings().getStationName())); + } + } + } +} + void VORLocalizerGUI::makeUIConnections() { QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &VORLocalizerGUI::on_startStop_toggled); diff --git a/plugins/feature/vorlocalizer/vorlocalizergui.h b/plugins/feature/vorlocalizer/vorlocalizergui.h index 51639ad92..a6169e53b 100644 --- a/plugins/feature/vorlocalizer/vorlocalizergui.h +++ b/plugins/feature/vorlocalizer/vorlocalizergui.h @@ -287,6 +287,7 @@ private slots: void downloadingURL(const QString& url); void downloadError(const QString& error); void downloadNavAidsFinished(); + void preferenceChanged(int elementType); }; #endif // INCLUDE_VORLOCALIZERGUI_H