From c3d39e25715d83a1d99a9cd9880249a7ca49ad9c Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Sat, 12 Jul 2025 08:48:07 -0400 Subject: [PATCH] Add a label to the location marker settings widget to indicate the existance of hotkeys for adding/editing location markers --- .../scwx/qt/ui/marker_settings_widget.cpp | 32 +++++++++++++------ .../scwx/qt/ui/marker_settings_widget.ui | 29 ++++++++++++++++- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/scwx-qt/source/scwx/qt/ui/marker_settings_widget.cpp b/scwx-qt/source/scwx/qt/ui/marker_settings_widget.cpp index 51d9e40a..da1d3809 100644 --- a/scwx-qt/source/scwx/qt/ui/marker_settings_widget.cpp +++ b/scwx-qt/source/scwx/qt/ui/marker_settings_widget.cpp @@ -3,17 +3,15 @@ #include #include +#include +#include #include #include #include #include -namespace scwx -{ -namespace qt -{ -namespace ui +namespace scwx::qt::ui { static const std::string logPrefix_ = "scwx::qt::ui::marker_settings_widget"; @@ -34,6 +32,7 @@ public: } void ConnectSignals(); + void UpdateHotkeyLabel(); MarkerSettingsWidget* self_; model::MarkerModel* markerModel_; @@ -41,9 +40,9 @@ public: std::shared_ptr markerManager_ { manager::MarkerManager::Instance()}; std::shared_ptr editMarkerDialog_ {nullptr}; + boost::signals2::scoped_connection hotkeyConnection_; }; - MarkerSettingsWidget::MarkerSettingsWidget(QWidget* parent) : QFrame(parent), p {std::make_unique(this)}, @@ -53,6 +52,7 @@ MarkerSettingsWidget::MarkerSettingsWidget(QWidget* parent) : ui->removeButton->setEnabled(false); ui->markerView->setModel(p->proxyModel_); + p->UpdateHotkeyLabel(); p->editMarkerDialog_ = std::make_shared(this); @@ -128,8 +128,22 @@ void MarkerSettingsWidgetImpl::ConnectSignals() editMarkerDialog_->setup(id.toULongLong()); editMarkerDialog_->show(); }); + hotkeyConnection_ = settings::HotkeySettings::Instance() + .hotkey(types::Hotkey::AddLocationMarker) + .changed_signal() + .connect([this]() { UpdateHotkeyLabel(); }); } -} // namespace ui -} // namespace qt -} // namespace scwx +void MarkerSettingsWidgetImpl::UpdateHotkeyLabel() +{ + self_->ui->hotkeyLabel->setText( + fmt::format( + "A Location Marker can be placed at the location under the cursor by " + "pressing \"{}\" and edited by right clicking it on the map.", + settings::HotkeySettings::Instance() + .hotkey(types::Hotkey::AddLocationMarker) + .GetValue()) + .c_str()); +} + +} // namespace scwx::qt::ui diff --git a/scwx-qt/source/scwx/qt/ui/marker_settings_widget.ui b/scwx-qt/source/scwx/qt/ui/marker_settings_widget.ui index 3804f318..49b41c8b 100644 --- a/scwx-qt/source/scwx/qt/ui/marker_settings_widget.ui +++ b/scwx-qt/source/scwx/qt/ui/marker_settings_widget.ui @@ -14,6 +14,33 @@ Frame + + 0 + + + + + + 0 + 0 + + + + + 9 + + + + QFrame::Shape::NoFrame + + + + + + Qt::TextFormat::PlainText + + + @@ -34,7 +61,7 @@ 0 - 0 + 6 0