12-15-2010, 11:02 AM | #16 | |
creator of calibre
Posts: 43,856
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Quote:
|
|
12-15-2010, 12:09 PM | #17 |
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
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: Code:
actual_icon = None try: resource = self.load_resource(icon_name) pixmap = QPixmap() pixmap.loadFromData(resource) actual_icon = QIcon(pixmap) except ValueError: actual_icon = QIcon(I(icon_name)) ac.setIcon(actual_icon) 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. EDIT: Didn't see Kovid's post above that had made a further change to the API, let me give that a go... Last edited by kiwidude; 12-15-2010 at 12:17 PM. |
12-15-2010, 12:17 PM | #18 | ||
Grand Sorcerer
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
|
||
12-15-2010, 12:18 PM | #19 |
creator of calibre
Posts: 43,856
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I'm happy with the approach. I've already fixed the multiple open problem. Feel free to update your plugin after the next release.
|
12-15-2010, 12:28 PM | #20 |
Calibre Plugins Developer
Posts: 4,637
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
Thanks Chaley/Kovid, I'll give that a go, looks more optimised. I do like the idea of being able to distribute a plugin that is just one zip the user never has to open. It should work nicely and much prefer as you say a test for presence in a dictionary over catching errors.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
New Plugin Type Idea: Library Plugin | cgranade | Plugins | 3 | 09-15-2010 12:11 PM |
Multicomputer Sync users - Do you sync the Config directory? | Starson17 | Calibre | 4 | 07-29-2010 01:07 AM |
How do I Create a Python Plugin? | Sydney's Mom | Plugins | 25 | 01-27-2010 06:26 AM |
How do I do create a directory on a PRS-500? | JSWolf | Calibre | 5 | 11-25-2009 11:53 AM |
Statusbar config? | tselling | PocketBook | 0 | 11-13-2009 10:47 AM |