Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 04-03-2011, 10:52 AM   #1
silentguy
Connoisseur
silentguy doesn't littersilentguy doesn't littersilentguy doesn't litter
 
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...
silentguy is offline   Reply With Quote
Old 04-03-2011, 11:28 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,866
Karma: 22666666
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.
kovidgoyal is offline   Reply With Quote
Old 04-03-2011, 12:01 PM   #3
silentguy
Connoisseur
silentguy doesn't littersilentguy doesn't littersilentguy doesn't litter
 
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.
silentguy is offline   Reply With Quote
Old 04-03-2011, 12:03 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Setting icon = I(...) will work if you have put the image in the correct place.
kovidgoyal is offline   Reply With Quote
Old 04-03-2011, 12:05 PM   #5
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,637
Karma: 2162064
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.
kiwidude is offline   Reply With Quote
Old 04-03-2011, 12:48 PM   #6
silentguy
Connoisseur
silentguy doesn't littersilentguy doesn't littersilentguy doesn't litter
 
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.
silentguy is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 06:41 PM.


MobileRead.com is a privately owned, operated and funded community.