Improved some theme warning messages in BadgeComponent.

This commit is contained in:
Leon Styhre 2022-10-29 12:54:52 +02:00
parent 064909bf96
commit 03a9dc8e05

View file

@ -212,9 +212,10 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
if (elem->has("horizontalAlignment")) {
const std::string horizontalAlignment {elem->get<std::string>("horizontalAlignment")};
if (horizontalAlignment != "left" && horizontalAlignment != "right") {
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <horizontalAlignment> "
"property defined as \""
<< horizontalAlignment << "\"";
LOG(LogWarning)
<< "BadgeComponent: Invalid theme configuration, property \"horizontalAlignment\" "
"for element \""
<< element.substr(7) << "\" defined as \"" << horizontalAlignment << "\"";
}
else {
mFlexboxComponent.setAlignment(horizontalAlignment);
@ -224,9 +225,9 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
else if (elem->has("alignment")) {
const std::string alignment {elem->get<std::string>("alignment")};
if (alignment != "left" && alignment != "right") {
LOG(LogWarning)
<< "BadgeComponent: Invalid theme configuration, <alignment> property defined as \""
<< alignment << "\"";
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, property \"alignment\""
" for element \""
<< element.substr(7) << "\" defined as \"" << alignment << "\"";
}
else {
mFlexboxComponent.setAlignment(alignment);
@ -236,9 +237,9 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
if (elem->has("direction")) {
const std::string direction {elem->get<std::string>("direction")};
if (direction != "row" && direction != "column") {
LOG(LogWarning)
<< "BadgeComponent: Invalid theme configuration, <direction> property defined as \""
<< direction << "\"";
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, property \"direction\""
" for element \""
<< element.substr(7) << "\" defined as \"" << direction << "\"";
}
else {
mFlexboxComponent.setDirection(direction);
@ -249,9 +250,9 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
if (elem->has("lines")) {
const unsigned int lines {elem->get<unsigned int>("lines")};
if (lines < 1 || lines > 10) {
LOG(LogWarning)
<< "BadgeComponent: Invalid theme configuration, <lines> property defined as \""
<< lines << "\"";
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, property \"lines\""
" for element \""
<< element.substr(7) << "\" defined as \"" << lines << "\"";
}
else {
mFlexboxComponent.setLines(lines);
@ -262,9 +263,10 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
if (elem->has("itemsPerLine")) {
const unsigned int itemsPerLine {elem->get<unsigned int>("itemsPerLine")};
if (itemsPerLine < 1 || itemsPerLine > 10) {
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <itemsPerLine> "
"property defined as \""
<< itemsPerLine << "\"";
LOG(LogWarning)
<< "BadgeComponent: Invalid theme configuration, property \"itemsPerLine\""
" for element \""
<< element.substr(7) << "\" defined as \"" << itemsPerLine << "\"";
}
else {
mFlexboxComponent.setItemsPerLine(itemsPerLine);
@ -276,9 +278,11 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
if ((itemMargin.x != -1.0 && itemMargin.y != -1.0) &&
(itemMargin.x < 0.0f || itemMargin.x > 0.2f || itemMargin.y < 0.0f ||
itemMargin.y > 0.2f)) {
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <itemMargin> property "
"defined as \""
<< itemMargin.x << " " << itemMargin.y << "\"";
LOG(LogWarning)
<< "BadgeComponent: Invalid theme configuration, property \"itemMargin\""
" for element \""
<< element.substr(7) << "\" defined as \"" << itemMargin.x << " " << itemMargin.y
<< "\"";
}
else {
mFlexboxComponent.setItemMargin(itemMargin);