[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: How kde find a proper icon for a file with certain mimetype?
From:       Sebastian Sauer <mail () dipe ! org>
Date:       2008-08-30 4:49:18
Message-ID: 200808300649.18220.mail () dipe ! org
[Download RAW message or body]

Dong Tiger wrote:

>> KMimeType::iconName()
>> KMimeType::iconNameForUrl()

> Sorry I didn't make question clear. I can't use KDE library in my program
> but I want to show the same icon as KDE. So my question is where kde gets
> the information to map mimetypes to icon names. Are there some
> configuration files?

Well, the info provided by Rafael does offer us a good starting point since by 
looking at kmimetype.cpp 
(http://websvn.kde.org/trunk/KDE/kdelibs/kdecore/services/kmimetype.cpp), 
it's possible to get an impression what is done within the 
KMimeType::iconNameForUrl() method to map a URL=>mimetype=>icon.

It seems there may also be an easier way by just replacing in the mimetype "/" 
with "-" (so, e.g. image/png becomes image-png) and then look what the 
KIconLoader::iconPath() method 
(http://websvn.kde.org/trunk/KDE/kdelibs/kdeui/icons/kiconloader.cpp) is 
doing.

So, within a Qt-app it may needed to emulate/extract what findResource() does 
and to probably also try to fetch the information what icontheme is used 
(e.g. oxygen) to select the correct one.

here the commandline version (thx dfaure for the hint provided at another 
mail ;)
kiconfinder `echo image/png | sed -e 's,/,-,g'`
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic