From 48be27bce5f23811ee1b756d9507b98e29b05aca Mon Sep 17 00:00:00 2001 From: mistic100 Date: Fri, 4 Dec 2020 17:57:58 +0100 Subject: [PATCH] Fix parsing of XML --- src/customlayout.h | 77 +++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/src/customlayout.h b/src/customlayout.h index 833b715..4c6392d 100644 --- a/src/customlayout.h +++ b/src/customlayout.h @@ -59,53 +59,52 @@ struct CustomLayout { borderWidth = _dom->attribute("borderWidth").toShort(); borderColor = _dom->attribute("borderColor").toUInt(); } - - // inner nodes (since 2.2.1) - QDomNode node = _dom->firstChild(); - - if (!node.isNull()) + else { + // inner nodes (since 2.2.1) + QDomNode node = _dom->firstChild(); + borderEnabled = false; mainEnabled = false; shadowEnabled = false; variationEnabled = false; - } - while (!node.isNull()) - { - if (node.isElement()) + while (!node.isNull()) { - QDomElement element = node.toElement(); - - if (element.tagName() == "main") - { - mainEnabled = true; - mainRows = element.attribute("rows").toShort(); - mainCols = element.attribute("cols").toShort(); - mainPos = static_cast(element.attribute("pos").toInt()); - } - else if (element.tagName() == "border") - { - borderEnabled = true; - borderWidth = element.attribute("width").toShort(); - borderColor = QColor(element.attribute("color")).rgb(); - } - else if (element.tagName() == "shadow") - { - shadowEnabled = true; - shadowWidth = element.attribute("width").toShort(); - shadowColor = QColor(element.attribute("color")).rgb(); - } - else if (element.tagName() == "variation") - { - variationEnabled = true; - angleVariation = element.attribute("angle").toDouble(); - sizeVariation = element.attribute("size").toDouble(); - posVariation = element.attribute("pos").toDouble(); - } + if (node.isElement()) + { + QDomElement element = node.toElement(); + + if (element.tagName() == "main") + { + mainEnabled = true; + mainRows = element.attribute("rows").toShort(); + mainCols = element.attribute("cols").toShort(); + mainPos = static_cast(element.attribute("pos").toInt()); + } + else if (element.tagName() == "border") + { + borderEnabled = true; + borderWidth = element.attribute("width").toShort(); + borderColor = QColor(element.attribute("color")).rgb(); + } + else if (element.tagName() == "shadow") + { + shadowEnabled = true; + shadowWidth = element.attribute("width").toShort(); + shadowColor = QColor(element.attribute("color")).rgb(); + } + else if (element.tagName() == "variation") + { + variationEnabled = true; + angleVariation = element.attribute("angle").toDouble(); + sizeVariation = element.attribute("size").toDouble(); + posVariation = element.attribute("pos").toDouble(); + } + } + + node = node.nextSibling(); } - - node = node.nextSibling(); } }