Use PNGs for branded clients
authorKevin Ottens <kevin.ottens@nextcloud.com>
Mon, 27 Jul 2020 15:34:42 +0000 (17:34 +0200)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Tue, 28 Jul 2020 09:20:34 +0000 (09:20 +0000)
For branded clients try to load a png of the right size, for unbranded
clients use the SVGs. If something fails at load time skip it.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/libsync/theme.cpp

index b62736860743e2583e0749aa3331cc251da7a9ea..f2dcb597b4837e3ae92c5899a2273737f98db253 100644 (file)
@@ -154,10 +154,18 @@ QIcon Theme::themeIcon(const QString &name, bool sysTray) const
             return QPixmap::fromImage(img);
         };
 
+        const auto loadPixmap = [flavor, name] (int size) {
+            const auto pixmapName = QString::fromLatin1(":/client/theme/%1/%2-%3.png").arg(flavor).arg(name).arg(size);
+            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 };
         for (int size : sizes) {
-            auto px = createPixmapFromSvg(size);
+            auto px = isBranded() ? loadPixmap(size) : createPixmapFromSvg(size);
+            if (px.isNull()) {
+                continue;
+            }
             // HACK, get rid of it by supporting FDO icon themes, this is really just emulating ubuntu-mono
             if (qgetenv("DESKTOP_SESSION") == "ubuntu") {
                 QBitmap mask = px.createMaskFromColor(Qt::white, Qt::MaskOutColor);