mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 23:10:05 +00:00
Add LineSettings class to use as subcategory
This commit is contained in:
parent
c8dc8ed630
commit
cea2993665
3 changed files with 168 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
121
scwx-qt/source/scwx/qt/settings/line_settings.cpp
Normal file
121
scwx-qt/source/scwx/qt/settings/line_settings.cpp
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
#include <scwx/qt/settings/line_settings.hpp>
|
||||
#include <scwx/qt/util/color.hpp>
|
||||
|
||||
#include <boost/gil.hpp>
|
||||
|
||||
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<std::string> lineColor_ {"line_color"};
|
||||
SettingsVariable<std::string> highlightColor_ {"highlight_color"};
|
||||
SettingsVariable<std::string> borderColor_ {"border_color"};
|
||||
|
||||
SettingsVariable<std::int64_t> lineWidth_ {"line_width"};
|
||||
SettingsVariable<std::int64_t> highlightWidth_ {"highlight_width"};
|
||||
SettingsVariable<std::int64_t> borderWidth_ {"border_width"};
|
||||
};
|
||||
|
||||
LineSettings::LineSettings(const std::string& name) :
|
||||
SettingsCategory(name), p(std::make_unique<Impl>())
|
||||
{
|
||||
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<std::string>& LineSettings::border_color() const
|
||||
{
|
||||
return p->borderColor_;
|
||||
}
|
||||
|
||||
SettingsVariable<std::string>& LineSettings::highlight_color() const
|
||||
{
|
||||
return p->highlightColor_;
|
||||
}
|
||||
|
||||
SettingsVariable<std::string>& LineSettings::line_color() const
|
||||
{
|
||||
return p->lineColor_;
|
||||
}
|
||||
|
||||
SettingsVariable<std::int64_t>& LineSettings::border_width() const
|
||||
{
|
||||
return p->borderWidth_;
|
||||
}
|
||||
|
||||
SettingsVariable<std::int64_t>& LineSettings::highlight_width() const
|
||||
{
|
||||
return p->highlightWidth_;
|
||||
}
|
||||
|
||||
SettingsVariable<std::int64_t>& 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
|
||||
45
scwx-qt/source/scwx/qt/settings/line_settings.hpp
Normal file
45
scwx-qt/source/scwx/qt/settings/line_settings.hpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/settings/settings_category.hpp>
|
||||
#include <scwx/qt/settings/settings_variable.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
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<std::string>& border_color() const;
|
||||
SettingsVariable<std::string>& highlight_color() const;
|
||||
SettingsVariable<std::string>& line_color() const;
|
||||
|
||||
SettingsVariable<std::int64_t>& border_width() const;
|
||||
SettingsVariable<std::int64_t>& highlight_width() const;
|
||||
SettingsVariable<std::int64_t>& line_width() const;
|
||||
|
||||
friend bool operator==(const LineSettings& lhs, const LineSettings& rhs);
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> p;
|
||||
};
|
||||
|
||||
} // namespace settings
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
Loading…
Add table
Add a link
Reference in a new issue