Ok, I've given that method a go. I guess my head was still thinking about that config\resources\images directory and being able to make use of that. However I can see where you are coming from in terms of keeping the plugin completely self-contained even after "install".
Being in the resources directory did have a minor advantage in that it means that you can use self.create_action to create your menus since that just takes an icon name, however now you must pass None to that for the icon and then use a separate .setIcon call afterwards.
The other potential nasty with this approach is typified by the search the internet plugin where users can have custom images for when they add their own websites to the menu. That means either:
- they should manually add their images to the plugin zip file within the Calibre configuration folder (and remember to do that any time they upgrade the plugin). Don't like that idea.
- or I support them using the config/resources/images directory. In which case I have to trap ValueError since I don't know whether an icon will or won't be in the zip when building the menus with code like this:
actual_icon = None
resource = self.load_resource(icon_name)
pixmap = QPixmap()
actual_icon = QIcon(pixmap)
actual_icon = QIcon(I(icon_name))
And yeah as Chaley says if you have a lot of icons you are opening/closing the zip a lot of times.
I've written the code, and it works, but I won't publish it on the gui plugins thread until the next version of Calibre is out and you are 100% happy that this is the approach you want to take. I don't mind tweaking the plugin code further if anything is changed.
Didn't see Kovid's post above that had made a further change to the API, let me give that a go...