How to set the application icon if qmake overwrites the pkg file?
I'm developing a Qt app for S60 (3rd edition FP2) and I'd like to use my own application icon.
I know this has been discussed elsewhere, but the documentation seems to be conflicting. I've tried...
[URL="http://wiki.forum.nokia.com/index.php/How_to_create_application_icon(SVG)_in_S60_3rd_edition"]http://wiki.forum.nokia.com/index.php/How_to_create_application_icon(SVG)_in_S60_3rd_edition[/URL]
and
[URL="http://wiki.forum.nokia.com/index.php/How_to_define_application_icon"]
http://wiki.forum.nokia.com/index.php/How_to_define_application_icon[/URL]
...but neither works for me. I've tried creating my own SVGs and tried using the SVG file from an existing example app. I've also rebuilding from clean, restarting the phone, deleting the app and reinstalling, etc.
mifconv seems to work fine (and, yes, I've checked to make sure I've used the right file names and paths).
I guess the problem is that qmake is overwriting the pkg file(s). How can I set the values for the mif and mbm files (to use the bitmap example) if not in the pkg file?
Are there definitive instructions somewhere, explaining how to set a custom application icon?
Sam Dutton
Re: How to set the application icon if qmake overwrites the pkg file?
Whatever qmake does generate is based on instructions found in the *.pro file. Your question becomes thus what statement should be added to *.pro that inserts the needed *.mif in the pkg file.
Until we find the answer to this question the workaround is to make a copy of the PKG file, edit it according to your needs and then call "createsis create <file>.pkg" in order to generate a self-signed package. (for advanced use cases see makesis.exe and signsis.exe)
Re: How to set the application icon if qmake overwrites the pkg file?
Solution #2: add an icon to all the Qt for S60 projects by modifying bool SymbianMakefileGenerator::generatePkgFile(const QString &compiler, const QString &config) in \qmake\generators\symbian\symmake.cpp
Re: How to set the application icon if qmake overwrites the pkg file?
You can simply make changes to one of the generated package files and save it with a different name, then use the same 'createpackage' convenience script provided with the Qt for S60 releases.
There should be a way to add the necessary files to the .pkg via the DEPLOYMENT keyword in the .pro file but I haven't had a chance to try it out yet. You could check to see if it's used in any of the examples/demos.
Mark
Re: How to set the application icon if qmake overwrites the pkg file?
Thanks for all the suggestions, but I still haven't managed to get this to work.
This is what I've done so far...
1. Followed the instructions for creating using bitmap icons here: [URL="http://wiki.forum.nokia.com/index.php/How_to_define_application_icon"]http://wiki.forum.nokia.com/index.php/How_to_define_application_icon[/URL]
2. Created a copy of my pkg file, added the following and saved:
"test.mif" -"!:\resource\apps\test_reg.mif"
"test.mbm" -"!:\resource\apps\test_reg.mbm"
3. Ran createpackage on the new pkg file.
4. Deleted existing applications from my (N96) phone.
5. Copied the new application onto the phone, having changed some text to make sure it was actually the new version.
6. Turned off the phone and turned it on again.
I've done all this without errors, but the icon stays with the default 'jigsaw piece'. :confused:
Just a thought -- does it matter that the application is self-signed?
Re: How to set the application icon if qmake overwrites the pkg file?
Hi,
Possibly your problem here is that the application registration file is also getting overwritten by qmake? It's certainly generated.
ICON handling seems to be somewhat platform specific in Qt, so I expect we'll get something easy to use in a future release.
It should be possible to hack around it in the way you're attempting though. Perhaps you'll have to create a copy of the app reg file and modify the package to install that one instead too?
Mark
P.S. No, self-signed is fine for changing icons.
Re: How to set the application icon if qmake overwrites the pkg file?
As Sorcery said the key must be in the resource files, they must contain a valid registration resource and the icon file (which is either mif or mbm, not both) properly specified there (name, number of icon frames). I would not expect the resource file to be overwritten but, as indicated above, you can if needed modify qmake's generators to ensure that the icon definition is persistent.
Re: How to set the application icon if qmake overwrites the pkg file?
You're right: qmake overwrites myapp_reg.rss (I take it this is the reg file?) so it looks for the moment like you have to rebuild qmake...
Here's a response from Janne Anttila on the QtS60-feedback list:
[QUOTE]At the moment QtS60 does not have build-in support for custom application icons - the work is in progress. In upcoming releases there will be mechanism to set custom application icon via pro file by giving the SVG icon name.
Meanwhile you should be able to set the application icon by following the instructions in S60 help.
In addition, you will need to modify files generated by qmake to take the icon in use and to deploy it correctly to device.[/QUOTE]
Sam
Re: How to set the application icon if qmake overwrites the pkg file?
Yes, myapp_reg.rss is the application registration file. Without it an application, while present in the file system, doesn't appear in the applications menu anywhere.
So, you can probably solve the problem with a separate copy of the registration file. Since this isn't the way you'll need to do it in the longer term, it might not be worth bothering and just put up with the default icon for now?
Mark
Re: How to set the application icon if qmake overwrites the pkg file?
I'm going to wait for the ability to do this in the .pro file -- as you suggest...
I tried creating a separate reg file with the icon stuff and changing the .pro file to reference this, but it didn't work.
There are several places in hacking this where I'm not sure what I'm doing, or may have made a silly mistake, so I'm going to give up and put up with the default icon for now!
Re: How to set the application icon if qmake overwrites the pkg file?
As this discussion was continuing on the feedback mailing list it is better to put it back in the public space and fix it (at least as a temporary hack). The following changes are to be made to project files which then are to be set as read-only as to prevent them from being overwritten by qmake.
=================
It is advisable to use an SVG icon and to get you started use the one from the S60 SDK's HelloWorld.
Modify bld.inf in order to add a make script that will build the icon (unless you want to do this manually each time you change the icon, not very often anyway). Just copy the make script from one SDK example and edit the source file names in it according to your project layout.
Once you have the *.mif file (or the *.mk that will build it) you will have to modify the following files:
- *.rss - ensure icon_file and number_of_icons are set properly
[CODE]RESOURCE LOCALISABLE_APP_INFO [COLOR="DarkOrange"]r_helloworldbasic_localisable_app_info[/COLOR]
{
short_caption = STRING_r_hewb_caption_string; // or "AppName"
caption_and_icon =
CAPTION_AND_ICON_INFO
{
caption = STRING_r_hewb_caption_string; // or "Long App Name"
number_of_icons = [COLOR="Red"]1[/COLOR]; // 1 for MIF, could be more, of different sizes for MBM (count image + mask pair as one icon)
icon_file = "[COLOR="Red"]\\resource\\apps\\Helloworldbasic_aif.mif[/COLOR]";
};
}[/CODE]
- *_reg.rss - ensure localisable_resource_id points to the localized resource defined above (name CAPITALIZED)
[CODE]RESOURCE APP_REGISTRATION_INFO
{
app_file="HelloWorldBasic";
localisable_resource_file = STRING_r_helloworldbasic_loc_resource_file_1;
localisable_resource_id = [COLOR="DarkOrange"]R_HELLOWORLDBASIC_LOCALISABLE_APP_INFO[/COLOR];
embeddability=KAppNotEmbeddable;
newfile=KAppDoesNotSupportNewFile;
}[/CODE]
finally, modify the *.pkg adding a line that will package the icon file to deployment
[CODE]"$(EPOCROOT)\epoc32\data\z\resource\apps\helloworldbasic_aif.mif" -"!:\resource\apps\helloworldbasic_aif.mif"[/CODE]
If all this is in place your icon will show up.
Re: How to set the application icon if qmake overwrites the pkg file?
Thanks, ltomuta, for your detailed reply.
I don't want to waste (more of) your time, but one basic question: when creating a Qt project from Carbide, only a *_reg.rss is created: not a *.rss file.
What part of the build process creates the *.rss rile? How can I add this resource to the Qt project -- or should I include the RESOURCE LOCALISABLE_APP_INFO code elsewhere?
Sam
Re: How to set the application icon if qmake overwrites the pkg file?
Ups, that's the problem of solving a problem "in theory" and not verifying it in practice. That was more of a "normal" resource linking for a Symbian C++ project.
Put the structure intended for the *.RSS file in the *_reg.RSS and then compile the project again.
I will try this myself some time this evening and I promise to bring you a working solution tomorrow :)
Re: How to set the application icon if qmake overwrites the pkg file?
1 Attachment(s)
Re: How to set the application icon if qmake overwrites the pkg file?
Ok, here's the solution. It is in fact the same as desribed above, with a new file *_loc.rss added to the project and holding the localizable registration resource.
[code] #include <appinfo.rh>
RESOURCE LOCALISABLE_APP_INFO r_local_qtmwappwithicon
{
short_caption = "AppIcon";
caption_and_icon =
{
CAPTION_AND_ICON_INFO
{
caption = "App With Icon";
number_of_icons = 1; // each icon must be a bitmap/mask pair
icon_file = "\\resource\\apps\\qtmwappwithicon.mif";
}
};
}
[/code]
That is then linked to the *_reg.rss as described above.
[CODE]#include <appinfo.rh>
#include <QtMWAppWithIcon_loc.rsg>
UID2 KUidAppRegistrationResourceFile
UID3 0xE44F599D
RESOURCE APP_REGISTRATION_INFO
{
app_file="QtMWAppWithIcon";
localisable_resource_file="\\resource\\apps\\QtMWAppWithIcon_loc";
localisable_resource_id = R_LOCAL_QTMWAPPWITHICON;
embeddability=KAppNotEmbeddable;
newfile=KAppDoesNotSupportNewFile;
}
[/CODE]
The *.mif file I've used is one built already for the helloworldbasic example, I've just make a copy of it in place (at \epoc32\release\winscw\udeb\z\resource\apps ).
The additions to the MMP file:
[CODE]
...
SOURCEPATH .
start resource QtMWAppWithIcon_loc.rss
targetpath \resource\apps
lang 01
HEADER
end
START RESOURCE "QtMWAppWithIcon_reg.rss"
...
[/CODE]
Finally, the new built files should be added to the package (*.pkg), in my case
[CODE]"\S60\devices\S60_5th_Edition_SDK_v0.9\epoc32\data\z\resource\apps\QtMWAppWithIcon.mif" -"!:\resource\apps\QtMWAppWithIcon.mif"
"\S60\devices\S60_5th_Edition_SDK_v0.9\epoc32\data\z\resource\apps\QtMWAppWithIcon_loc.r01" -"!:\resource\apps\QtMWAppWithIcon_loc.r01"[/CODE]
Remember to set all modified files as read only and as you don't really want to prevent to make legitimate changes to them you will have to apply the hacks only when the project is otherwise completed.
[img]http://i39.tinypic.com/2qx963c.jpg[/img]