[PATCH] Using KIcon for icons with overlay

Andreas Hartmetz ahartmetz at gmail.com
Sat Aug 25 12:23:56 BST 2007


On Thursday 23 August 2007 13:58:51 Gustavo Pichorim Boiko wrote:
> A Wednesday 22 August 2007 14:25:59, Aaron J. Seigo escreveu:
> > On Wednesday 22 August 2007, Gustavo Pichorim Boiko wrote:
> > > Is there a way to apply a custom effect to an icon (in this case
> > > applying a color) before it gets the overlays drawn?
> >
> > so you want the overlay to not have the same effect as the overlay,
> > correct? so the overlay would be done using the regular presentation
> > while the icon might be greyed out, colourized, etc ... essentially
> > anything in KIconEffect?
> >
> > > If not, would it be possible to change KIcon to support this before
> > > 4.0?
> >
> > probably. do you have any specific API suggestions?
>
> I've tried to do it in a not-much intrusive way.
> This patch adds a setEffect() method to KIconLoader. If you want a custom
> effect to be applied to a set of icons, just create a KIconLoader and set
> its effect, and use this loader when loading icons.
> Every time you change the effect, the cache of the iconloader is discarded,
> making sure the new effect is going to be applied to all requested icons.
>
> Please review it and make suggestions/critics to this approach.
>
Just as a general principle it's always better to carry as few state around as 
possible. The less there is to know about something you are using (a 
KIconLoader instance in that case) the easier it is to figure out what is 
actually happening in a piece of code.
There are other factors, of course. I just wanted to point out that if you can 
make effects "stateless" without major disadvantages you should definitely do 
so. AFAIK (not really sure) KIconLoader is also not exactly lightweight, 
which would be another reason to not have more of them around in an 
application than you absolutely need.

Cheers,
Andreas




More information about the kde-core-devel mailing list