Skip to content

Commit

Permalink
Add radar site hover text enabled to settings
Browse files Browse the repository at this point in the history
Resolves #133
  • Loading branch information
dpaulat committed Jan 29, 2024
1 parent d8eaee2 commit 7694b0b
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 26 deletions.
6 changes: 5 additions & 1 deletion scwx-qt/source/scwx/qt/map/radar_site_layer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <scwx/qt/map/radar_site_layer.hpp>
#include <scwx/qt/config/radar_site.hpp>
#include <scwx/qt/settings/text_settings.hpp>
#include <scwx/qt/util/maplibre.hpp>
#include <scwx/qt/util/tooltip.hpp>
#include <scwx/common/geographic.hpp>
Expand Down Expand Up @@ -130,7 +131,10 @@ void RadarSiteLayer::Impl::RenderRadarSite(
}

// Store hover text for mouse picking pass
if (ImGui::IsItemHovered())
if (settings::TextSettings::Instance()
.radar_site_hover_text_enabled()
.GetValue() &&
ImGui::IsItemHovered())
{
hoverText_ =
fmt::format("{} ({})\n{}\n{}, {}",
Expand Down
11 changes: 11 additions & 0 deletions scwx-qt/source/scwx/qt/settings/text_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class TextSettings::Impl
hoverTextWrap_.SetMinimum(0);
hoverTextWrap_.SetMaximum(999);
placefileTextDropShadowEnabled_.SetDefault(true);
radarSiteHoverTextEnabled_.SetDefault(true);
tooltipMethod_.SetDefault(defaultTooltipMethodValue);

tooltipMethod_.SetValidator(
Expand Down Expand Up @@ -97,13 +98,16 @@ class TextSettings::Impl

SettingsVariable<bool> placefileTextDropShadowEnabled_ {
"placefile_text_drop_shadow_enabled"};
SettingsVariable<bool> radarSiteHoverTextEnabled_ {
"radar_site_hover_text_enabled"};
};

TextSettings::TextSettings() :
SettingsCategory("text"), p(std::make_unique<Impl>(this))
{
RegisterVariables({&p->hoverTextWrap_,
&p->placefileTextDropShadowEnabled_,
&p->radarSiteHoverTextEnabled_,
&p->tooltipMethod_});
SetDefaults();
}
Expand Down Expand Up @@ -173,6 +177,11 @@ SettingsVariable<bool>& TextSettings::placefile_text_drop_shadow_enabled() const
return p->placefileTextDropShadowEnabled_;
}

SettingsVariable<bool>& TextSettings::radar_site_hover_text_enabled() const
{
return p->radarSiteHoverTextEnabled_;
}

SettingsVariable<std::string>& TextSettings::tooltip_method() const
{
return p->tooltipMethod_;
Expand All @@ -190,6 +199,8 @@ bool operator==(const TextSettings& lhs, const TextSettings& rhs)
lhs.p->hoverTextWrap_ == rhs.p->hoverTextWrap_ &&
lhs.p->placefileTextDropShadowEnabled_ ==
rhs.p->placefileTextDropShadowEnabled_ &&
lhs.p->radarSiteHoverTextEnabled_ ==
rhs.p->radarSiteHoverTextEnabled_ &&
lhs.p->tooltipMethod_ == rhs.p->tooltipMethod_);
}

Expand Down
1 change: 1 addition & 0 deletions scwx-qt/source/scwx/qt/settings/text_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class TextSettings : public SettingsCategory

SettingsVariable<std::int64_t>& hover_text_wrap() const;
SettingsVariable<bool>& placefile_text_drop_shadow_enabled() const;
SettingsVariable<bool>& radar_site_hover_text_enabled() const;
SettingsVariable<std::string>& tooltip_method() const;

static TextSettings& Instance();
Expand Down
9 changes: 8 additions & 1 deletion scwx-qt/source/scwx/qt/ui/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ class SettingsDialogImpl
&alertAudioCounty_,
&hoverTextWrap_,
&tooltipMethod_,
&placefileTextDropShadowEnabled_}}
&placefileTextDropShadowEnabled_,
&radarSiteHoverTextEnabled_}}
{
// Configure default alert phenomena colors
auto& paletteSettings = settings::PaletteSettings::Instance();
Expand Down Expand Up @@ -252,6 +253,7 @@ class SettingsDialogImpl
settings::SettingsInterface<std::int64_t> hoverTextWrap_ {};
settings::SettingsInterface<std::string> tooltipMethod_ {};
settings::SettingsInterface<bool> placefileTextDropShadowEnabled_ {};
settings::SettingsInterface<bool> radarSiteHoverTextEnabled_ {};

std::vector<settings::SettingsInterfaceBase*> settings_;
};
Expand Down Expand Up @@ -1118,6 +1120,11 @@ void SettingsDialogImpl::SetupTextTab()
textSettings.placefile_text_drop_shadow_enabled());
placefileTextDropShadowEnabled_.SetEditWidget(
self_->ui->placefileTextDropShadowCheckBox);

radarSiteHoverTextEnabled_.SetSettingsVariable(
textSettings.radar_site_hover_text_enabled());
radarSiteHoverTextEnabled_.SetEditWidget(
self_->ui->radarSiteHoverTextCheckBox);
}

QImage SettingsDialogImpl::GenerateColorTableImage(
Expand Down
53 changes: 30 additions & 23 deletions scwx-qt/source/scwx/qt/ui/settings_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>508</width>
<height>383</height>
<width>514</width>
<height>382</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
Expand Down Expand Up @@ -873,16 +873,38 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Tooltip Method</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="radarSiteHoverTextCheckBox">
<property name="text">
<string>Radar Site Hover Text Enabled</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="resetTooltipMethodButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../../scwx-qt.qrc">
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="hoverTextWrapSpinBox">
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="tooltipMethodComboBox"/>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="resetHoverTextWrapButton">
<property name="text">
Expand All @@ -894,32 +916,17 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Tooltip Method</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Hover text character wrap (0 to disable)</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="resetTooltipMethodButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../../scwx-qt.qrc">
<normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</normaloff>:/res/icons/font-awesome-6/rotate-left-solid.svg</iconset>
</property>
</widget>
<item row="0" column="1">
<widget class="QComboBox" name="tooltipMethodComboBox"/>
</item>
<item row="2" column="0" colspan="2">
<item row="2" column="0">
<widget class="QCheckBox" name="placefileTextDropShadowCheckBox">
<property name="text">
<string>Placefile Text Drop Shadow</string>
Expand Down

0 comments on commit 7694b0b

Please sign in to comment.