From cad9088937aa5fdba9f5ff3c551229bc7e07dd77 Mon Sep 17 00:00:00 2001 From: ZeldaZach Date: Thu, 6 Feb 2025 01:45:34 -0500 Subject: [PATCH] Fixup custom theme image loading --- cockatrice/src/client/ui/pixel_map_generator.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cockatrice/src/client/ui/pixel_map_generator.cpp b/cockatrice/src/client/ui/pixel_map_generator.cpp index a1c8aa152..c7303cd37 100644 --- a/cockatrice/src/client/ui/pixel_map_generator.cpp +++ b/cockatrice/src/client/ui/pixel_map_generator.cpp @@ -18,18 +18,18 @@ /** * Loads in an svg from file and scales it without affecting image quality. * - * @param path The path to the svg file. Automatically appends ".svg" to the end if not present + * @param svgPath The path to the svg file, with file extension. * @param size The desired size of the pixmap. * @param expandOnly If true, then keep the size of the initial pixmap to at least the svg size. * * @return The svg loaded into a Pixmap with the given size, or an empty Pixmap if the loading failed. */ -static QPixmap loadSvg(const QString &path, const QSize &size, bool expandOnly = false) +static QPixmap loadSvg(const QString &svgPath, const QSize &size, bool expandOnly = false) { - QSvgRenderer svgRenderer(path + ".svg"); + QSvgRenderer svgRenderer(svgPath); if (!svgRenderer.isValid()) { - qCWarning(PixelMapGeneratorLog) << "Failed to load" << path; + qCWarning(PixelMapGeneratorLog) << "Failed to load" << svgPath; return {}; } @@ -53,7 +53,7 @@ static QPixmap loadSvg(const QString &path, const QSize &size, bool expandOnly = /** * Try to load path image from non-SVG formats, otherwise fall back to SVG. * This is to allow custom themes to support non-SVG format type overrides, since SVG requires custom loading. - * @param path The path to the file. File formats will be automatically detected. + * @param path The path to the file, with no file extension. File formats will be automatically detected. * @param size The desired size of the pixmap. * @param expandOnly If true, then keep the size of the initial pixmap to at least the size (Only relevant if SVG). * @@ -70,7 +70,7 @@ static QPixmap tryLoadImage(const QString &path, const QSize &size, bool expandO } } - return loadSvg(path, size, expandOnly); + return loadSvg(path + ".svg", size, expandOnly); } QMap PhasePixmapGenerator::pmCache;