From 05515c59b89f9b4c9218a1a87b174019922132d6 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Thu, 28 Nov 2024 13:27:03 -0500 Subject: [PATCH] Added hotkey for adding new location markers --- scwx-qt/source/scwx/qt/map/map_widget.cpp | 21 ++++++++++++++++--- .../scwx/qt/settings/hotkey_settings.cpp | 1 + scwx-qt/source/scwx/qt/types/hotkey_types.cpp | 2 ++ scwx-qt/source/scwx/qt/types/hotkey_types.hpp | 3 ++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index ab7b0cf6..9c68a68a 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -9,10 +9,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -79,6 +80,7 @@ public: map_(), layerList_ {}, imGuiRendererInitialized_ {false}, + editMarkerDialog_ {nullptr}, radarProductManager_ {nullptr}, radarProductLayer_ {nullptr}, overlayLayer_ {nullptr}, @@ -127,8 +129,6 @@ public: ImGui_ImplQt_Init(); InitializeCustomStyles(); - - ConnectSignals(); } ~MapWidgetImpl() @@ -219,6 +219,8 @@ public: std::shared_ptr layerModel_ { model::LayerModel::Instance()}; + std::shared_ptr editMarkerDialog_; + std::shared_ptr hotkeyManager_ { manager::HotkeyManager::Instance()}; std::shared_ptr placefileManager_ { @@ -283,6 +285,9 @@ MapWidget::MapWidget(std::size_t id, const QMapLibre::Settings& settings) : setFocusPolicy(Qt::StrongFocus); ImGui_ImplQt_RegisterWidget(this); + + p->editMarkerDialog_ = std::make_shared(this); + p->ConnectSignals(); } MapWidget::~MapWidget() @@ -429,6 +434,16 @@ void MapWidgetImpl::HandleHotkeyPressed(types::Hotkey hotkey, bool isAutoRepeat) switch (hotkey) { + case types::Hotkey::AddLocationMarker: + if (hasMouse_) + { + auto coordinate = map_->coordinateForPixel(lastPos_); + + editMarkerDialog_->setup(coordinate.first, coordinate.second); + editMarkerDialog_->show(); + } + break; + case types::Hotkey::ChangeMapStyle: if (context_->settings().isActive_) { diff --git a/scwx-qt/source/scwx/qt/settings/hotkey_settings.cpp b/scwx-qt/source/scwx/qt/settings/hotkey_settings.cpp index 0edaf840..e9c6b007 100644 --- a/scwx-qt/source/scwx/qt/settings/hotkey_settings.cpp +++ b/scwx-qt/source/scwx/qt/settings/hotkey_settings.cpp @@ -12,6 +12,7 @@ namespace settings static const std::string logPrefix_ = "scwx::qt::settings::hotkey_settings"; static const std::unordered_map kDefaultHotkeys_ { + {types::Hotkey::AddLocationMarker, QKeySequence {Qt::Key::Key_M}}, {types::Hotkey::ChangeMapStyle, QKeySequence {Qt::Key::Key_Z}}, {types::Hotkey::CopyCursorCoordinates, QKeySequence {QKeyCombination {Qt::KeyboardModifier::ControlModifier, diff --git a/scwx-qt/source/scwx/qt/types/hotkey_types.cpp b/scwx-qt/source/scwx/qt/types/hotkey_types.cpp index 8a4d0ee5..72c77f63 100644 --- a/scwx-qt/source/scwx/qt/types/hotkey_types.cpp +++ b/scwx-qt/source/scwx/qt/types/hotkey_types.cpp @@ -13,6 +13,7 @@ namespace types { static const std::unordered_map hotkeyShortName_ { + {Hotkey::AddLocationMarker, "add_location_marker"}, {Hotkey::ChangeMapStyle, "change_map_style"}, {Hotkey::CopyCursorCoordinates, "copy_cursor_coordinates"}, {Hotkey::CopyMapCoordinates, "copy_map_coordinates"}, @@ -52,6 +53,7 @@ static const std::unordered_map hotkeyShortName_ { {Hotkey::Unknown, "?"}}; static const std::unordered_map hotkeyLongName_ { + {Hotkey::AddLocationMarker, "Add Location Marker"}, {Hotkey::ChangeMapStyle, "Change Map Style"}, {Hotkey::CopyCursorCoordinates, "Copy Cursor Coordinates"}, {Hotkey::CopyMapCoordinates, "Copy Map Coordinates"}, diff --git a/scwx-qt/source/scwx/qt/types/hotkey_types.hpp b/scwx-qt/source/scwx/qt/types/hotkey_types.hpp index c2118a4f..2107a009 100644 --- a/scwx-qt/source/scwx/qt/types/hotkey_types.hpp +++ b/scwx-qt/source/scwx/qt/types/hotkey_types.hpp @@ -13,6 +13,7 @@ namespace types enum class Hotkey { + AddLocationMarker, ChangeMapStyle, CopyCursorCoordinates, CopyMapCoordinates, @@ -52,7 +53,7 @@ enum class Hotkey Unknown }; typedef scwx::util:: - Iterator + Iterator HotkeyIterator; Hotkey GetHotkeyFromShortName(const std::string& name);