From 358e90524ab242dacd8c6bf72996bb602d3091ea Mon Sep 17 00:00:00 2001 From: magnetProgramming Date: Wed, 10 Sep 2025 03:23:58 -0500 Subject: [PATCH] Icon-O-Matic: Warn when exporting unsupported gradients to SVG SVG does not support conic, diamond, xy, or sqrt_xy gradients. Show a one time warning and export them as linear approximations. Fixes #19533. Change-Id: Id49d9ea098a47088c0865d5a8609b657b0bcc45b Reviewed-on: https://review.haiku-os.org/c/haiku/+/9636 Reviewed-by: Zardshard Zardshard <0azrune6@zard.anonaddy.com> Tested-by: Commit checker robot --- .../import_export/svg/SVGExporter.cpp | 29 +++++++++++++++++++ .../import_export/svg/SVGExporter.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/src/apps/icon-o-matic/import_export/svg/SVGExporter.cpp b/src/apps/icon-o-matic/import_export/svg/SVGExporter.cpp index e055a01d58..31ae15ac07 100644 --- a/src/apps/icon-o-matic/import_export/svg/SVGExporter.cpp +++ b/src/apps/icon-o-matic/import_export/svg/SVGExporter.cpp @@ -49,6 +49,7 @@ write_line(BPositionIO* stream, BString& string) // constructor SVGExporter::SVGExporter() : Exporter(), + fShownUnsupportedGradientWarning(false), fGradientCount(0), fOriginalEntry(NULL) { @@ -156,6 +157,27 @@ SVGExporter::_DisplayWarning() const return alert->Go() == 1; } +// _DisplayUnsupportedGradientWarning +void +SVGExporter::_DisplayUnsupportedGradientWarning() const +{ + if (fShownUnsupportedGradientWarning) + return; + + BAlert* alert = new BAlert( + B_TRANSLATE("SVG export"), + B_TRANSLATE("SVG does not support some gradient types " + "(conic, diamond, xy, sqrt_xy).\n\n" + "They will be exported as linear approximations and " + "may look different in other viewers."), + B_TRANSLATE("OK") + ); + + alert->Go(); + fShownUnsupportedGradientWarning = true; +} + + // #pragma mark - // convert_join_mode_svg @@ -368,6 +390,13 @@ SVGExporter::_ExportGradient(const Gradient* gradient, BPositionIO* stream) { BString helper; + // display a warning if the gradient is unsupported + if (gradient->Type() == GRADIENT_CONIC + || gradient->Type() == GRADIENT_DIAMOND + || gradient->Type() == GRADIENT_XY + || gradient->Type() == GRADIENT_SQRT_XY) + _DisplayUnsupportedGradientWarning(); + // start new gradient tag if (gradient->Type() == GRADIENT_CIRCULAR) { helper << "