when compiling a qt app you don’t get the original icon built with it instead you get the default beos/haiku apps icon,so there are different ways for different OSs for building the icon,i just can’t find any doc about this topic for haiku.
as an example for macosx,you convert the original icon to .icns format like this eg: myapp.icns,then you create a text file with this line ( MACOXICON = mayapp.icns)then save the file as you wish ,once this is done you will add this line in your .pro file wich is the the project file of your app.
ICON_FILE += yournewlysavedfilename
so my question is ,how would it be for haiku?
what file do i have to create?
what line do i have to add to the .pro file?
The easiest way to insert an icon into a binary is open that binary with FileTypes. You’ll see an ‘Icon’ rectangle on the right – just drag another file into this square and it will change the binary’s icon… usually. The file has to have a vector icon resource itself. Most do.
For example, drag a text file into that square and you app will now have a text file icon (probably not what you want). If you already have some file that displays with the icon that you want in Tracker, then that file might work. I say “might” because that file may use bitmap icon(s) instead of a vector icon. Just drag it and see if it works.
If you can get it done that way – great, if not… you’ve got some work to do. I’ll do another post for that.
Icons are stored as resources in your app binary. The easiest way to view/edit resources is to use QuickRes. Download this from Haikuware. You absolutely should get QuickRes… seriously – the educational value of playing around with it alone is worth gold.
You can use QuickRes to create resource files. These usually have a “.rsrc” extension. They are binary files. There is also a text file equivalent format called rdef (resource definition) that usually have a “.rdef” extension.
Haiku comes with two builtin programs for dealing with resources. Xres inserts resouce data from a “.rsrc” file into a binary. And rc converts between “.rsrc” and “.rdef”.
xres -o $(appname) $(appname).rsrc
This line could be placed into a makefile, for example, to insert resource data (such as icons) into your app’s binary. Obviously, you must have defined ‘appname’ already. But how to create the rsrc file in the first place? Next post.
Ok, to get a rsrc file. Well, you could start from scratch using QuickRes, but that’s a lot of work. Plus QuickRes isn’t set up for creating VICN (vector icon) resources – it’s an old, old app back from the BeOS days. However, you can open up any other program with QuickRes and save the resources from that.
For example open /boot/system/apps/DeskCalc with QuickRes. You’ll see all the resources in that program. Now do a ‘Save As’ and give it a “.rsrc” file extension. Now you have a “DeskCalc.rsrc” resource file in the home directory. You could copy that file and edit it with QuickRes.
Alternately, you could change the resource file to an rdef file:
rc -d DeskCalc.rsrc -o DeskCalc.rdef
The rdef file is simply a text file version of the resource and you could modify it with any text editor. Rc can then turn an rdef back into a binary rsrc file:
rc $(appname).rdef -o $(appname).rsrc
This creates a binary rsrc file from the text rdef file. Then xres can be used to insert those resources into you app binary, as mentioned earlier.
Sorry, while I noticed your question I sadly can’t found an answer that would help before I got side-tracked somewhere else.
AFAICT, Qt’s qmake tool don’t know about an “haiku” trigger.
So you can’t configure an “haiku” configure option like that, qmake just wont know what to do with it.
To add a icon to a application, you need to:
create a resource file, an human readable .rdef file is preferred. Icon-O-Matic can export an icon as a .rdef file.
"compile" this .rdef file into a binary .rsrc file. The "rc" tool (for resource compiler) that comes with Haiku development environment will do that, check "rc --help" to knows how to launch it for that. You will find a very good article on rc written by his developer here: http://www.haiku-os.org/documents/dev/compile_them_resources
For an app icon, you need to put a resource of "vector_icon" type in the .rdef file. Ideally, you should also add app's flags, signature and supported file_types list. Give a look at any src/apps/*/*.rdef for a sample app resource (for instance this one: http://dev.haiku-os.org/browser/haiku/trunk/src/apps/stylededit/StyledEdit.rdef)
Last but not least, you will need to add to your qmake project the command to link the compiled .rsrc resource with the app binary. The tool "xres -o your-binary list-of-rsrc-files" does this, check its option on how to use it.
You may also call mimeset tool, so your new app (its signature and supported MIME types) will be known to the system application registrar.
thanks alot guys for taking the time to respond to my post,this seems much more complicated than how it is done on other platforms.
i’m gonna take some time to find my way between all this info,then i’ll write a tutorial about it,i think it’s worth to write one,so that it can help others.
IIRC, qmake use platform specific templates, so I guess to make it as easy as with others platforms one must look what’s supported regarding application’s icons (and more generally resources) in the templates made by the people who ported Qt to Haiku.
that’s indeed the best solution,if one could get help from one of these devs,but unfortunetly there is no way i could get in touch with them over at http://qt-haiku.ru ,or at osdrawer.
btw,do you know any tool that converts other icons to haiku_icons, i’m stuck right now,because icon o matic does produce a file when you export the original icon in the .HVIF format,but the file is totaly useless,you can’t even reopen it with icon o matic,whereas the original icons that come with the haiku source do get opened with it,so i’m suspecting a bug here in icon o matic if i’m not mistaking?
Icon-O-Matic has its own document format that include additional information. The icon in the artwork folder in the trunk are of that format to be easily edited. The HVIF format is the optimized small-as-possible version that is used as the data for the actual icon attribute of a file. See the user guide for more info.
You can convert icons to SVG and import that into I-O-M. Results vary, as SVG support may not be perfect yet. Also, Haiku’s icon format has other characteristics than “simple” SVG-like vector graphics. Paths are re-used, shapes transformed etc., which doesn’t translate well to SVG and is the reason I-O-M has such an unfamiliar usage.