mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Only return a dummy PNG to Qt if the resource being loaded has a raster image extension
This commit is contained in:
parent
308f163a03
commit
d9f2449ddc
@ -28,7 +28,7 @@ from calibre.gui2.widgets import LineEditECM
|
|||||||
from calibre.gui2.widgets2 import to_plain_text
|
from calibre.gui2.widgets2 import to_plain_text
|
||||||
from calibre.utils.config import tweaks
|
from calibre.utils.config import tweaks
|
||||||
from calibre.utils.imghdr import what
|
from calibre.utils.imghdr import what
|
||||||
from polyglot.builtins import filter, iteritems, itervalues, unicode_type, as_bytes
|
from polyglot.builtins import filter, iteritems, itervalues, unicode_type
|
||||||
|
|
||||||
# Cleanup Qt markup {{{
|
# Cleanup Qt markup {{{
|
||||||
|
|
||||||
@ -764,12 +764,13 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
|
|||||||
with lopen(path, 'rb') as f:
|
with lopen(path, 'rb') as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
return QByteArray(bytearray.fromhex(
|
if path.rpartition('.')[-1].lower() in {'jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp'}:
|
||||||
'89504e470d0a1a0a0000000d49484452'
|
return QByteArray(bytearray.fromhex(
|
||||||
'000000010000000108060000001f15c4'
|
'89504e470d0a1a0a0000000d49484452'
|
||||||
'890000000a49444154789c6300010000'
|
'000000010000000108060000001f15c4'
|
||||||
'0500010d0a2db40000000049454e44ae'
|
'890000000a49444154789c6300010000'
|
||||||
'426082'))
|
'0500010d0a2db40000000049454e44ae'
|
||||||
|
'426082'))
|
||||||
else:
|
else:
|
||||||
return QByteArray(data)
|
return QByteArray(data)
|
||||||
|
|
||||||
|
@ -489,16 +489,18 @@ class HTMLDisplay(QTextBrowser):
|
|||||||
with lopen(path, 'rb') as f:
|
with lopen(path, 'rb') as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
return QByteArray(bytearray.fromhex(
|
if path.rpartition('.')[-1].lower() in {'jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp'}:
|
||||||
'89504e470d0a1a0a0000000d49484452'
|
return QByteArray(bytearray.fromhex(
|
||||||
'000000010000000108060000001f15c4'
|
'89504e470d0a1a0a0000000d49484452'
|
||||||
'890000000a49444154789c6300010000'
|
'000000010000000108060000001f15c4'
|
||||||
'0500010d0a2db40000000049454e44ae'
|
'890000000a49444154789c6300010000'
|
||||||
'426082'))
|
'0500010d0a2db40000000049454e44ae'
|
||||||
|
'426082'))
|
||||||
else:
|
else:
|
||||||
return QByteArray(data)
|
return QByteArray(data)
|
||||||
else:
|
else:
|
||||||
QTextBrowser.loadResource(self, rtype, qurl)
|
return QTextBrowser.loadResource(self, rtype, qurl)
|
||||||
|
|
||||||
|
|
||||||
class ScrollingTabWidget(QTabWidget):
|
class ScrollingTabWidget(QTabWidget):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user