We can colorize icons based on the user's palette, so clear the pixmap cache when it changes.
Details
- Reviewers
emmanuelp mart - Group Reviewers
Dolphin - Commits
- R318:86d2aa321d54: [KStandardItemListWidget] Update icon when palette changes
When changing palette, the icons in Places sidebar reflect the change immediately
Diff Detail
- Repository
- R318 Dolphin
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Wouldn't it be easier if you just clear the pixmap cache on palette change? e.g. in MainWindow?
A palette change basically invalidates all cached icons, so I don't see any advantage in adding the palette information to the key (... use cases like frequently toggling between two palettes are not supported).
I had that originally but then saw the fancy approach KIconLoader used. I could surely just nuke the QPixmapCache in response to a palette change.
I see some potential problems with the QPalette key approach. The key only covers some parts of the palette, so it is not really future proof when colors different than text, highlight or highlighted text are used in future. It also requires more memory because the cache still holds old unused pixmaps (only true if number of used pixmaps doesn't exceed the cache limit). Also the keys are much longer which requires more work when generating and hashing the keys.
I would prefer the cache wipe, because this is exactly what we want to achieve (but less fragile) :)
- Just clear QPixmapCache
(I know there can be multiple (two?) DolphinViews in one app and we would clear multiple times in quick succession but I didn't want to add a new event listener just for this)