Add support for configurable transparent background to SVGs

Authored by huoni on Mar 27 2018, 5:37 AM.


Add support for configurable transparent background to SVGs

SVGs do not honor the "Transparent background" config option, and simply have no
background at all. This patch ensures this option is applied to SVGs as well as
raster images.

Unlike RasterImageView that uses a QPixmap buffer (mCurrentBuffer) for drawing
the background and the image, SVGs are rendered directly on top of SvgImageView
(QGraphicsWidget). Therefore we just paint the background in SvgImageView::paint
which happens before the SVG is rendered.

We move the checkboard texture code to AbstractImageView now that it's used by
both subclasses RasterImageView and SvgImageView.

This patch also configures kconf_update due to the moving of the above enum.
Since I didn't want to litter /app with files, I've moved the update files to

Fixes T8125



Test Plan:

  • Open an SVG with solid color config option
  • Open and SVG with checkboard background config. At a high enough zoom (where the birdseye view shows up), panning/scrolling should have the checkboard pattern fixed to the image, like raster images
  • Ensure raster images with transparent backgrounds are unaffected


The script must be in
/usr/share/kconf_update in order for /usr/lib/kf5/kconf_update to find it.
If successfull, instances of RasterImageView::AlphaBackground* should change to

Reviewers: Gwenview, rkflx, ngraham

Reviewed By: Gwenview, rkflx, ngraham

Tags: Gwenview

Maniphest Tasks: T8125

Differential Revision: