diff --git a/scwx-qt/source/scwx/qt/settings/palette_settings.cpp b/scwx-qt/source/scwx/qt/settings/palette_settings.cpp index 4c61a916..12e3fe99 100644 --- a/scwx-qt/source/scwx/qt/settings/palette_settings.cpp +++ b/scwx-qt/source/scwx/qt/settings/palette_settings.cpp @@ -5,7 +5,6 @@ #include #include #include -#include namespace scwx { @@ -116,8 +115,6 @@ public: void InitializeLegacyAlerts(); void InitializeAlerts(); - static bool ValidateColor(const std::string& value); - PaletteSettings* self_; std::unordered_map> palette_ {}; @@ -132,12 +129,6 @@ public: std::vector alertSettings_ {}; }; -bool PaletteSettings::Impl::ValidateColor(const std::string& value) -{ - static constexpr LazyRE2 re = {"#[0-9A-Fa-f]{8}"}; - return RE2::FullMatch(value, *re); -} - PaletteSettings::PaletteSettings() : SettingsCategory("palette"), p(std::make_unique(this)) { @@ -196,8 +187,8 @@ void PaletteSettings::Impl::InitializeLegacyAlerts() inactiveVariable.SetDefault( util::color::ToArgbString(alert.second.second)); - activeVariable.SetValidator(&ValidateColor); - inactiveVariable.SetValidator(&ValidateColor); + activeVariable.SetValidator(&util::color::ValidateArgbString); + inactiveVariable.SetValidator(&util::color::ValidateArgbString); variables_.push_back(&activeVariable); variables_.push_back(&inactiveVariable); diff --git a/scwx-qt/source/scwx/qt/util/color.cpp b/scwx-qt/source/scwx/qt/util/color.cpp index 6e193dc9..16060bb9 100644 --- a/scwx-qt/source/scwx/qt/util/color.cpp +++ b/scwx-qt/source/scwx/qt/util/color.cpp @@ -1,6 +1,7 @@ #include #include +#include #include namespace scwx @@ -38,6 +39,12 @@ boost::gil::rgba32f_pixel_t ToRgba32fPixelT(const std::string& argbString) rgba8Pixel[3] / 255.0f}; } +bool ValidateArgbString(const std::string& argbString) +{ + static constexpr LazyRE2 re = {"#[0-9A-Fa-f]{8}"}; + return RE2::FullMatch(argbString, *re); +} + } // namespace color } // namespace util } // namespace qt diff --git a/scwx-qt/source/scwx/qt/util/color.hpp b/scwx-qt/source/scwx/qt/util/color.hpp index 73ca07f1..6d90fe56 100644 --- a/scwx-qt/source/scwx/qt/util/color.hpp +++ b/scwx-qt/source/scwx/qt/util/color.hpp @@ -39,6 +39,15 @@ boost::gil::rgba8_pixel_t ToRgba8PixelT(const std::string& argbString); */ boost::gil::rgba32f_pixel_t ToRgba32fPixelT(const std::string& argbString); +/** + * Validates an ARGB string used by Qt libraries. + * + * @param argbString + * + * @return Validity of ARGB string + */ +bool ValidateArgbString(const std::string& argbString); + } // namespace color } // namespace util } // namespace qt