From: Kevin Ottens Date: Wed, 20 Jan 2021 14:11:57 +0000 (+0100) Subject: Use APPLICATION_ICON_SET for themed icons X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~414^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=471bb25e62c6748d656b6cdc627ec1beadd070e9;p=nextcloud-desktop.git Use APPLICATION_ICON_SET for themed icons We now favor APPLICATION_ICON_SET to isBranded() regarding the decision to use PNG or SVG for icons. Signed-off-by: Kevin Ottens --- diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index 93487134f..be3bde5e6 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -192,10 +192,11 @@ QIcon Theme::themeIcon(const QString &name, bool sysTray) const return QPixmap(pixmapName); }; - const auto sizes = isBranded() ? QVector{ 16, 22, 32, 48, 64, 128, 256, 512, 1024 } - : QVector{ 16, 32, 64, 128, 256 }; + const auto useSvg = shouldPreferSvg(); + const auto sizes = useSvg ? QVector{ 16, 32, 64, 128, 256 } + : QVector{ 16, 22, 32, 48, 64, 128, 256, 512, 1024 }; for (int size : sizes) { - auto px = isBranded() ? loadPixmap(size) : createPixmapFromSvg(size); + auto px = useSvg ? createPixmapFromSvg(size) : loadPixmap(size); if (px.isNull()) { continue; } @@ -224,20 +225,25 @@ QIcon Theme::themeIcon(const QString &name, bool sysTray) const QString Theme::themeImagePath(const QString &name, int size, bool sysTray) const { const auto flavor = (!isBranded() && sysTray) ? systrayIconFlavor(_mono) : QLatin1String("colored"); + const auto useSvg = shouldPreferSvg(); // branded client may have several sizes of the same icon - const QString filePath = (isBranded() && size > 0) - ? QString::fromLatin1(":/client/theme/%1/%2-%3").arg(flavor).arg(name).arg(size) - : QString::fromLatin1(":/client/theme/%1/%2").arg(flavor).arg(name); - - const QString brandedImagePath = filePath + ".png"; + const QString filePath = (useSvg || size <= 0) + ? QString::fromLatin1(":/client/theme/%1/%2").arg(flavor).arg(name) + : QString::fromLatin1(":/client/theme/%1/%2-%3").arg(flavor).arg(name).arg(size); - // only return branded .png image path if it exists, or fall-back to non-branded .svg otherwise - if (isBranded() && QFile::exists(brandedImagePath)) { - return brandedImagePath; + const QString svgPath = filePath + ".svg"; + if (useSvg) { + return svgPath; } - return filePath + ".svg"; + const QString pngPath = filePath + ".png"; + // Use the SVG as fallback if a PNG is missing so that we get a chance to display something + if (QFile::exists(pngPath)) { + return pngPath; + } else { + return svgPath; + } } QIcon Theme::uiThemeIcon(const QString &iconName, bool uiHasDarkBg) const