diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 52d26ccc..530f93a1 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -172,6 +172,7 @@ set(SRC_REQUEST source/scwx/qt/request/download_request.cpp set(HDR_SETTINGS source/scwx/qt/settings/audio_settings.hpp source/scwx/qt/settings/general_settings.hpp source/scwx/qt/settings/hotkey_settings.hpp + source/scwx/qt/settings/line_settings.hpp source/scwx/qt/settings/map_settings.hpp source/scwx/qt/settings/palette_settings.hpp source/scwx/qt/settings/product_settings.hpp @@ -188,6 +189,7 @@ set(HDR_SETTINGS source/scwx/qt/settings/audio_settings.hpp set(SRC_SETTINGS source/scwx/qt/settings/audio_settings.cpp source/scwx/qt/settings/general_settings.cpp source/scwx/qt/settings/hotkey_settings.cpp + source/scwx/qt/settings/line_settings.cpp source/scwx/qt/settings/map_settings.cpp source/scwx/qt/settings/palette_settings.cpp source/scwx/qt/settings/product_settings.cpp diff --git a/scwx-qt/source/scwx/qt/settings/line_settings.cpp b/scwx-qt/source/scwx/qt/settings/line_settings.cpp new file mode 100644 index 00000000..bc467186 --- /dev/null +++ b/scwx-qt/source/scwx/qt/settings/line_settings.cpp @@ -0,0 +1,121 @@ +#include +#include + +#include + +namespace scwx +{ +namespace qt +{ +namespace settings +{ + +static const std::string logPrefix_ = "scwx::qt::settings::line_settings"; + +static const boost::gil::rgba8_pixel_t kTransparentColor_ {0, 0, 0, 0}; +static const std::string kTransparentColorString_ { + util::color::ToArgbString(kTransparentColor_)}; + +static const boost::gil::rgba8_pixel_t kBlackColor_ {0, 0, 0, 255}; +static const std::string kBlackColorString_ { + util::color::ToArgbString(kBlackColor_)}; + +static const boost::gil::rgba8_pixel_t kWhiteColor_ {255, 255, 255, 255}; +static const std::string kWhiteColorString_ { + util::color::ToArgbString(kWhiteColor_)}; + +class LineSettings::Impl +{ +public: + explicit Impl() + { + lineColor_.SetDefault(kWhiteColorString_); + highlightColor_.SetDefault(kTransparentColorString_); + borderColor_.SetDefault(kBlackColorString_); + + lineWidth_.SetDefault(3); + highlightWidth_.SetDefault(0); + borderWidth_.SetDefault(1); + + lineWidth_.SetMinimum(1); + highlightWidth_.SetMinimum(0); + borderWidth_.SetMinimum(0); + + lineWidth_.SetMaximum(9); + highlightWidth_.SetMaximum(9); + borderWidth_.SetMaximum(9); + + lineColor_.SetValidator(&util::color::ValidateArgbString); + highlightColor_.SetValidator(&util::color::ValidateArgbString); + borderColor_.SetValidator(&util::color::ValidateArgbString); + } + ~Impl() {} + + SettingsVariable lineColor_ {"line_color"}; + SettingsVariable highlightColor_ {"highlight_color"}; + SettingsVariable borderColor_ {"border_color"}; + + SettingsVariable lineWidth_ {"line_width"}; + SettingsVariable highlightWidth_ {"highlight_width"}; + SettingsVariable borderWidth_ {"border_width"}; +}; + +LineSettings::LineSettings(const std::string& name) : + SettingsCategory(name), p(std::make_unique()) +{ + RegisterVariables({&p->lineColor_, + &p->highlightColor_, + &p->borderColor_, + &p->lineWidth_, + &p->highlightWidth_, + &p->borderWidth_}); + SetDefaults(); +} +LineSettings::~LineSettings() = default; + +LineSettings::LineSettings(LineSettings&&) noexcept = default; +LineSettings& LineSettings::operator=(LineSettings&&) noexcept = default; + +SettingsVariable& LineSettings::border_color() const +{ + return p->borderColor_; +} + +SettingsVariable& LineSettings::highlight_color() const +{ + return p->highlightColor_; +} + +SettingsVariable& LineSettings::line_color() const +{ + return p->lineColor_; +} + +SettingsVariable& LineSettings::border_width() const +{ + return p->borderWidth_; +} + +SettingsVariable& LineSettings::highlight_width() const +{ + return p->highlightWidth_; +} + +SettingsVariable& LineSettings::line_width() const +{ + return p->lineWidth_; +} + +bool operator==(const LineSettings& lhs, const LineSettings& rhs) +{ + return (lhs.p->borderColor_ == rhs.p->borderColor_ && + lhs.p->highlightColor_ == rhs.p->highlightColor_ && + lhs.p->lineColor_ == rhs.p->lineColor_ && + lhs.p->borderWidth_ == rhs.p->borderWidth_ && + lhs.p->highlightWidth_ == rhs.p->highlightWidth_ && + lhs.p->lineWidth_ == rhs.p->lineWidth_); +} + +} // namespace settings +} // namespace qt +} // namespace scwx diff --git a/scwx-qt/source/scwx/qt/settings/line_settings.hpp b/scwx-qt/source/scwx/qt/settings/line_settings.hpp new file mode 100644 index 00000000..e99d9b3e --- /dev/null +++ b/scwx-qt/source/scwx/qt/settings/line_settings.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include +#include + +#include +#include + +namespace scwx +{ +namespace qt +{ +namespace settings +{ + +class LineSettings : public SettingsCategory +{ +public: + explicit LineSettings(const std::string& name); + ~LineSettings(); + + LineSettings(const LineSettings&) = delete; + LineSettings& operator=(const LineSettings&) = delete; + + LineSettings(LineSettings&&) noexcept; + LineSettings& operator=(LineSettings&&) noexcept; + + SettingsVariable& border_color() const; + SettingsVariable& highlight_color() const; + SettingsVariable& line_color() const; + + SettingsVariable& border_width() const; + SettingsVariable& highlight_width() const; + SettingsVariable& line_width() const; + + friend bool operator==(const LineSettings& lhs, const LineSettings& rhs); + +private: + class Impl; + std::unique_ptr p; +}; + +} // namespace settings +} // namespace qt +} // namespace scwx