Use Cal6 get_icons() so icon themes apply--print_tracebacks_for_missing_resources=False cal 6.2+.

This commit is contained in:
Jim Miller 2022-07-20 13:33:26 -05:00
parent ce6df518a2
commit 314ff73280

View file

@ -41,16 +41,33 @@ def set_plugin_icon_resources(name, resources):
plugin_name = name
plugin_icon_resources = resources
# print_tracebacks_for_missing_resources first appears in cal 6.2.0
if calibre_version >= (6,2,0):
def get_icons_nolog(icon_name,plugin_name):
return get_icons(icon_name,
plugin_name,
print_tracebacks_for_missing_resources=False)
else:
get_icons_nolog = get_icons
def get_icon_6plus(icon_name):
'''
Retrieve a QIcon for the named image from the zip file if it exists,
or if not then from Calibre's image cache.
Retrieve a QIcon for the named image from
1. Calibre's image cache
2. resources/images
3. the icon theme
4. the plugin zip
Only plugin zip has images/ in the image name for backward
compatibility.
'''
if icon_name:
## look in theme 1st, plugin zip 2nd
## both .ic and get_icons return an empty QIcon if not found.
icon = QIcon.ic(icon_name)
## both .ic and get_icons return an empty QIcon if not found.
if not icon or icon.isNull():
# don't need a tracestack from get_icons just because
# there's no icon in the theme
icon = get_icons_nolog(icon_name.replace('images/',''),
plugin_name)
if not icon or icon.isNull():
icon = get_icons(icon_name,plugin_name)
return icon
@ -69,6 +86,7 @@ def get_icon_old(icon_name):
return QIcon(pixmap)
return QIcon()
# get_icons changed in Cal6.
if calibre_version >= (6,0,0):
get_icon = get_icon_6plus
else: