KIO: How best to add custom icons to items from a kioslave?

David Faure faure at kde.org
Wed Nov 4 00:28:41 GMT 2009


On Saturday 24 October 2009, Friedrich W. H. Kossebau wrote:
> Hi,
> 
> (seems like there are no KIO experienced people on kde-devel, so resent
>  here)
> 
> I am currently working on adding a UPnP-backend to the network:/ kioslave,
> based on Coherence [B]. So you can also browse (and connect to, if there
>  are handlers for the services offered) UPnP-enabled devices using KIO.
> 
> [B] http://frinring.wordpress.com/2009/10/04/coherencekde-sprint-day-1/
> 
> Now these devices can have custom icons (cmp. favicons). And it would be
>  great to have them show up in Konqueror as symbol for the device, wouldn't
>  it. What is the best approach?
> 
> I haven't seen a way to set custom icons (as in pixmap, not string ids) to
> UDSEntries. As the kioslave might not know which icon size to use, this
>  seems only fair.

So the pixmap comes from the device itself, not from a themed icon?
In that case the icon size is the one you get from the device, no? Or can you 
get many sizes?

Anyway saving it to a file (like for favicons) would be a solution then, I 
think, and then you can use UDS_ICON with a full path... No idea how to handle 
the life cycle of these temp files though.

(BTW the actual favicon support is: KMimeType makes a dbus call to the kded 
module favicons, implemented in kdebase/apps/lib/konq/favicons. But that's not 
extensible right now).

> Is there some additional interface to kioslaves which is used to get custom
> icons?

No, from kioslaves there's only UDS_ICON.

But you're right, there's indeed the solution of using previews (aka 
thumbnails).

> Or is a proper "file" preview plugin the solution to this (best template
>  code where to be found)?

kdebase/runtime/kioslave/thumbnail/*

This is called by KIO::PreviewJob in kdelibs. Right now I can't figure out if 
it is only called for local files or for all urls. If the former then you'll 
need to extend that somehow; if the latter then that seems wasteful right now
(since we don't have the data for remote files anyway).
And in any case the usage of url.path() in thumbnail.cpp is wrong (should be 
.toLocalFile() when used as a local file, and then non-local-urls need to be 
handled somehow). But I'm too tired to do anything about that right now.

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. Konqueror (http://www.konqueror.org).




More information about the kde-core-devel mailing list