return QPixmap(pixmapName);
};
- const auto sizes = isBranded() ? QVector<int>{ 16, 22, 32, 48, 64, 128, 256, 512, 1024 }
- : QVector<int>{ 16, 32, 64, 128, 256 };
+ const auto useSvg = shouldPreferSvg();
+ const auto sizes = useSvg ? QVector<int>{ 16, 32, 64, 128, 256 }
+ : QVector<int>{ 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;
}
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