Merge pull request #359 from AdenKoperczak/settings_tidy_and_checks

Settings tidy and checks
This commit is contained in:
Dan Paulat 2025-02-01 15:30:10 -06:00 committed by GitHub
commit 4038fb2c43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 323 additions and 397 deletions

View file

@ -60,6 +60,8 @@ public:
void WriteMarkerSettings(); void WriteMarkerSettings();
std::shared_ptr<MarkerRecord> GetMarkerByName(const std::string& name); std::shared_ptr<MarkerRecord> GetMarkerByName(const std::string& name);
bool markerFileRead_ {false};
void InitalizeIds(); void InitalizeIds();
types::MarkerId NewId(); types::MarkerId NewId();
types::MarkerId lastId_ {0}; types::MarkerId lastId_ {0};
@ -209,11 +211,16 @@ void MarkerManager::Impl::ReadMarkerSettings()
} }
} }
markerFileRead_ = true;
Q_EMIT self_->MarkersUpdated(); Q_EMIT self_->MarkersUpdated();
} }
void MarkerManager::Impl::WriteMarkerSettings() void MarkerManager::Impl::WriteMarkerSettings()
{ {
if (!markerFileRead_)
{
return;
}
logger_->info("Saving location marker settings"); logger_->info("Saving location marker settings");
const std::shared_lock lock(markerRecordLock_); const std::shared_lock lock(markerRecordLock_);

View file

@ -70,6 +70,8 @@ public:
boost::unordered_flat_map<std::string, std::shared_ptr<PlacefileRecord>> boost::unordered_flat_map<std::string, std::shared_ptr<PlacefileRecord>>
placefileRecordMap_ {}; placefileRecordMap_ {};
std::shared_mutex placefileRecordLock_ {}; std::shared_mutex placefileRecordLock_ {};
bool placefileSettingsRead_ {false};
}; };
class PlacefileManager::Impl::PlacefileRecord class PlacefileManager::Impl::PlacefileRecord
@ -413,10 +415,15 @@ void PlacefileManager::Impl::ReadPlacefileSettings()
} }
} }
} }
placefileSettingsRead_ = true;
} }
void PlacefileManager::Impl::WritePlacefileSettings() void PlacefileManager::Impl::WritePlacefileSettings()
{ {
if (!placefileSettingsRead_)
{
return;
}
logger_->info("Saving placefile settings"); logger_->info("Saving placefile settings");
std::shared_lock lock {placefileRecordLock_}; std::shared_lock lock {placefileRecordLock_};

View file

@ -67,9 +67,10 @@ void SettingsManager::Initialize()
} }
p->settingsPath_ = appDataPath + "/settings.json"; p->settingsPath_ = appDataPath + "/settings.json";
p->initialized_ = true;
ReadSettings(p->settingsPath_); ReadSettings(p->settingsPath_);
p->initialized_ = true;
p->ValidateSettings(); p->ValidateSettings();
} }

View file

@ -96,6 +96,8 @@ public:
manager::PlacefileManager::Instance()}; manager::PlacefileManager::Instance()};
types::LayerVector layers_ {}; types::LayerVector layers_ {};
bool fileRead_ {false};
}; };
LayerModel::LayerModel(QObject* parent) : LayerModel::LayerModel(QObject* parent) :
@ -201,6 +203,8 @@ void LayerModel::Impl::ReadLayerSettings()
// Assign read layers // Assign read layers
layers_.swap(newLayers); layers_.swap(newLayers);
} }
fileRead_ = true;
} }
void LayerModel::Impl::ValidateLayerSettings(types::LayerVector& layers) void LayerModel::Impl::ValidateLayerSettings(types::LayerVector& layers)
@ -314,6 +318,10 @@ void LayerModel::Impl::ValidateLayerSettings(types::LayerVector& layers)
void LayerModel::Impl::WriteLayerSettings() void LayerModel::Impl::WriteLayerSettings()
{ {
if (!fileRead_)
{
return;
}
logger_->info("Saving layer settings"); logger_->info("Saving layer settings");
auto layerJson = boost::json::value_from(layers_); auto layerJson = boost::json::value_from(layers_);

View file

@ -68,6 +68,8 @@ public:
scwx::common::Coordinate previousPosition_; scwx::common::Coordinate previousPosition_;
QIcon starIcon_ {":/res/icons/font-awesome-6/star-solid.svg"}; QIcon starIcon_ {":/res/icons/font-awesome-6/star-solid.svg"};
bool presetsRead_ {false};
}; };
RadarSiteModel::RadarSiteModel(QObject* parent) : RadarSiteModel::RadarSiteModel(QObject* parent) :
@ -146,10 +148,15 @@ void RadarSiteModelImpl::ReadPresets()
} }
} }
} }
presetsRead_ = true;
} }
void RadarSiteModelImpl::WritePresets() void RadarSiteModelImpl::WritePresets()
{ {
if (!presetsRead_)
{
return;
}
logger_->info("Saving presets"); logger_->info("Saving presets");
auto presetsJson = boost::json::value_from(presets_); auto presetsJson = boost::json::value_from(presets_);

View file

@ -7,11 +7,7 @@
#include <boost/gil.hpp> #include <boost/gil.hpp>
#include <boost/unordered/unordered_flat_map.hpp> #include <boost/unordered/unordered_flat_map.hpp>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = static const std::string logPrefix_ =
@ -139,7 +135,12 @@ public:
SetDefaultLineData(inactive_, kInactivePalettes_.at(phenomenon)); SetDefaultLineData(inactive_, kInactivePalettes_.at(phenomenon));
} }
~Impl() {}
~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
static void SetDefaultLineData(LineSettings& lineSettings, static void SetDefaultLineData(LineSettings& lineSettings,
const LineData& lineData); const LineData& lineData);
@ -236,6 +237,4 @@ bool operator==(const AlertPaletteSettings& lhs,
lhs.p->tornadoPossible_ == rhs.p->tornadoPossible_); lhs.p->tornadoPossible_ == rhs.p->tornadoPossible_);
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -8,18 +8,14 @@
#include <memory> #include <memory>
#include <string> #include <string>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class AlertPaletteSettings : public SettingsCategory class AlertPaletteSettings : public SettingsCategory
{ {
public: public:
explicit AlertPaletteSettings(awips::Phenomenon phenomenon); explicit AlertPaletteSettings(awips::Phenomenon phenomenon);
~AlertPaletteSettings(); ~AlertPaletteSettings() override;
AlertPaletteSettings(const AlertPaletteSettings&) = delete; AlertPaletteSettings(const AlertPaletteSettings&) = delete;
AlertPaletteSettings& operator=(const AlertPaletteSettings&) = delete; AlertPaletteSettings& operator=(const AlertPaletteSettings&) = delete;
@ -27,11 +23,11 @@ public:
AlertPaletteSettings(AlertPaletteSettings&&) noexcept; AlertPaletteSettings(AlertPaletteSettings&&) noexcept;
AlertPaletteSettings& operator=(AlertPaletteSettings&&) noexcept; AlertPaletteSettings& operator=(AlertPaletteSettings&&) noexcept;
LineSettings& [[nodiscard]] LineSettings&
threat_category(awips::ibw::ThreatCategory threatCategory) const; threat_category(awips::ibw::ThreatCategory threatCategory) const;
LineSettings& inactive() const; [[nodiscard]] LineSettings& inactive() const;
LineSettings& observed() const; [[nodiscard]] LineSettings& observed() const;
LineSettings& tornado_possible() const; [[nodiscard]] LineSettings& tornado_possible() const;
friend bool operator==(const AlertPaletteSettings& lhs, friend bool operator==(const AlertPaletteSettings& lhs,
const AlertPaletteSettings& rhs); const AlertPaletteSettings& rhs);
@ -41,6 +37,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -9,11 +9,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <fmt/format.h> #include <fmt/format.h>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::audio_settings"; static const std::string logPrefix_ = "scwx::qt::settings::audio_settings";
@ -33,6 +29,8 @@ public:
boost::to_lower(defaultAlertLocationMethodValue); boost::to_lower(defaultAlertLocationMethodValue);
// SetDefault, SetMinimum and SetMaximum are descriptive
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
alertSoundFile_.SetDefault(defaultAlertSoundFileValue); alertSoundFile_.SetDefault(defaultAlertSoundFileValue);
alertLocationMethod_.SetDefault(defaultAlertLocationMethodValue); alertLocationMethod_.SetDefault(defaultAlertLocationMethodValue);
alertLatitude_.SetDefault(0.0); alertLatitude_.SetDefault(0.0);
@ -48,7 +46,7 @@ public:
alertLongitude_.SetMaximum(180.0); alertLongitude_.SetMaximum(180.0);
alertRadius_.SetMinimum(0.0); alertRadius_.SetMinimum(0.0);
alertRadius_.SetMaximum(9999999999); alertRadius_.SetMaximum(9999999999);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
alertLocationMethod_.SetValidator( alertLocationMethod_.SetValidator(
SCWX_SETTINGS_ENUM_VALIDATOR(types::LocationMethod, SCWX_SETTINGS_ENUM_VALIDATOR(types::LocationMethod,
@ -94,7 +92,11 @@ public:
SettingsVariable<bool> {"alert_disabled"}); SettingsVariable<bool> {"alert_disabled"});
} }
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
SettingsVariable<std::string> alertSoundFile_ {"alert_sound_file"}; SettingsVariable<std::string> alertSoundFile_ {"alert_sound_file"};
SettingsVariable<std::string> alertLocationMethod_ {"alert_location_method"}; SettingsVariable<std::string> alertLocationMethod_ {"alert_location_method"};
@ -208,6 +210,4 @@ bool operator==(const AudioSettings& lhs, const AudioSettings& rhs)
lhs.p->alertEnabled_ == rhs.p->alertEnabled_); lhs.p->alertEnabled_ == rhs.p->alertEnabled_);
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -7,18 +7,14 @@
#include <memory> #include <memory>
#include <string> #include <string>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class AudioSettings : public SettingsCategory class AudioSettings : public SettingsCategory
{ {
public: public:
explicit AudioSettings(); explicit AudioSettings();
~AudioSettings(); ~AudioSettings() override;
AudioSettings(const AudioSettings&) = delete; AudioSettings(const AudioSettings&) = delete;
AudioSettings& operator=(const AudioSettings&) = delete; AudioSettings& operator=(const AudioSettings&) = delete;
@ -26,16 +22,17 @@ public:
AudioSettings(AudioSettings&&) noexcept; AudioSettings(AudioSettings&&) noexcept;
AudioSettings& operator=(AudioSettings&&) noexcept; AudioSettings& operator=(AudioSettings&&) noexcept;
SettingsVariable<std::string>& alert_sound_file() const; [[nodiscard]] SettingsVariable<std::string>& alert_sound_file() const;
SettingsVariable<std::string>& alert_location_method() const; [[nodiscard]] SettingsVariable<std::string>& alert_location_method() const;
SettingsVariable<double>& alert_latitude() const; [[nodiscard]] SettingsVariable<double>& alert_latitude() const;
SettingsVariable<double>& alert_longitude() const; [[nodiscard]] SettingsVariable<double>& alert_longitude() const;
SettingsVariable<double>& alert_radius() const; [[nodiscard]] SettingsVariable<double>& alert_radius() const;
SettingsVariable<std::string>& alert_radar_site() const; [[nodiscard]] SettingsVariable<std::string>& alert_radar_site() const;
SettingsVariable<std::string>& alert_county() const; [[nodiscard]] SettingsVariable<std::string>& alert_county() const;
SettingsVariable<std::string>& alert_wfo() const; [[nodiscard]] SettingsVariable<std::string>& alert_wfo() const;
SettingsVariable<bool>& alert_enabled(awips::Phenomenon phenomenon) const; [[nodiscard]] SettingsVariable<bool>&
SettingsVariable<bool>& ignore_missing_codecs() const; alert_enabled(awips::Phenomenon phenomenon) const;
[[nodiscard]] SettingsVariable<bool>& ignore_missing_codecs() const;
static AudioSettings& Instance(); static AudioSettings& Instance();
@ -46,6 +43,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -8,16 +8,10 @@
#include <scwx/qt/types/time_types.hpp> #include <scwx/qt/types/time_types.hpp>
#include <scwx/util/time.hpp> #include <scwx/util/time.hpp>
#include <array>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <QUrl> #include <QUrl>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::general_settings"; static const std::string logPrefix_ = "scwx::qt::settings::general_settings";
@ -50,6 +44,8 @@ public:
boost::to_lower(defaultPositioningPlugin); boost::to_lower(defaultPositioningPlugin);
boost::to_lower(defaultThemeValue); boost::to_lower(defaultThemeValue);
// SetDefault, SetMinimum, and SetMaximum are descriptive
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
antiAliasingEnabled_.SetDefault(true); antiAliasingEnabled_.SetDefault(true);
clockFormat_.SetDefault(defaultClockFormatValue); clockFormat_.SetDefault(defaultClockFormatValue);
customStyleDrawLayer_.SetDefault(".*\\.annotations\\.points"); customStyleDrawLayer_.SetDefault(".*\\.annotations\\.points");
@ -100,6 +96,7 @@ public:
nmeaBaudRate_.SetMaximum(999999999); nmeaBaudRate_.SetMaximum(999999999);
radarSiteThreshold_.SetMinimum(-10000); radarSiteThreshold_.SetMinimum(-10000);
radarSiteThreshold_.SetMaximum(10000); radarSiteThreshold_.SetMaximum(10000);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
customStyleDrawLayer_.SetTransform([](const std::string& value) customStyleDrawLayer_.SetTransform([](const std::string& value)
{ return boost::trim_copy(value); }); { return boost::trim_copy(value); });
@ -141,7 +138,11 @@ public:
{ return QUrl {QString::fromStdString(value)}.isValid(); }); { return QUrl {QString::fromStdString(value)}.isValid(); });
} }
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
SettingsVariable<bool> antiAliasingEnabled_ {"anti_aliasing_enabled"}; SettingsVariable<bool> antiAliasingEnabled_ {"anti_aliasing_enabled"};
SettingsVariable<std::string> clockFormat_ {"clock_format"}; SettingsVariable<std::string> clockFormat_ {"clock_format"};
@ -444,6 +445,4 @@ bool operator==(const GeneralSettings& lhs, const GeneralSettings& rhs)
rhs.p->highPrivilegeWarningEnabled_); rhs.p->highPrivilegeWarningEnabled_);
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -6,18 +6,14 @@
#include <memory> #include <memory>
#include <string> #include <string>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class GeneralSettings : public SettingsCategory class GeneralSettings : public SettingsCategory
{ {
public: public:
explicit GeneralSettings(); explicit GeneralSettings();
~GeneralSettings(); ~GeneralSettings() override;
GeneralSettings(const GeneralSettings&) = delete; GeneralSettings(const GeneralSettings&) = delete;
GeneralSettings& operator=(const GeneralSettings&) = delete; GeneralSettings& operator=(const GeneralSettings&) = delete;
@ -25,38 +21,40 @@ public:
GeneralSettings(GeneralSettings&&) noexcept; GeneralSettings(GeneralSettings&&) noexcept;
GeneralSettings& operator=(GeneralSettings&&) noexcept; GeneralSettings& operator=(GeneralSettings&&) noexcept;
SettingsVariable<bool>& anti_aliasing_enabled() const; [[nodiscard]] SettingsVariable<bool>& anti_aliasing_enabled() const;
SettingsVariable<std::string>& clock_format() const; [[nodiscard]] SettingsVariable<std::string>& clock_format() const;
SettingsVariable<std::string>& custom_style_draw_layer() const; [[nodiscard]] SettingsVariable<std::string>& custom_style_draw_layer() const;
SettingsVariable<std::string>& custom_style_url() const; [[nodiscard]] SettingsVariable<std::string>& custom_style_url() const;
SettingsVariable<bool>& debug_enabled() const; [[nodiscard]] SettingsVariable<bool>& debug_enabled() const;
SettingsVariable<std::string>& default_alert_action() const; [[nodiscard]] SettingsVariable<std::string>& default_alert_action() const;
SettingsVariable<std::string>& default_radar_site() const; [[nodiscard]] SettingsVariable<std::string>& default_radar_site() const;
SettingsVariable<std::string>& default_time_zone() const; [[nodiscard]] SettingsVariable<std::string>& default_time_zone() const;
SettingsContainer<std::vector<std::int64_t>>& font_sizes() const; [[nodiscard]] SettingsContainer<std::vector<std::int64_t>>&
SettingsVariable<std::int64_t>& grid_height() const; font_sizes() const;
SettingsVariable<std::int64_t>& grid_width() const; [[nodiscard]] SettingsVariable<std::int64_t>& grid_height() const;
SettingsVariable<std::int64_t>& loop_delay() const; [[nodiscard]] SettingsVariable<std::int64_t>& grid_width() const;
SettingsVariable<double>& loop_speed() const; [[nodiscard]] SettingsVariable<std::int64_t>& loop_delay() const;
SettingsVariable<std::int64_t>& loop_time() const; [[nodiscard]] SettingsVariable<double>& loop_speed() const;
SettingsVariable<std::string>& map_provider() const; [[nodiscard]] SettingsVariable<std::int64_t>& loop_time() const;
SettingsVariable<std::string>& mapbox_api_key() const; [[nodiscard]] SettingsVariable<std::string>& map_provider() const;
SettingsVariable<std::string>& maptiler_api_key() const; [[nodiscard]] SettingsVariable<std::string>& mapbox_api_key() const;
SettingsVariable<std::int64_t>& nmea_baud_rate() const; [[nodiscard]] SettingsVariable<std::string>& maptiler_api_key() const;
SettingsVariable<std::string>& nmea_source() const; [[nodiscard]] SettingsVariable<std::int64_t>& nmea_baud_rate() const;
SettingsVariable<std::string>& positioning_plugin() const; [[nodiscard]] SettingsVariable<std::string>& nmea_source() const;
SettingsVariable<bool>& process_module_warnings_enabled() const; [[nodiscard]] SettingsVariable<std::string>& positioning_plugin() const;
SettingsVariable<bool>& show_map_attribution() const; [[nodiscard]] SettingsVariable<bool>&
SettingsVariable<bool>& show_map_center() const; process_module_warnings_enabled() const;
SettingsVariable<bool>& show_map_logo() const; [[nodiscard]] SettingsVariable<bool>& show_map_attribution() const;
SettingsVariable<std::string>& theme() const; [[nodiscard]] SettingsVariable<bool>& show_map_center() const;
SettingsVariable<std::string>& theme_file() const; [[nodiscard]] SettingsVariable<bool>& show_map_logo() const;
SettingsVariable<bool>& track_location() const; [[nodiscard]] SettingsVariable<std::string>& theme() const;
SettingsVariable<bool>& update_notifications_enabled() const; [[nodiscard]] SettingsVariable<std::string>& theme_file() const;
SettingsVariable<std::string>& warnings_provider() const; [[nodiscard]] SettingsVariable<bool>& track_location() const;
SettingsVariable<bool>& cursor_icon_always_on() const; [[nodiscard]] SettingsVariable<bool>& update_notifications_enabled() const;
SettingsVariable<double>& radar_site_threshold() const; [[nodiscard]] SettingsVariable<std::string>& warnings_provider() const;
SettingsVariable<bool>& high_privilege_warning_enabled() const; [[nodiscard]] SettingsVariable<bool>& cursor_icon_always_on() const;
[[nodiscard]] SettingsVariable<double>& radar_site_threshold() const;
[[nodiscard]] SettingsVariable<bool>& high_privilege_warning_enabled() const;
static GeneralSettings& Instance(); static GeneralSettings& Instance();
@ -70,6 +68,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -2,11 +2,7 @@
#include <QKeySequence> #include <QKeySequence>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::hotkey_settings"; static const std::string logPrefix_ = "scwx::qt::settings::hotkey_settings";
@ -94,7 +90,11 @@ public:
SettingsVariable<std::string> {"?"}); SettingsVariable<std::string> {"?"});
} }
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
std::unordered_map<types::Hotkey, SettingsVariable<std::string>> hotkey_ {}; std::unordered_map<types::Hotkey, SettingsVariable<std::string>> hotkey_ {};
std::vector<SettingsVariableBase*> variables_ {}; std::vector<SettingsVariableBase*> variables_ {};
@ -142,6 +142,4 @@ static bool IsHotkeyValid(const std::string& value)
.toStdString() == value; .toStdString() == value;
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -7,18 +7,14 @@
#include <memory> #include <memory>
#include <string> #include <string>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class HotkeySettings : public SettingsCategory class HotkeySettings : public SettingsCategory
{ {
public: public:
explicit HotkeySettings(); explicit HotkeySettings();
~HotkeySettings(); ~HotkeySettings() override;
HotkeySettings(const HotkeySettings&) = delete; HotkeySettings(const HotkeySettings&) = delete;
HotkeySettings& operator=(const HotkeySettings&) = delete; HotkeySettings& operator=(const HotkeySettings&) = delete;
@ -26,7 +22,8 @@ public:
HotkeySettings(HotkeySettings&&) noexcept; HotkeySettings(HotkeySettings&&) noexcept;
HotkeySettings& operator=(HotkeySettings&&) noexcept; HotkeySettings& operator=(HotkeySettings&&) noexcept;
SettingsVariable<std::string>& hotkey(scwx::qt::types::Hotkey hotkey) const; [[nodiscard]] SettingsVariable<std::string>&
hotkey(scwx::qt::types::Hotkey hotkey) const;
static HotkeySettings& Instance(); static HotkeySettings& Instance();
@ -37,6 +34,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -1,11 +1,7 @@
#include <scwx/qt/settings/line_settings.hpp> #include <scwx/qt/settings/line_settings.hpp>
#include <scwx/qt/util/color.hpp> #include <scwx/qt/util/color.hpp>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::line_settings"; static const std::string logPrefix_ = "scwx::qt::settings::line_settings";
@ -27,6 +23,8 @@ class LineSettings::Impl
public: public:
explicit Impl() explicit Impl()
{ {
// SetDefault, SetMinimum, and SetMaximum are descriptive
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
lineColor_.SetDefault(kWhiteColorString_); lineColor_.SetDefault(kWhiteColorString_);
highlightColor_.SetDefault(kTransparentColorString_); highlightColor_.SetDefault(kTransparentColorString_);
borderColor_.SetDefault(kBlackColorString_); borderColor_.SetDefault(kBlackColorString_);
@ -42,12 +40,18 @@ public:
lineWidth_.SetMaximum(9); lineWidth_.SetMaximum(9);
highlightWidth_.SetMaximum(9); highlightWidth_.SetMaximum(9);
borderWidth_.SetMaximum(9); borderWidth_.SetMaximum(9);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
lineColor_.SetValidator(&util::color::ValidateArgbString); lineColor_.SetValidator(&util::color::ValidateArgbString);
highlightColor_.SetValidator(&util::color::ValidateArgbString); highlightColor_.SetValidator(&util::color::ValidateArgbString);
borderColor_.SetValidator(&util::color::ValidateArgbString); borderColor_.SetValidator(&util::color::ValidateArgbString);
} }
~Impl() {}
~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
SettingsVariable<std::string> lineColor_ {"line_color"}; SettingsVariable<std::string> lineColor_ {"line_color"};
SettingsVariable<std::string> highlightColor_ {"highlight_color"}; SettingsVariable<std::string> highlightColor_ {"highlight_color"};
@ -150,6 +154,4 @@ bool operator==(const LineSettings& lhs, const LineSettings& rhs)
lhs.p->lineWidth_ == rhs.p->lineWidth_); lhs.p->lineWidth_ == rhs.p->lineWidth_);
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -8,18 +8,14 @@
#include <boost/gil/typedefs.hpp> #include <boost/gil/typedefs.hpp>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class LineSettings : public SettingsCategory class LineSettings : public SettingsCategory
{ {
public: public:
explicit LineSettings(const std::string& name); explicit LineSettings(const std::string& name);
~LineSettings(); ~LineSettings() override;
LineSettings(const LineSettings&) = delete; LineSettings(const LineSettings&) = delete;
LineSettings& operator=(const LineSettings&) = delete; LineSettings& operator=(const LineSettings&) = delete;
@ -27,17 +23,17 @@ public:
LineSettings(LineSettings&&) noexcept; LineSettings(LineSettings&&) noexcept;
LineSettings& operator=(LineSettings&&) noexcept; LineSettings& operator=(LineSettings&&) noexcept;
SettingsVariable<std::string>& border_color() const; [[nodiscard]] SettingsVariable<std::string>& border_color() const;
SettingsVariable<std::string>& highlight_color() const; [[nodiscard]] SettingsVariable<std::string>& highlight_color() const;
SettingsVariable<std::string>& line_color() const; [[nodiscard]] SettingsVariable<std::string>& line_color() const;
SettingsVariable<std::int64_t>& border_width() const; [[nodiscard]] SettingsVariable<std::int64_t>& border_width() const;
SettingsVariable<std::int64_t>& highlight_width() const; [[nodiscard]] SettingsVariable<std::int64_t>& highlight_width() const;
SettingsVariable<std::int64_t>& line_width() const; [[nodiscard]] SettingsVariable<std::int64_t>& line_width() const;
boost::gil::rgba32f_pixel_t GetBorderColorRgba32f() const; [[nodiscard]] boost::gil::rgba32f_pixel_t GetBorderColorRgba32f() const;
boost::gil::rgba32f_pixel_t GetHighlightColorRgba32f() const; [[nodiscard]] boost::gil::rgba32f_pixel_t GetHighlightColorRgba32f() const;
boost::gil::rgba32f_pixel_t GetLineColorRgba32f() const; [[nodiscard]] boost::gil::rgba32f_pixel_t GetLineColorRgba32f() const;
void StageValues(boost::gil::rgba8_pixel_t borderColor, void StageValues(boost::gil::rgba8_pixel_t borderColor,
boost::gil::rgba8_pixel_t highlightColor, boost::gil::rgba8_pixel_t highlightColor,
@ -53,6 +49,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -9,11 +9,7 @@
#include <boost/json.hpp> #include <boost/json.hpp>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::map_settings"; static const std::string logPrefix_ = "scwx::qt::settings::map_settings";
@ -104,7 +100,11 @@ public:
} }
} }
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
void SetDefaults(std::size_t i) void SetDefaults(std::size_t i)
{ {
@ -276,6 +276,4 @@ bool operator==(const MapSettings& lhs, const MapSettings& rhs)
return (lhs.p->map_ == rhs.p->map_); return (lhs.p->map_ == rhs.p->map_);
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -6,18 +6,14 @@
#include <memory> #include <memory>
#include <string> #include <string>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class MapSettings : public SettingsCategory class MapSettings : public SettingsCategory
{ {
public: public:
explicit MapSettings(); explicit MapSettings();
~MapSettings(); ~MapSettings() override;
MapSettings(const MapSettings&) = delete; MapSettings(const MapSettings&) = delete;
MapSettings& operator=(const MapSettings&) = delete; MapSettings& operator=(const MapSettings&) = delete;
@ -25,7 +21,7 @@ public:
MapSettings(MapSettings&&) noexcept; MapSettings(MapSettings&&) noexcept;
MapSettings& operator=(MapSettings&&) noexcept; MapSettings& operator=(MapSettings&&) noexcept;
std::size_t count() const; [[nodiscard]] std::size_t count() const;
SettingsVariable<std::string>& map_style(std::size_t i); SettingsVariable<std::string>& map_style(std::size_t i);
SettingsVariable<std::string>& radar_site(std::size_t i); SettingsVariable<std::string>& radar_site(std::size_t i);
SettingsVariable<std::string>& radar_product_group(std::size_t i); SettingsVariable<std::string>& radar_product_group(std::size_t i);
@ -60,6 +56,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -6,11 +6,7 @@
#include <boost/gil.hpp> #include <boost/gil.hpp>
#include <fmt/format.h> #include <fmt/format.h>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::palette_settings"; static const std::string logPrefix_ = "scwx::qt::settings::palette_settings";
@ -83,7 +79,11 @@ public:
InitializeAlerts(); InitializeAlerts();
} }
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
void InitializeColorTables(); void InitializeColorTables();
void InitializeLegacyAlerts(); void InitializeLegacyAlerts();
@ -252,6 +252,4 @@ bool operator==(const PaletteSettings& lhs, const PaletteSettings& rhs)
lhs.p->inactiveAlertColor_ == rhs.p->inactiveAlertColor_); lhs.p->inactiveAlertColor_ == rhs.p->inactiveAlertColor_);
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -9,18 +9,14 @@
#include <memory> #include <memory>
#include <string> #include <string>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class PaletteSettings : public SettingsCategory class PaletteSettings : public SettingsCategory
{ {
public: public:
explicit PaletteSettings(); explicit PaletteSettings();
~PaletteSettings(); ~PaletteSettings() override;
PaletteSettings(const PaletteSettings&) = delete; PaletteSettings(const PaletteSettings&) = delete;
PaletteSettings& operator=(const PaletteSettings&) = delete; PaletteSettings& operator=(const PaletteSettings&) = delete;
@ -28,9 +24,10 @@ public:
PaletteSettings(PaletteSettings&&) noexcept; PaletteSettings(PaletteSettings&&) noexcept;
PaletteSettings& operator=(PaletteSettings&&) noexcept; PaletteSettings& operator=(PaletteSettings&&) noexcept;
SettingsVariable<std::string>& palette(const std::string& name) const; [[nodiscard]] SettingsVariable<std::string>&
SettingsVariable<std::string>& alert_color(awips::Phenomenon phenomenon, palette(const std::string& name) const;
bool active) const; [[nodiscard]] SettingsVariable<std::string>&
alert_color(awips::Phenomenon phenomenon, bool active) const;
AlertPaletteSettings& alert_palette(awips::Phenomenon); AlertPaletteSettings& alert_palette(awips::Phenomenon);
static const std::vector<awips::Phenomenon>& alert_phenomena(); static const std::vector<awips::Phenomenon>& alert_phenomena();
@ -45,6 +42,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -1,11 +1,9 @@
#include <scwx/qt/settings/product_settings.hpp> #include <scwx/qt/settings/product_settings.hpp>
#include <scwx/qt/settings/settings_container.hpp> #include <scwx/qt/settings/settings_container.hpp>
namespace scwx #include <string>
{
namespace qt namespace scwx::qt::settings
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::product_settings"; static const std::string logPrefix_ = "scwx::qt::settings::product_settings";
@ -15,12 +13,19 @@ class ProductSettings::Impl
public: public:
explicit Impl() explicit Impl()
{ {
// SetDefault, SetMinimum and SetMaximum are descriptive
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
showSmoothedRangeFolding_.SetDefault(false); showSmoothedRangeFolding_.SetDefault(false);
stiForecastEnabled_.SetDefault(true); stiForecastEnabled_.SetDefault(true);
stiPastEnabled_.SetDefault(true); stiPastEnabled_.SetDefault(true);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
} }
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
SettingsVariable<bool> showSmoothedRangeFolding_ { SettingsVariable<bool> showSmoothedRangeFolding_ {
"show_smoothed_range_folding"}; "show_smoothed_range_folding"};
@ -82,6 +87,4 @@ bool operator==(const ProductSettings& lhs, const ProductSettings& rhs)
lhs.p->stiPastEnabled_ == rhs.p->stiPastEnabled_); lhs.p->stiPastEnabled_ == rhs.p->stiPastEnabled_);
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -4,20 +4,15 @@
#include <scwx/qt/settings/settings_variable.hpp> #include <scwx/qt/settings/settings_variable.hpp>
#include <memory> #include <memory>
#include <string>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class ProductSettings : public SettingsCategory class ProductSettings : public SettingsCategory
{ {
public: public:
explicit ProductSettings(); explicit ProductSettings();
~ProductSettings(); ~ProductSettings() override;
ProductSettings(const ProductSettings&) = delete; ProductSettings(const ProductSettings&) = delete;
ProductSettings& operator=(const ProductSettings&) = delete; ProductSettings& operator=(const ProductSettings&) = delete;
@ -41,6 +36,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -4,11 +4,7 @@
#include <algorithm> #include <algorithm>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::settings_category"; static const std::string logPrefix_ = "scwx::qt::settings::settings_category";
@ -19,7 +15,11 @@ class SettingsCategory::Impl
public: public:
explicit Impl(const std::string& name) : name_ {name} {} explicit Impl(const std::string& name) : name_ {name} {}
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
void ConnectSubcategory(SettingsCategory& category); void ConnectSubcategory(SettingsCategory& category);
void ConnectVariable(SettingsVariableBase* variable); void ConnectVariable(SettingsVariableBase* variable);
@ -479,6 +479,4 @@ void SettingsCategory::Impl::ConnectVariable(SettingsVariableBase* variable)
})); }));
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -8,11 +8,7 @@
#include <boost/json/object.hpp> #include <boost/json/object.hpp>
#include <boost/signals2/signal.hpp> #include <boost/signals2/signal.hpp>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class SettingsCategory class SettingsCategory
@ -27,7 +23,7 @@ public:
SettingsCategory(SettingsCategory&&) noexcept; SettingsCategory(SettingsCategory&&) noexcept;
SettingsCategory& operator=(SettingsCategory&&) noexcept; SettingsCategory& operator=(SettingsCategory&&) noexcept;
std::string name() const; [[nodiscard]] std::string name() const;
/** /**
* Gets the signal invoked when a variable within the category is changed. * Gets the signal invoked when a variable within the category is changed.
@ -50,7 +46,7 @@ public:
* @return true if all settings variables are currently set to default * @return true if all settings variables are currently set to default
* values, otherwise false. * values, otherwise false.
*/ */
bool IsDefault() const; [[nodiscard]] bool IsDefault() const;
/** /**
* Gets whether or not all settings variables currently have staged values * Gets whether or not all settings variables currently have staged values
@ -59,7 +55,7 @@ public:
* @return true if all settings variables currently have staged values set * @return true if all settings variables currently have staged values set
* to default, otherwise false. * to default, otherwise false.
*/ */
bool IsDefaultStaged() const; [[nodiscard]] bool IsDefaultStaged() const;
/** /**
* Set all variables to their defaults. * Set all variables to their defaults.
@ -118,6 +114,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -1,11 +1,7 @@
#include <scwx/qt/settings/settings_container.hpp> #include <scwx/qt/settings/settings_container.hpp>
#include <scwx/util/logger.hpp> #include <scwx/util/logger.hpp>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::settings_container"; static const std::string logPrefix_ = "scwx::qt::settings::settings_container";
@ -15,9 +11,13 @@ template<class Container>
class SettingsContainer<Container>::Impl class SettingsContainer<Container>::Impl
{ {
public: public:
explicit Impl() {} explicit Impl() = default;
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
T elementDefault_ {}; T elementDefault_ {};
std::optional<T> elementMinimum_ {}; std::optional<T> elementMinimum_ {};
@ -172,6 +172,4 @@ bool SettingsContainer<Container>::Equals(const SettingsVariableBase& o) const
template class SettingsContainer<std::vector<std::int64_t>>; template class SettingsContainer<std::vector<std::int64_t>>;
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -2,11 +2,7 @@
#include <scwx/qt/settings/settings_variable.hpp> #include <scwx/qt/settings/settings_variable.hpp>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
template<class Container> template<class Container>
@ -92,13 +88,12 @@ public:
void SetElementValidator(std::function<bool(const T&)> validator); void SetElementValidator(std::function<bool(const T&)> validator);
protected: protected:
virtual bool Equals(const SettingsVariableBase& o) const override; [[nodiscard]] virtual bool
Equals(const SettingsVariableBase& o) const override;
private: private:
class Impl; class Impl;
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -12,12 +12,9 @@
#include <QLineEdit> #include <QLineEdit>
#include <QSpinBox> #include <QSpinBox>
#include <QWidget> #include <QWidget>
#include <vector>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::settings_interface"; static const std::string logPrefix_ = "scwx::qt::settings::settings_interface";
@ -31,7 +28,11 @@ public:
context_->moveToThread(QCoreApplication::instance()->thread()); context_->moveToThread(QCoreApplication::instance()->thread());
} }
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
template<class U> template<class U>
void SetWidgetText(U* widget, const T& currentValue); void SetWidgetText(U* widget, const T& currentValue);
@ -633,6 +634,4 @@ template class SettingsInterface<std::string>;
// Containers are not to be used directly // Containers are not to be used directly
template class SettingsInterface<std::vector<std::int64_t>>; template class SettingsInterface<std::vector<std::int64_t>>;
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -5,15 +5,10 @@
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector>
class QLabel; class QLabel;
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
template<class T> template<class T>
@ -140,6 +135,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -2,11 +2,7 @@
#include <string> #include <string>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = static const std::string logPrefix_ =
@ -15,8 +11,12 @@ static const std::string logPrefix_ =
class SettingsInterfaceBase::Impl class SettingsInterfaceBase::Impl
{ {
public: public:
explicit Impl() {} explicit Impl() = default;
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
}; };
SettingsInterfaceBase::SettingsInterfaceBase() : p(std::make_unique<Impl>()) {} SettingsInterfaceBase::SettingsInterfaceBase() : p(std::make_unique<Impl>()) {}
@ -29,6 +29,4 @@ SettingsInterfaceBase::SettingsInterfaceBase(SettingsInterfaceBase&&) noexcept =
SettingsInterfaceBase& SettingsInterfaceBase&
SettingsInterfaceBase::operator=(SettingsInterfaceBase&&) noexcept = default; SettingsInterfaceBase::operator=(SettingsInterfaceBase&&) noexcept = default;
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -5,11 +5,7 @@
class QAbstractButton; class QAbstractButton;
class QWidget; class QWidget;
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class SettingsInterfaceBase class SettingsInterfaceBase
@ -70,6 +66,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -7,11 +7,7 @@
#include <fmt/ostream.h> #include <fmt/ostream.h>
#include <fmt/ranges.h> #include <fmt/ranges.h>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::settings_variable"; static const std::string logPrefix_ = "scwx::qt::settings::settings_variable";
@ -21,8 +17,12 @@ template<class T>
class SettingsVariable<T>::Impl class SettingsVariable<T>::Impl
{ {
public: public:
explicit Impl() {} explicit Impl() = default;
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
T value_ {}; T value_ {};
T default_ {}; T default_ {};
@ -439,6 +439,4 @@ template class SettingsVariable<std::string>;
// Containers are not to be used directly // Containers are not to be used directly
template class SettingsVariable<std::vector<std::int64_t>>; template class SettingsVariable<std::vector<std::int64_t>>;
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -10,11 +10,7 @@
class QAbstractButton; class QAbstractButton;
class QWidget; class QWidget;
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
template<class T> template<class T>
@ -250,13 +246,12 @@ public:
void UnregisterValueStagedCallback(boost::uuids::uuid uuid); void UnregisterValueStagedCallback(boost::uuids::uuid uuid);
protected: protected:
virtual bool Equals(const SettingsVariableBase& o) const override; [[nodiscard]] virtual bool
Equals(const SettingsVariableBase& o) const override;
private: private:
class Impl; class Impl;
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -1,10 +1,6 @@
#include <scwx/qt/settings/settings_variable_base.hpp> #include <scwx/qt/settings/settings_variable_base.hpp>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = static const std::string logPrefix_ =
@ -15,7 +11,11 @@ class SettingsVariableBase::Impl
public: public:
explicit Impl(const std::string& name) : name_ {name} {} explicit Impl(const std::string& name) : name_ {name} {}
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
const std::string name_; const std::string name_;
@ -62,6 +62,4 @@ bool operator==(const SettingsVariableBase& lhs,
return typeid(lhs) == typeid(rhs) && lhs.Equals(rhs); return typeid(lhs) == typeid(rhs) && lhs.Equals(rhs);
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -6,11 +6,7 @@
#include <boost/json/object.hpp> #include <boost/json/object.hpp>
#include <boost/signals2/signal.hpp> #include <boost/signals2/signal.hpp>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
/** /**
@ -29,7 +25,7 @@ public:
SettingsVariableBase(SettingsVariableBase&&) noexcept; SettingsVariableBase(SettingsVariableBase&&) noexcept;
SettingsVariableBase& operator=(SettingsVariableBase&&) noexcept; SettingsVariableBase& operator=(SettingsVariableBase&&) noexcept;
std::string name() const; [[nodiscard]] std::string name() const;
/** /**
* Gets the signal invoked when the settings variable is changed. * Gets the signal invoked when the settings variable is changed.
@ -52,7 +48,7 @@ public:
* @return true if the settings variable is currently set to its default * @return true if the settings variable is currently set to its default
* value, otherwise false. * value, otherwise false.
*/ */
virtual bool IsDefault() const = 0; [[nodiscard]] virtual bool IsDefault() const = 0;
/** /**
* Gets whether or not the settings variable currently has its staged value * Gets whether or not the settings variable currently has its staged value
@ -61,7 +57,7 @@ public:
* @return true if the settings variable currently has its staged value set * @return true if the settings variable currently has its staged value set
* to default, otherwise false. * to default, otherwise false.
*/ */
virtual bool IsDefaultStaged() const = 0; [[nodiscard]] virtual bool IsDefaultStaged() const = 0;
/** /**
* Sets the current value of the settings variable to default. * Sets the current value of the settings variable to default.
@ -107,7 +103,7 @@ public:
protected: protected:
friend bool operator==(const SettingsVariableBase& lhs, friend bool operator==(const SettingsVariableBase& lhs,
const SettingsVariableBase& rhs); const SettingsVariableBase& rhs);
virtual bool Equals(const SettingsVariableBase& o) const; [[nodiscard]] virtual bool Equals(const SettingsVariableBase& o) const;
private: private:
class Impl; class Impl;
@ -117,6 +113,4 @@ private:
bool operator==(const SettingsVariableBase& lhs, bool operator==(const SettingsVariableBase& lhs,
const SettingsVariableBase& rhs); const SettingsVariableBase& rhs);
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -3,11 +3,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::text_settings"; static const std::string logPrefix_ = "scwx::qt::settings::text_settings";
@ -50,12 +46,15 @@ public:
boost::to_lower(defaultTooltipMethodValue); boost::to_lower(defaultTooltipMethodValue);
// SetDefault, SetMinimum and SetMaximum are descriptive
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
hoverTextWrap_.SetDefault(80); hoverTextWrap_.SetDefault(80);
hoverTextWrap_.SetMinimum(0); hoverTextWrap_.SetMinimum(0);
hoverTextWrap_.SetMaximum(999); hoverTextWrap_.SetMaximum(999);
placefileTextDropShadowEnabled_.SetDefault(true); placefileTextDropShadowEnabled_.SetDefault(true);
radarSiteHoverTextEnabled_.SetDefault(true); radarSiteHoverTextEnabled_.SetDefault(true);
tooltipMethod_.SetDefault(defaultTooltipMethodValue); tooltipMethod_.SetDefault(defaultTooltipMethodValue);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
tooltipMethod_.SetValidator( tooltipMethod_.SetValidator(
[](const std::string& value) [](const std::string& value)
@ -81,7 +80,11 @@ public:
InitializeFontVariables(); InitializeFontVariables();
} }
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
void InitializeFontVariables(); void InitializeFontVariables();
@ -141,8 +144,11 @@ void TextSettings::Impl::InitializeFontVariables()
{ return !value.empty(); }); { return !value.empty(); });
// Font point size must be between 6 and 72 // Font point size must be between 6 and 72
// SetDefault, SetMinimum and SetMaximum are descriptive
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
font.fontPointSize_.SetMinimum(6.0); font.fontPointSize_.SetMinimum(6.0);
font.fontPointSize_.SetMaximum(72.0); font.fontPointSize_.SetMaximum(72.0);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
// Variable registration // Variable registration
auto& settings = fontSettings_.emplace_back( auto& settings = fontSettings_.emplace_back(
@ -210,6 +216,4 @@ bool operator==(const TextSettings& lhs, const TextSettings& rhs)
lhs.p->tooltipMethod_ == rhs.p->tooltipMethod_); lhs.p->tooltipMethod_ == rhs.p->tooltipMethod_);
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -7,18 +7,14 @@
#include <memory> #include <memory>
#include <string> #include <string>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class TextSettings : public SettingsCategory class TextSettings : public SettingsCategory
{ {
public: public:
explicit TextSettings(); explicit TextSettings();
~TextSettings(); ~TextSettings() override;
TextSettings(const TextSettings&) = delete; TextSettings(const TextSettings&) = delete;
TextSettings& operator=(const TextSettings&) = delete; TextSettings& operator=(const TextSettings&) = delete;
@ -26,17 +22,18 @@ public:
TextSettings(TextSettings&&) noexcept; TextSettings(TextSettings&&) noexcept;
TextSettings& operator=(TextSettings&&) noexcept; TextSettings& operator=(TextSettings&&) noexcept;
SettingsVariable<std::string>& [[nodiscard]] SettingsVariable<std::string>&
font_family(types::FontCategory fontCategory) const; font_family(types::FontCategory fontCategory) const;
SettingsVariable<std::string>& [[nodiscard]] SettingsVariable<std::string>&
font_style(types::FontCategory fontCategory) const; font_style(types::FontCategory fontCategory) const;
SettingsVariable<double>& [[nodiscard]] SettingsVariable<double>&
font_point_size(types::FontCategory fontCategory) const; font_point_size(types::FontCategory fontCategory) const;
SettingsVariable<std::int64_t>& hover_text_wrap() const; [[nodiscard]] SettingsVariable<std::int64_t>& hover_text_wrap() const;
SettingsVariable<bool>& placefile_text_drop_shadow_enabled() const; [[nodiscard]] SettingsVariable<bool>&
SettingsVariable<bool>& radar_site_hover_text_enabled() const; placefile_text_drop_shadow_enabled() const;
SettingsVariable<std::string>& tooltip_method() const; [[nodiscard]] SettingsVariable<bool>& radar_site_hover_text_enabled() const;
[[nodiscard]] SettingsVariable<std::string>& tooltip_method() const;
static TextSettings& Instance(); static TextSettings& Instance();
@ -48,6 +45,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -1,10 +1,6 @@
#include <scwx/qt/settings/ui_settings.hpp> #include <scwx/qt/settings/ui_settings.hpp>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::ui_settings"; static const std::string logPrefix_ = "scwx::qt::settings::ui_settings";
@ -14,6 +10,8 @@ class UiSettingsImpl
public: public:
explicit UiSettingsImpl() explicit UiSettingsImpl()
{ {
// SetDefault, SetMinimum and SetMaximum are descriptive
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
level2ProductsExpanded_.SetDefault(false); level2ProductsExpanded_.SetDefault(false);
level2SettingsExpanded_.SetDefault(true); level2SettingsExpanded_.SetDefault(true);
level3ProductsExpanded_.SetDefault(true); level3ProductsExpanded_.SetDefault(true);
@ -21,9 +19,14 @@ public:
timelineExpanded_.SetDefault(true); timelineExpanded_.SetDefault(true);
mainUIState_.SetDefault(""); mainUIState_.SetDefault("");
mainUIGeometry_.SetDefault(""); mainUIGeometry_.SetDefault("");
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
} }
~UiSettingsImpl() {} ~UiSettingsImpl() = default;
UiSettingsImpl(const UiSettingsImpl&) = delete;
UiSettingsImpl& operator=(const UiSettingsImpl&) = delete;
UiSettingsImpl(const UiSettingsImpl&&) = delete;
UiSettingsImpl& operator=(const UiSettingsImpl&&) = delete;
SettingsVariable<bool> level2ProductsExpanded_ {"level2_products_expanded"}; SettingsVariable<bool> level2ProductsExpanded_ {"level2_products_expanded"};
SettingsVariable<bool> level2SettingsExpanded_ {"level2_settings_expanded"}; SettingsVariable<bool> level2SettingsExpanded_ {"level2_settings_expanded"};
@ -119,6 +122,4 @@ bool operator==(const UiSettings& lhs, const UiSettings& rhs)
lhs.p->mainUIGeometry_ == rhs.p->mainUIGeometry_); lhs.p->mainUIGeometry_ == rhs.p->mainUIGeometry_);
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -6,11 +6,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class UiSettingsImpl; class UiSettingsImpl;
@ -19,7 +15,7 @@ class UiSettings : public SettingsCategory
{ {
public: public:
explicit UiSettings(); explicit UiSettings();
~UiSettings(); ~UiSettings() override;
UiSettings(const UiSettings&) = delete; UiSettings(const UiSettings&) = delete;
UiSettings& operator=(const UiSettings&) = delete; UiSettings& operator=(const UiSettings&) = delete;
@ -27,13 +23,13 @@ public:
UiSettings(UiSettings&&) noexcept; UiSettings(UiSettings&&) noexcept;
UiSettings& operator=(UiSettings&&) noexcept; UiSettings& operator=(UiSettings&&) noexcept;
SettingsVariable<bool>& level2_products_expanded() const; [[nodiscard]] SettingsVariable<bool>& level2_products_expanded() const;
SettingsVariable<bool>& level2_settings_expanded() const; [[nodiscard]] SettingsVariable<bool>& level2_settings_expanded() const;
SettingsVariable<bool>& level3_products_expanded() const; [[nodiscard]] SettingsVariable<bool>& level3_products_expanded() const;
SettingsVariable<bool>& map_settings_expanded() const; [[nodiscard]] SettingsVariable<bool>& map_settings_expanded() const;
SettingsVariable<bool>& timeline_expanded() const; [[nodiscard]] SettingsVariable<bool>& timeline_expanded() const;
SettingsVariable<std::string>& main_ui_state() const; [[nodiscard]] SettingsVariable<std::string>& main_ui_state() const;
SettingsVariable<std::string>& main_ui_geometry() const; [[nodiscard]] SettingsVariable<std::string>& main_ui_geometry() const;
bool Shutdown(); bool Shutdown();
@ -45,6 +41,4 @@ private:
std::unique_ptr<UiSettingsImpl> p; std::unique_ptr<UiSettingsImpl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -4,11 +4,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
static const std::string logPrefix_ = "scwx::qt::settings::unit_settings"; static const std::string logPrefix_ = "scwx::qt::settings::unit_settings";
@ -35,11 +31,14 @@ public:
boost::to_lower(defaultSpeedUnitsValue); boost::to_lower(defaultSpeedUnitsValue);
boost::to_lower(defaultDistanceUnitsValue); boost::to_lower(defaultDistanceUnitsValue);
// SetDefault, SetMinimum and SetMaximum are descriptive
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
accumulationUnits_.SetDefault(defaultAccumulationUnitsValue); accumulationUnits_.SetDefault(defaultAccumulationUnitsValue);
echoTopsUnits_.SetDefault(defaultEchoTopsUnitsValue); echoTopsUnits_.SetDefault(defaultEchoTopsUnitsValue);
otherUnits_.SetDefault(defaultOtherUnitsValue); otherUnits_.SetDefault(defaultOtherUnitsValue);
speedUnits_.SetDefault(defaultSpeedUnitsValue); speedUnits_.SetDefault(defaultSpeedUnitsValue);
distanceUnits_.SetDefault(defaultDistanceUnitsValue); distanceUnits_.SetDefault(defaultDistanceUnitsValue);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
accumulationUnits_.SetValidator( accumulationUnits_.SetValidator(
SCWX_SETTINGS_ENUM_VALIDATOR(types::AccumulationUnits, SCWX_SETTINGS_ENUM_VALIDATOR(types::AccumulationUnits,
@ -63,7 +62,11 @@ public:
types::GetDistanceUnitsName)); types::GetDistanceUnitsName));
} }
~Impl() {} ~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
Impl(const Impl&&) = delete;
Impl& operator=(const Impl&&) = delete;
SettingsVariable<std::string> accumulationUnits_ {"accumulation_units"}; SettingsVariable<std::string> accumulationUnits_ {"accumulation_units"};
SettingsVariable<std::string> echoTopsUnits_ {"echo_tops_units"}; SettingsVariable<std::string> echoTopsUnits_ {"echo_tops_units"};
@ -127,6 +130,4 @@ bool operator==(const UnitSettings& lhs, const UnitSettings& rhs)
lhs.p->distanceUnits_ == rhs.p->distanceUnits_); lhs.p->distanceUnits_ == rhs.p->distanceUnits_);
} }
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx

View file

@ -6,18 +6,14 @@
#include <memory> #include <memory>
#include <string> #include <string>
namespace scwx namespace scwx::qt::settings
{
namespace qt
{
namespace settings
{ {
class UnitSettings : public SettingsCategory class UnitSettings : public SettingsCategory
{ {
public: public:
explicit UnitSettings(); explicit UnitSettings();
~UnitSettings(); ~UnitSettings() override;
UnitSettings(const UnitSettings&) = delete; UnitSettings(const UnitSettings&) = delete;
UnitSettings& operator=(const UnitSettings&) = delete; UnitSettings& operator=(const UnitSettings&) = delete;
@ -25,11 +21,11 @@ public:
UnitSettings(UnitSettings&&) noexcept; UnitSettings(UnitSettings&&) noexcept;
UnitSettings& operator=(UnitSettings&&) noexcept; UnitSettings& operator=(UnitSettings&&) noexcept;
SettingsVariable<std::string>& accumulation_units() const; [[nodiscard]] SettingsVariable<std::string>& accumulation_units() const;
SettingsVariable<std::string>& echo_tops_units() const; [[nodiscard]] SettingsVariable<std::string>& echo_tops_units() const;
SettingsVariable<std::string>& other_units() const; [[nodiscard]] SettingsVariable<std::string>& other_units() const;
SettingsVariable<std::string>& speed_units() const; [[nodiscard]] SettingsVariable<std::string>& speed_units() const;
SettingsVariable<std::string>& distance_units() const; [[nodiscard]] SettingsVariable<std::string>& distance_units() const;
static UnitSettings& Instance(); static UnitSettings& Instance();
@ -40,6 +36,4 @@ private:
std::unique_ptr<Impl> p; std::unique_ptr<Impl> p;
}; };
} // namespace settings } // namespace scwx::qt::settings
} // namespace qt
} // namespace scwx