Improve icon recolouring API
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());
WIP because it's lacking API documentation
Edited by Aleix Pol Gonzalez