From ec0b92ec1d9d93bc1986f2c48f11eb7f1a2ffffe Mon Sep 17 00:00:00 2001 From: Claveau Joshua Date: Sun, 18 Oct 2020 10:45:05 +0200 Subject: [PATCH] Fix : Filling color is not apply to polyline. --- .../graphicspart/customelementgraphicpart.cpp | 13 +++++++++---- sources/editor/graphicspart/partpolygon.cpp | 2 +- sources/editor/styleeditor.cpp | 16 ++++++++++------ sources/editor/ui/polygoneditor.cpp | 12 +++++++----- sources/factory/elementpicturefactory.cpp | 14 +++++++------- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/sources/editor/graphicspart/customelementgraphicpart.cpp b/sources/editor/graphicspart/customelementgraphicpart.cpp index ecfa68961..b804fdee6 100644 --- a/sources/editor/graphicspart/customelementgraphicpart.cpp +++ b/sources/editor/graphicspart/customelementgraphicpart.cpp @@ -523,11 +523,16 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde) //Check each pair of style QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$"); - foreach (QString style, styles) + for (auto style : styles) { - if (rx!=QRegularExpression(style)) continue; - QString style_name = rx.namedCaptureGroups().at(1); - QString style_value = rx.namedCaptureGroups().at(2); + auto rx_match = rx.match(style); + if (!rx_match.hasMatch()) { + continue; + } + + auto style_name = rx_match.captured(1); + auto style_value = rx_match.captured(2); + if (style_name == "line-style") { if (style_value == "dashed") _linestyle = DashedStyle; diff --git a/sources/editor/graphicspart/partpolygon.cpp b/sources/editor/graphicspart/partpolygon.cpp index 0875781de..89e21beb9 100644 --- a/sources/editor/graphicspart/partpolygon.cpp +++ b/sources/editor/graphicspart/partpolygon.cpp @@ -61,7 +61,7 @@ PartPolygon::~PartPolygon() */ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget) { - Q_UNUSED(widget); + Q_UNUSED(widget) applyStylesToQPainter(*painter); diff --git a/sources/editor/styleeditor.cpp b/sources/editor/styleeditor.cpp index 121cbfba1..0ffb48ca5 100644 --- a/sources/editor/styleeditor.cpp +++ b/sources/editor/styleeditor.cpp @@ -448,11 +448,15 @@ void StyleEditor::updateForm() if (part) { - antialiasing -> setChecked(part -> antialiased()); - outline_color -> setCurrentIndex(part -> color()); - line_style -> setCurrentIndex(part -> lineStyle()); - size_weight -> setCurrentIndex(part -> lineWeight()); - filling_color -> setCurrentIndex(part -> filling()); + antialiasing ->setChecked(part -> antialiased()); + outline_color ->removeItem(13); //Remove the separator for set the good index at the line below + outline_color ->setCurrentIndex(part->color()); + outline_color ->insertSeparator(13); + line_style ->setCurrentIndex(part -> lineStyle()); + size_weight ->setCurrentIndex(part -> lineWeight()); + filling_color ->removeItem(13); //Remove the separator for set the good index at the line below + filling_color ->setCurrentIndex(part -> filling()); + filling_color ->insertSeparator(13); } else if (m_part_list.size()) { @@ -463,7 +467,7 @@ void StyleEditor::updateForm() size_weight -> setCurrentIndex(first_part -> lineWeight()); filling_color -> setCurrentIndex(first_part -> filling()); - foreach (CustomElementGraphicPart *cegp, m_part_list) + for (auto cegp : m_part_list) { if (first_part -> antialiased() != cegp -> antialiased()) antialiasing -> setChecked(false); if (first_part -> color() != cegp -> color()) outline_color -> setCurrentIndex(-1); diff --git a/sources/editor/ui/polygoneditor.cpp b/sources/editor/ui/polygoneditor.cpp index ed008fb04..ab1d6c07f 100644 --- a/sources/editor/ui/polygoneditor.cpp +++ b/sources/editor/ui/polygoneditor.cpp @@ -90,23 +90,25 @@ bool PolygonEditor::setPart(CustomElementPart *new_part) { if (!new_part) { - if (m_part) - { + if (m_part) { disconnectChangeConnections(); + m_style->setPart(nullptr); } m_part = nullptr; return(true); } if (PartPolygon *part_polygon = dynamic_cast(new_part)) { - if (m_part == part_polygon) return true; - if (m_part) - { + if (m_part == part_polygon) { + return true; + } + if (m_part) { disconnectChangeConnections(); } m_part = part_polygon; updateForm(); setUpChangeConnections(); + m_style->setPart(m_part); return(true); } return(false); diff --git a/sources/factory/elementpicturefactory.cpp b/sources/factory/elementpicturefactory.cpp index 30cebc61c..f0bd3a795 100644 --- a/sources/factory/elementpicturefactory.cpp +++ b/sources/factory/elementpicturefactory.cpp @@ -488,7 +488,7 @@ void ElementPictureFactory::parsePolygon(const QDomElement &dom, QPainter &paint void ElementPictureFactory::parseText(const QDomElement &dom, QPainter &painter, ElementPictureFactory::primitives &prim) const { - Q_UNUSED(prim); + Q_UNUSED(prim) if (dom.tagName() != "text") { return; @@ -571,7 +571,8 @@ void ElementPictureFactory::setPainterStyle(const QDomElement &dom, QPainter &pa #endif const QStringList styles = dom.attribute("style").split(";", Qt::SkipEmptyParts); #endif - QRegularExpression rx("^(?[a-z-]+):(?[a-z-]+)$"); + + QRegularExpression rx("^(?[a-z-]+):(?[a-zA-Z-]+)$"); if (!rx.isValid()) { qWarning() <