mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-05-09 05:21:13 +02:00
Use Cal6 get_icons() so icon themes apply--print_tracebacks_for_missing_resources=False cal 6.2+.
This commit is contained in:
parent
ce6df518a2
commit
314ff73280
1 changed files with 22 additions and 4 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue