[Qt-interest] How to get an icon associated with a certain filetype using Qt?
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Fri Mar 26 19:13:49 CET 2010
Nikos Chantziaras wrote on Friday, March 26, 2010 6:13 PM:
> On 03/26/2010 10:34 AM, Oliver.Knoll at comit.ch wrote:
>> Nikos Chantziaras wrote on Wednesday, March 24, 2010 7:10 PM:
>>
>>>> ...
>>>> And does it really have to be the icon of the application which can
>>>> deal with that MIME type? Or would "generic" icons be sufficient?
>> ...
>> The reason I was suggesting this is that there might be *multiple*
>> applications which would be able to deal with say MIME image/jpeg,
>> but only *one* application which is actually (directly) associated
>> ...
> And what generic icon are you going to pick? There's isn't even a
> generic one available :)
Well, there is always www.gimp.org and if you are a bit creative... ;) No seriously, off course I meant an icon provided by the application itself.
> And if you include generic icons in your
> app, what are you going to include? There are thousands of MIME
> types.
Hence my original question to the OP whether "generic icons would be sufficient". Maybe he just needs to deal with "typical web MIME types" such as JPEG/PNG/BMP... text, XML, ... that would be only a few dozens, and for those it should be feasible to create icons and embed them into the executable.
> The best that can be done is query the OS using the native API.
You are right, that might actually work on Linux (Unix) in case you are running Gnome or KDE. Indeed they seem to associate MIME types with applications, see http://en.wikipedia.org/wiki/File_association - see also http://ubuntuforums.org/showthread.php?t=383040 - it mentions "sudo update-mime-database /usr/share/mime/", so it seems that's where the MIME associations are stored.
But on Windows and Mac that would most likely not work, because as already mentioned Windows uses the file extension and Mac "type codes and creator codes". According to Wikipedia "more recent" versions (Mac OS X 10.x?) also support file extensions. Well, and maybe also MIME type: "Application bundles in OS X declare supported file types in their Info.plist file. [...] For example, the JPEG type is defined with a UTI of 'public.jpeg', and tagged with the extensions 'jpg' and 'jpeg', the MIME type 'image/jpeg' and the type code 'JPEG'."
So either make it platform-dependent with the proper API code (Windows?) or use "generic icons", in case you just have to deal with a few dozen MIME types.
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list