Add radar site hover text enabled to settings

Resolves #133
This commit is contained in:
Dan Paulat 2024-01-28 21:24:30 -06:00
parent d8eaee2f7f
commit 7694b0bf59
6 changed files with 60 additions and 30 deletions

View file

@ -1,5 +1,6 @@
#include <scwx/qt/map/radar_site_layer.hpp> #include <scwx/qt/map/radar_site_layer.hpp>
#include <scwx/qt/config/radar_site.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/maplibre.hpp>
#include <scwx/qt/util/tooltip.hpp> #include <scwx/qt/util/tooltip.hpp>
#include <scwx/common/geographic.hpp> #include <scwx/common/geographic.hpp>
@ -130,7 +131,10 @@ void RadarSiteLayer::Impl::RenderRadarSite(
} }
// Store hover text for mouse picking pass // Store hover text for mouse picking pass
if (ImGui::IsItemHovered()) if (settings::TextSettings::Instance()
.radar_site_hover_text_enabled()
.GetValue() &&
ImGui::IsItemHovered())
{ {
hoverText_ = hoverText_ =
fmt::format("{} ({})\n{}\n{}, {}", fmt::format("{} ({})\n{}\n{}, {}",

View file

@ -50,6 +50,7 @@ public:
hoverTextWrap_.SetMinimum(0); hoverTextWrap_.SetMinimum(0);
hoverTextWrap_.SetMaximum(999); hoverTextWrap_.SetMaximum(999);
placefileTextDropShadowEnabled_.SetDefault(true); placefileTextDropShadowEnabled_.SetDefault(true);
radarSiteHoverTextEnabled_.SetDefault(true);
tooltipMethod_.SetDefault(defaultTooltipMethodValue); tooltipMethod_.SetDefault(defaultTooltipMethodValue);
tooltipMethod_.SetValidator( tooltipMethod_.SetValidator(
@ -97,6 +98,8 @@ public:
SettingsVariable<bool> placefileTextDropShadowEnabled_ { SettingsVariable<bool> placefileTextDropShadowEnabled_ {
"placefile_text_drop_shadow_enabled"}; "placefile_text_drop_shadow_enabled"};
SettingsVariable<bool> radarSiteHoverTextEnabled_ {
"radar_site_hover_text_enabled"};
}; };
TextSettings::TextSettings() : TextSettings::TextSettings() :
@ -104,6 +107,7 @@ TextSettings::TextSettings() :
{ {
RegisterVariables({&p->hoverTextWrap_, RegisterVariables({&p->hoverTextWrap_,
&p->placefileTextDropShadowEnabled_, &p->placefileTextDropShadowEnabled_,
&p->radarSiteHoverTextEnabled_,
&p->tooltipMethod_}); &p->tooltipMethod_});
SetDefaults(); SetDefaults();
} }
@ -173,6 +177,11 @@ SettingsVariable<bool>& TextSettings::placefile_text_drop_shadow_enabled() const
return p->placefileTextDropShadowEnabled_; return p->placefileTextDropShadowEnabled_;
} }
SettingsVariable<bool>& TextSettings::radar_site_hover_text_enabled() const
{
return p->radarSiteHoverTextEnabled_;
}
SettingsVariable<std::string>& TextSettings::tooltip_method() const SettingsVariable<std::string>& TextSettings::tooltip_method() const
{ {
return p->tooltipMethod_; return p->tooltipMethod_;
@ -190,6 +199,8 @@ bool operator==(const TextSettings& lhs, const TextSettings& rhs)
lhs.p->hoverTextWrap_ == rhs.p->hoverTextWrap_ && lhs.p->hoverTextWrap_ == rhs.p->hoverTextWrap_ &&
lhs.p->placefileTextDropShadowEnabled_ == lhs.p->placefileTextDropShadowEnabled_ ==
rhs.p->placefileTextDropShadowEnabled_ && rhs.p->placefileTextDropShadowEnabled_ &&
lhs.p->radarSiteHoverTextEnabled_ ==
rhs.p->radarSiteHoverTextEnabled_ &&
lhs.p->tooltipMethod_ == rhs.p->tooltipMethod_); lhs.p->tooltipMethod_ == rhs.p->tooltipMethod_);
} }

View file

@ -35,6 +35,7 @@ public:
SettingsVariable<std::int64_t>& hover_text_wrap() const; SettingsVariable<std::int64_t>& hover_text_wrap() const;
SettingsVariable<bool>& placefile_text_drop_shadow_enabled() const; SettingsVariable<bool>& placefile_text_drop_shadow_enabled() const;
SettingsVariable<bool>& radar_site_hover_text_enabled() const;
SettingsVariable<std::string>& tooltip_method() const; SettingsVariable<std::string>& tooltip_method() const;
static TextSettings& Instance(); static TextSettings& Instance();

View file

@ -139,7 +139,8 @@ public:
&alertAudioCounty_, &alertAudioCounty_,
&hoverTextWrap_, &hoverTextWrap_,
&tooltipMethod_, &tooltipMethod_,
&placefileTextDropShadowEnabled_}} &placefileTextDropShadowEnabled_,
&radarSiteHoverTextEnabled_}}
{ {
// Configure default alert phenomena colors // Configure default alert phenomena colors
auto& paletteSettings = settings::PaletteSettings::Instance(); auto& paletteSettings = settings::PaletteSettings::Instance();
@ -252,6 +253,7 @@ public:
settings::SettingsInterface<std::int64_t> hoverTextWrap_ {}; settings::SettingsInterface<std::int64_t> hoverTextWrap_ {};
settings::SettingsInterface<std::string> tooltipMethod_ {}; settings::SettingsInterface<std::string> tooltipMethod_ {};
settings::SettingsInterface<bool> placefileTextDropShadowEnabled_ {}; settings::SettingsInterface<bool> placefileTextDropShadowEnabled_ {};
settings::SettingsInterface<bool> radarSiteHoverTextEnabled_ {};
std::vector<settings::SettingsInterfaceBase*> settings_; std::vector<settings::SettingsInterfaceBase*> settings_;
}; };
@ -1118,6 +1120,11 @@ void SettingsDialogImpl::SetupTextTab()
textSettings.placefile_text_drop_shadow_enabled()); textSettings.placefile_text_drop_shadow_enabled());
placefileTextDropShadowEnabled_.SetEditWidget( placefileTextDropShadowEnabled_.SetEditWidget(
self_->ui->placefileTextDropShadowCheckBox); self_->ui->placefileTextDropShadowCheckBox);
radarSiteHoverTextEnabled_.SetSettingsVariable(
textSettings.radar_site_hover_text_enabled());
radarSiteHoverTextEnabled_.SetEditWidget(
self_->ui->radarSiteHoverTextCheckBox);
} }
QImage SettingsDialogImpl::GenerateColorTableImage( QImage SettingsDialogImpl::GenerateColorTableImage(

View file

@ -373,8 +373,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>508</width> <width>514</width>
<height>383</height> <height>382</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
@ -873,27 +873,6 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<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">
<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="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="label_9">
<property name="text"> <property name="text">
@ -901,10 +880,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_8"> <widget class="QCheckBox" name="radarSiteHoverTextCheckBox">
<property name="text"> <property name="text">
<string>Hover text character wrap (0 to disable)</string> <string>Radar Site Hover Text Enabled</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -919,7 +898,35 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="1" column="1">
<widget class="QSpinBox" name="hoverTextWrapSpinBox">
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="resetHoverTextWrapButton">
<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="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="1">
<widget class="QComboBox" name="tooltipMethodComboBox"/>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="placefileTextDropShadowCheckBox"> <widget class="QCheckBox" name="placefileTextDropShadowCheckBox">
<property name="text"> <property name="text">
<string>Placefile Text Drop Shadow</string> <string>Placefile Text Drop Shadow</string>

@ -1 +1 @@
Subproject commit e3e743a5cc9c065d05f00151380fea892fb2156c Subproject commit 90331f7654586302b223d88329846929514bc883