This commit is contained in:
Kovid Goyal 2022-07-04 21:42:10 +05:30
parent 8ebb585539
commit 21c2b5f048
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 5 deletions

View File

@ -79,10 +79,10 @@ def get_icons(zfp, name_or_list_of_names, plugin_name=''):
if plugin_name:
for name in namelist:
q = QIcon.ic(f'{plugin_name}/{name}')
if q.isNull() or not len(q.availableSizes()):
failed.add(name)
else:
if q.is_ok():
ans[name] = q
else:
failed.add(name)
else:
failed = set(namelist)
if failed:

View File

@ -167,11 +167,11 @@ class IconResourceManager:
return QIcon(q)
icon_name = os.path.splitext(name.replace('\\', '__').replace('/', '__'))[0]
ans = QIcon.fromTheme(icon_name)
if ans.isNull() or not len(ans.availableSizes()):
if not ans.is_ok():
if 'user-any' in QIcon.themeName():
tc = 'dark' if QApplication.instance().is_dark_theme else 'light'
q = QIcon(f':/icons/calibre-default-{tc}/images/{name}')
if not q.isNull() and len(q.availableSizes()):
if q.is_ok():
ans = q
return ans
@ -203,6 +203,7 @@ class IconResourceManager:
icon_resource_manager = IconResourceManager()
QIcon.ic = icon_resource_manager
QIcon.icon_as_png = icon_resource_manager.icon_as_png
QIcon.is_ok = lambda self: not self.isNull() and len(self.availableSizes()) > 0
# Setup gprefs {{{