diff options
| author | Doris Verria <doris.verria@qt.io> | 2024-06-12 18:42:01 +0200 |
|---|---|---|
| committer | Doris Verria <doris.verria@qt.io> | 2024-10-04 09:15:13 +0200 |
| commit | 160bcd5f11ed9f21d01798c48398919ab9464750 (patch) | |
| tree | d383ffe97667e9bce73f1ce780f2e2ede6dfd19e | |
| parent | a48aae33a1887f729fb299526ca02a8d990086b0 (diff) | |
StyleGenerator: Make sure there is a stroke when getting strokeWeight
Sometimes in Figma the atom will report having a strokeWeight > 0 but
won't have any stroke.
Before taking the strokeWeight into account in our geometry
calculations, we should make sure the strokes array of the atom is not
empty.
Change-Id: Ib04438eebe3eaba74ea00637619a11cd1839cadc
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
| -rw-r--r-- | tools/qqcstylegenerator/src/stylegenerator.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/qqcstylegenerator/src/stylegenerator.h b/tools/qqcstylegenerator/src/stylegenerator.h index 3931031d6c..816a59f6a1 100644 --- a/tools/qqcstylegenerator/src/stylegenerator.h +++ b/tools/qqcstylegenerator/src/stylegenerator.h @@ -959,14 +959,14 @@ private: { // Use radii and border width of the obj to determine the offsets. // The biggest of them wins. - const qreal strokeWeight = obj["strokeWeight"].toDouble(0); + const qreal strokeWeight = !obj["strokes"].toArray().isEmpty() ? obj["strokeWeight"].toDouble(0) : .0; const QString strokeAlign = obj["strokeAlign"].toString(); BorderImageOffset offset; Radii radii = getRadii(obj); // if the stroke is not inside of the control, we need to include it in the offsets - if (strokeAlign == "OUTSIDE" || strokeAlign == "CENTERED") { + if (strokeWeight && (strokeAlign == "OUTSIDE" || strokeAlign == "CENTERED")) { const auto borderWidth = strokeAlign == "CENTERED" ? strokeWeight/2 : strokeWeight; radii.topLeft += borderWidth; radii.topRight += borderWidth; |
