![]() |
#1 |
Connoisseur
![]() ![]() ![]() Posts: 88
Karma: 200
Join Date: Nov 2010
Location: Dortmund, Germany
Device: Kindle Paperwhite (10. Generation)
|
Icon for device plugin?
Hi!
I wrote a device plugin for the oyo aa while back, and I just thought that I'd give adding an icon a go. All my attempts failed. Can't get it to work with get_icons in __init__ or initialize cause it tells "QPixmap: Must construct a QApplication before a QPaintDevice" Then I thought it's just extract the image there and define it with icon = I('oyo.png') in the header, but that fails mainly due to me not really knowing where to extract it to. which approach would be best and you you tell me what I'm doing wrong? Extracting only once would probably be more efficent but only if the code is not called every time... |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,955
Karma: 26594922
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I() expands to the resources/images subdirectory in the calibre installation directory, but do not change the installation directory, instead see the customizing calibre section of the user manual, which tells you how to add your own resources to a calibre install ina robust manner.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Connoisseur
![]() ![]() ![]() Posts: 88
Karma: 200
Join Date: Nov 2010
Location: Dortmund, Germany
Device: Kindle Paperwhite (10. Generation)
|
I already figured out that I should put my image into the calibreConfig\resources\images folder (doing that by hand works) to load it with I(), but I still have not managed to get my plugin to put it's image there (e.g. I'm looking for a variable that contains this path).
Alternatively I would use the get_icons() function given in the document you are talking about, but there are no good examples where to use them in a device plugin cause call device plugins i know are written by you meaning the images are already contained in the installation. The obvious places for me were __init__ or initialize but it seems those get called to early, cause get_icons uses stuff from Qt and the methods are called before the qt windows in constructed. |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,955
Karma: 26594922
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Setting icon = I(...) will work if you have put the image in the correct place.
|
![]() |
![]() |
![]() |
#5 |
Calibre Plugins Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,701
Karma: 2197768
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
@silentguy
from calibre.utils.config import config_dir This is the user's local Calibre directory. You will then need to add the check for the resources\images subfolders to append to that path and create if not existing. Then as Kovid says I(xxx) will work (after Calibre is restarted). This approach is used by my Search The Internet and Open With plugins, both of which store downloaded images in that directory. The Generate Cover does something similar too. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Connoisseur
![]() ![]() ![]() Posts: 88
Karma: 200
Join Date: Nov 2010
Location: Dortmund, Germany
Device: Kindle Paperwhite (10. Generation)
|
Thanks kiwidude, this was what i was looking for.
works like a charm now. |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Troubleshooting animated busy icon when device idle (kindle 3) | firewired | Amazon Kindle | 3 | 03-30-2011 06:34 PM |
Calibre not showing Save to Device Icon | sissiromy | Calibre | 0 | 12-20-2010 12:45 PM |
Device interface plugin - nook | badmadbug | Plugins | 2 | 09-06-2010 11:03 AM |
Device plugin development | reader42 | Plugins | 10 | 03-29-2010 12:39 PM |
Icon representing and ebook reading device | kovidgoyal | Sony Reader | 31 | 10-23-2007 05:48 PM |