mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow users to add extra mimetype icons by placing appropriately named image files in the resources/mimetypes override directory
This commit is contained in:
parent
cac8476f0e
commit
64d37eae40
@ -539,10 +539,18 @@ class FileIconProvider(QFileIconProvider):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QFileIconProvider.__init__(self)
|
QFileIconProvider.__init__(self)
|
||||||
self.icons = {}
|
upath, bpath = I('mimetypes'), I('mimetypes', allow_user_override=False)
|
||||||
for key in self.__class__.ICONS.keys():
|
if upath != bpath:
|
||||||
self.icons[key] = I('mimetypes/')+self.__class__.ICONS[key]+'.png'
|
# User has chosen to override mimetype icons
|
||||||
self.icons['calibre'] = I('lt.png')
|
path_map = {v:I('mimetypes/%s.png' % v) for v in set(self.ICONS.itervalues())}
|
||||||
|
for uicon in glob.glob(os.path.join(upath, '*.png')):
|
||||||
|
ukey = os.path.basename(uicon).rpartition('.')[0].lower()
|
||||||
|
if ukey not in path_map:
|
||||||
|
path_map[ukey] = uicon
|
||||||
|
else:
|
||||||
|
path_map = {v:os.path.join(bpath, v + '.png') for v in set(self.ICONS.itervalues())}
|
||||||
|
self.icons = {k:path_map[v] for k, v in self.ICONS.iteritems()}
|
||||||
|
self.icons['calibre'] = I('lt.png', allow_user_override=False)
|
||||||
for i in ('dir', 'default', 'zero'):
|
for i in ('dir', 'default', 'zero'):
|
||||||
self.icons[i] = QIcon(self.icons[i])
|
self.icons[i] = QIcon(self.icons[i])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user