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