From 35bd2433a71021017a84593bc85031e4324c853a Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Fri, 8 Mar 2024 00:55:55 -0600 Subject: [PATCH] Update map immediately if map logo or attribution is toggled --- scwx-qt/source/scwx/qt/map/overlay_layer.cpp | 30 ++++++++++++++++++-- scwx-qt/source/scwx/qt/map/overlay_layer.hpp | 2 ++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/scwx-qt/source/scwx/qt/map/overlay_layer.cpp b/scwx-qt/source/scwx/qt/map/overlay_layer.cpp index d00fb717..1f1844fd 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/overlay_layer.cpp @@ -42,14 +42,38 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class OverlayLayerImpl { public: - explicit OverlayLayerImpl(std::shared_ptr context) : + explicit OverlayLayerImpl(OverlayLayer* self, + std::shared_ptr context) : + self_ {self}, activeBoxOuter_ {std::make_shared(context)}, activeBoxInner_ {std::make_shared(context)}, geoIcons_ {std::make_shared(context)}, icons_ {std::make_shared(context)} { + auto& generalSettings = settings::GeneralSettings::Instance(); + + showMapAttributionCallbackUuid_ = + generalSettings.show_map_attribution().RegisterValueChangedCallback( + [this](const bool&) { Q_EMIT self_->NeedsRendering(); }); + showMapLogoCallbackUuid_ = + generalSettings.show_map_logo().RegisterValueChangedCallback( + [this](const bool&) { Q_EMIT self_->NeedsRendering(); }); } - ~OverlayLayerImpl() = default; + + ~OverlayLayerImpl() + { + auto& generalSettings = settings::GeneralSettings::Instance(); + + generalSettings.show_map_attribution().UnregisterValueChangedCallback( + showMapAttributionCallbackUuid_); + generalSettings.show_map_logo().UnregisterValueChangedCallback( + showMapLogoCallbackUuid_); + } + + OverlayLayer* self_; + + boost::uuids::uuid showMapAttributionCallbackUuid_; + boost::uuids::uuid showMapLogoCallbackUuid_; std::shared_ptr positionManager_ { manager::PositionManager::Instance()}; @@ -91,7 +115,7 @@ public: }; OverlayLayer::OverlayLayer(std::shared_ptr context) : - DrawLayer(context), p(std::make_unique(context)) + DrawLayer(context), p(std::make_unique(this, context)) { AddDrawItem(p->activeBoxOuter_); AddDrawItem(p->activeBoxInner_); diff --git a/scwx-qt/source/scwx/qt/map/overlay_layer.hpp b/scwx-qt/source/scwx/qt/map/overlay_layer.hpp index 411694b1..f842e81b 100644 --- a/scwx-qt/source/scwx/qt/map/overlay_layer.hpp +++ b/scwx-qt/source/scwx/qt/map/overlay_layer.hpp @@ -13,6 +13,8 @@ class OverlayLayerImpl; class OverlayLayer : public DrawLayer { + Q_DISABLE_COPY_MOVE(OverlayLayer) + public: explicit OverlayLayer(std::shared_ptr context); ~OverlayLayer();