[KStandardItemListWidget] Update icon when palette changes
ClosedPublic

Authored by broulik on Jan 3 2017, 4:06 PM.

Details

Summary

We can colorize icons based on the user's palette, so clear the pixmap cache when it changes.

Test Plan

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.
broulik updated this revision to Diff 9661.Jan 3 2017, 4:06 PM
broulik retitled this revision from to [KStandardItemListWidget] Update icon when palette changes.
broulik updated this object.
broulik edited the test plan for this revision. (Show Details)
broulik added reviewers: Dolphin, emmanuelp, mart.
broulik set the repository for this revision to R318 Dolphin.
emmanuelp edited edge metadata.Jan 12 2017, 7:07 AM

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) :)

broulik updated this revision to Diff 10488.Jan 24 2017, 11:31 AM
broulik edited edge metadata.
  • 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)

broulik updated this object.Jan 24 2017, 11:31 AM
broulik edited the test plan for this revision. (Show Details)
emmanuelp accepted this revision.Feb 5 2017, 7:49 PM
emmanuelp edited edge metadata.

Looks good otherwise!

src/views/dolphinview.cpp
736

remove the empty line

This revision is now accepted and ready to land.Feb 5 2017, 7:49 PM
This revision was automatically updated to reflect the committed changes.