Use the SVG wizard logo when APPLICATION_ICON_SET says so
authorKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 20 Jan 2021 09:44:29 +0000 (10:44 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Wed, 20 Jan 2021 14:09:58 +0000 (15:09 +0100)
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/libsync/theme.cpp

index 97f0b3697a0c59d35832649f3201737c0dd51734..93487134f3acd1713aae9491e4cc9a6badc9f010 100644 (file)
@@ -52,6 +52,11 @@ QUrl imagePathToUrl(const QString &imagePath)
     }
 }
 
+bool shouldPreferSvg()
+{
+    return QByteArray(APPLICATION_ICON_SET).toUpper() == QByteArrayLiteral("SVG");
+}
+
 }
 
 namespace OCC {
@@ -533,7 +538,17 @@ QColor Theme::wizardHeaderBackgroundColor() const
 QPixmap Theme::wizardHeaderLogo() const
 {
 #ifdef APPLICATION_WIZARD_USE_CUSTOM_LOGO
-   return QPixmap(hidpiFileName(":/client/theme/colored/wizard_logo.png"));
+    const auto useSvg = shouldPreferSvg();
+    const auto logoBasePath = QStringLiteral(":/client/theme/colored/wizard_logo");
+    if (useSvg) {
+        const auto maxHeight = 64;
+        const auto maxWidth = 2 * maxHeight;
+        const auto icon = QIcon(logoBasePath + ".svg");
+        const auto size = icon.actualSize(QSize(maxWidth, maxHeight));
+        return icon.pixmap(size);
+    } else {
+        return QPixmap(hidpiFileName(logoBasePath + ".png"));
+    }
 #else
     return applicationIcon().pixmap(64);
 #endif