mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-11-25 15:55:02 -05:00
Also use an icon for custom recipes
This commit is contained in:
parent
a8a9e5792c
commit
9cfbbc2082
@ -666,7 +666,7 @@ class Scheduler(QObject):
|
|||||||
if history:
|
if history:
|
||||||
for arg in reversed(history):
|
for arg in reversed(history):
|
||||||
ac = QAction(arg['title'], m)
|
ac = QAction(arg['title'], m)
|
||||||
ac.setIcon(QIcon(self.recipe_model.favicon_for_urn(arg['urn'])))
|
ac.setIcon(self.recipe_model.favicon_for_urn(arg['urn']))
|
||||||
m.addAction(ac)
|
m.addAction(ac)
|
||||||
ac.triggered.connect(partial(self.download, arg['urn']))
|
ac.triggered.connect(partial(self.download, arg['urn']))
|
||||||
m.addSeparator()
|
m.addSeparator()
|
||||||
|
|||||||
@ -171,8 +171,8 @@ class RecipeModel(QAbstractItemModel, AdaptSQP):
|
|||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
QAbstractItemModel.__init__(self, *args)
|
QAbstractItemModel.__init__(self, *args)
|
||||||
SearchQueryParser.__init__(self, locations=['all'])
|
SearchQueryParser.__init__(self, locations=['all'])
|
||||||
self.default_icon = (QIcon.ic('news.png'))
|
self.default_icon = QIcon.ic('news.png')
|
||||||
self.custom_icon = (QIcon.ic('user_profile.png'))
|
self.custom_icon = QIcon.ic('user_profile.png')
|
||||||
self.builtin_recipe_collection = get_builtin_recipe_collection()
|
self.builtin_recipe_collection = get_builtin_recipe_collection()
|
||||||
self.scheduler_config = SchedulerConfig()
|
self.scheduler_config = SchedulerConfig()
|
||||||
self.favicon_cache = {}
|
self.favicon_cache = {}
|
||||||
@ -288,7 +288,7 @@ class RecipeModel(QAbstractItemModel, AdaptSQP):
|
|||||||
self.root = new_root
|
self.root = new_root
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def favicon_for_urn(self, urn: str) -> QPixmap:
|
def favicon_for_urn(self, urn: str) -> QIcon:
|
||||||
icon = urn[8:] + '.png'
|
icon = urn[8:] + '.png'
|
||||||
if not (p := self.favicon_cache.get(icon)):
|
if not (p := self.favicon_cache.get(icon)):
|
||||||
p = QPixmap()
|
p = QPixmap()
|
||||||
@ -299,6 +299,9 @@ class RecipeModel(QAbstractItemModel, AdaptSQP):
|
|||||||
p.loadFromData(zf.read(self.favicons[icon]))
|
p.loadFromData(zf.read(self.favicons[icon]))
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
elif urn.startswith('custom:'):
|
||||||
|
p = self.custom_icon
|
||||||
|
p = QIcon(p)
|
||||||
self.favicon_cache[icon] = p
|
self.favicon_cache[icon] = p
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user