mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
More QIcon.ic usage
This commit is contained in:
parent
aee016b897
commit
2d44370c25
@ -119,7 +119,7 @@ class BOOX(HANLINV3):
|
|||||||
supported_platforms = ['windows', 'osx', 'linux']
|
supported_platforms = ['windows', 'osx', 'linux']
|
||||||
METADATA_CACHE = '.metadata.calibre'
|
METADATA_CACHE = '.metadata.calibre'
|
||||||
DRIVEINFO = '.driveinfo.calibre'
|
DRIVEINFO = '.driveinfo.calibre'
|
||||||
icon = I('devices/boox.png')
|
icon = 'devices/boox.png'
|
||||||
|
|
||||||
# Ordered list of supported formats
|
# Ordered list of supported formats
|
||||||
FORMATS = ['epub', 'fb2', 'djvu', 'pdf', 'html', 'txt', 'rtf', 'mobi',
|
FORMATS = ['epub', 'fb2', 'djvu', 'pdf', 'html', 'txt', 'rtf', 'mobi',
|
||||||
|
@ -56,7 +56,7 @@ class KINDLE(USBMS):
|
|||||||
|
|
||||||
name = 'Kindle Device Interface'
|
name = 'Kindle Device Interface'
|
||||||
gui_name = 'Amazon Kindle'
|
gui_name = 'Amazon Kindle'
|
||||||
icon = I('devices/kindle.png')
|
icon = 'devices/kindle.png'
|
||||||
description = _('Communicate with the Kindle e-book reader.')
|
description = _('Communicate with the Kindle e-book reader.')
|
||||||
author = 'John Schember'
|
author = 'John Schember'
|
||||||
supported_platforms = ['windows', 'osx', 'linux']
|
supported_platforms = ['windows', 'osx', 'linux']
|
||||||
|
@ -1382,7 +1382,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
' Aura H2O Edition 2, Clara HD, Forma, Libra H2O, Elipsa,'
|
' Aura H2O Edition 2, Clara HD, Forma, Libra H2O, Elipsa,'
|
||||||
' Sage and Libra 2 eReaders.'
|
' Sage and Libra 2 eReaders.'
|
||||||
' Based on the existing Kobo driver by %s.') % KOBO.author
|
' Based on the existing Kobo driver by %s.') % KOBO.author
|
||||||
# icon = I('devices/kobotouch.jpg')
|
# icon = 'devices/kobotouch.jpg'
|
||||||
|
|
||||||
supported_dbversion = 170
|
supported_dbversion = 170
|
||||||
min_supported_dbversion = 53
|
min_supported_dbversion = 53
|
||||||
|
@ -19,7 +19,7 @@ class NOOK(USBMS):
|
|||||||
gui_name = _('The Nook')
|
gui_name = _('The Nook')
|
||||||
description = _('Communicate with the Nook e-book reader.')
|
description = _('Communicate with the Nook e-book reader.')
|
||||||
author = 'John Schember'
|
author = 'John Schember'
|
||||||
icon = I('devices/nook.png')
|
icon = 'devices/nook.png'
|
||||||
supported_platforms = ['windows', 'linux', 'osx']
|
supported_platforms = ['windows', 'linux', 'osx']
|
||||||
|
|
||||||
# Ordered list of supported formats
|
# Ordered list of supported formats
|
||||||
|
@ -37,7 +37,7 @@ from calibre.utils.date import UNDEFINED_DATE
|
|||||||
from calibre.utils.file_type_icons import EXT_MAP
|
from calibre.utils.file_type_icons import EXT_MAP
|
||||||
from calibre.utils.localization import get_lang
|
from calibre.utils.localization import get_lang
|
||||||
from polyglot import queue
|
from polyglot import queue
|
||||||
from polyglot.builtins import iteritems, itervalues, string_or_bytes
|
from polyglot.builtins import iteritems, string_or_bytes
|
||||||
|
|
||||||
del pqc
|
del pqc
|
||||||
try:
|
try:
|
||||||
@ -645,23 +645,10 @@ class FileIconProvider(QFileIconProvider):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QFileIconProvider.__init__(self)
|
QFileIconProvider.__init__(self)
|
||||||
upath, bpath = I('mimetypes'), I('mimetypes', allow_user_override=False)
|
self.icons = {k:f'mimetypes/{v}.png' for k, v in self.ICONS.items()}
|
||||||
if upath != bpath:
|
|
||||||
# User has chosen to override mimetype icons
|
|
||||||
path_map = {v:I('mimetypes/%s.png' % v) for v in set(itervalues(self.ICONS))}
|
|
||||||
icons = self.ICONS.copy()
|
|
||||||
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
|
|
||||||
icons[ukey] = ukey
|
|
||||||
else:
|
|
||||||
path_map = {v:os.path.join(bpath, v + '.png') for v in set(itervalues(self.ICONS))}
|
|
||||||
icons = self.ICONS
|
|
||||||
self.icons = {k:path_map[v] for k, v in iteritems(icons)}
|
|
||||||
self.icons['calibre'] = I('lt.png', allow_user_override=False)
|
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.ic(self.icons[i])
|
||||||
|
|
||||||
def key_from_ext(self, ext):
|
def key_from_ext(self, ext):
|
||||||
key = ext if ext in list(self.icons.keys()) else 'default'
|
key = ext if ext in list(self.icons.keys()) else 'default'
|
||||||
@ -674,7 +661,7 @@ class FileIconProvider(QFileIconProvider):
|
|||||||
candidate = self.icons[key]
|
candidate = self.icons[key]
|
||||||
if isinstance(candidate, QIcon):
|
if isinstance(candidate, QIcon):
|
||||||
return candidate
|
return candidate
|
||||||
icon = QIcon(candidate)
|
icon = QIcon.ic(candidate)
|
||||||
self.icons[key] = icon
|
self.icons[key] = icon
|
||||||
return icon
|
return icon
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user