Skip to content

Improve icon recolouring API

Aleix Pol Gonzalez requested to merge work/colors-per-icon into master

Would allow us to do:

-    QPalette pal = palette();
     if (customColor != Qt::transparent) {
-        for (auto state : {QPalette::Active, QPalette::Inactive, QPalette::Disabled}) {
-            pal.setBrush(state, QPalette::WindowText, customColor);
-        }
+        KIconColors colors;
+        colors.setText(customColor);
+        return KDE::icon(name, colors);
+    } else {
+        return KDE::icon(name);
     }
 
-    bool hadPalette = KIconLoader::global()->hasCustomPalette();
-    QPalette olderPalette = KIconLoader::global()->customPalette();
-
-    auto cleanup = qScopeGuard([&] {
-        if (hadPalette) {
-            KIconLoader::global()->setCustomPalette(olderPalette);
-        } else {
-            KIconLoader::global()->resetPalette();
-        }
-    });
-
-    KIconLoader::global()->setCustomPalette(pal);
-    return KDE::icon(name, KIconLoader::global());

BUG: 442569

WIP because it's lacking API documentation

Edited by Aleix Pol Gonzalez

Merge request reports

Loading