From b0b52d51bdb093b7c2200d40ec41e2c3b0f2c830 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 1 Jan 2021 01:32:03 +0100 Subject: core: add "transparent" parameter to renderSVGIcon The start-selection widget will need icons with a transparent background so that the icons don't stick out like a sore thumb. So far the icons rendered by this function were only used by the images on the profile and were perfectly rectangular. Therefore there was no need for this. Signed-off-by: Berthold Stoeger --- core/imagedownloader.cpp | 8 ++++---- core/qthelper.cpp | 6 +++--- core/qthelper.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/imagedownloader.cpp b/core/imagedownloader.cpp index 7ce7bde5f..59f1da8b7 100644 --- a/core/imagedownloader.cpp +++ b/core/imagedownloader.cpp @@ -153,11 +153,11 @@ Thumbnailer::Thumbnail Thumbnailer::getHashedImage(const QString &filename, bool return thumbnail; } -Thumbnailer::Thumbnailer() : failImage(renderSVGIcon(":filter-close", maxThumbnailSize())), // TODO: Don't misuse filter close icon - dummyImage(renderSVGIcon(":camera-icon", maxThumbnailSize())), - videoImage(renderSVGIcon(":video-icon", maxThumbnailSize())), +Thumbnailer::Thumbnailer() : failImage(renderSVGIcon(":filter-close", maxThumbnailSize(), false)), // TODO: Don't misuse filter close icon + dummyImage(renderSVGIcon(":camera-icon", maxThumbnailSize(), false)), + videoImage(renderSVGIcon(":video-icon", maxThumbnailSize(), false)), videoOverlayImage(renderSVGIconWidth(":video-overlay", maxThumbnailSize())), - unknownImage(renderSVGIcon(":unknown-icon", maxThumbnailSize())) + unknownImage(renderSVGIcon(":unknown-icon", maxThumbnailSize(), false)) { // Currently, we only process one image at a time. Stefan Fuchs reported problems when // calculating multiple thumbnails at once and this hopefully helps. diff --git a/core/qthelper.cpp b/core/qthelper.cpp index bebed3cf6..4f21f59c8 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -1704,10 +1704,10 @@ extern "C" void emit_reset_signal() emit diveListNotifier.dataReset(); } -QImage renderSVGIcon(const char *id, int size) +QImage renderSVGIcon(const char *id, int size, bool transparent) { - QImage res(size, size, QImage::Format_RGB32); - res.fill(Qt::white); + QImage res(size, size, transparent ? QImage::Format_ARGB32 : QImage::Format_RGB32); + res.fill(transparent ? Qt::transparent : Qt::white); QSvgRenderer svg{QString(id)}; QPainter painter(&res); svg.render(&painter); diff --git a/core/qthelper.h b/core/qthelper.h index 152da7f89..ef7f4c8ff 100644 --- a/core/qthelper.h +++ b/core/qthelper.h @@ -87,7 +87,7 @@ QString getUserAgent(); QString printGPSCoords(const location_t *loc); std::vector get_cylinder_map_for_remove(int count, int n); std::vector get_cylinder_map_for_add(int count, int n); -QImage renderSVGIcon(const char *id, int size); +QImage renderSVGIcon(const char *id, int size, bool transparent); QImage renderSVGIconWidth(const char *id, int size); extern QString (*changesCallback)(); -- cgit v1.2.3-70-g09d2