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,6 +764,7 @@ 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:
|
||||||
|
if path.rpartition('.')[-1].lower() in {'jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp'}:
|
||||||
return QByteArray(bytearray.fromhex(
|
return QByteArray(bytearray.fromhex(
|
||||||
'89504e470d0a1a0a0000000d49484452'
|
'89504e470d0a1a0a0000000d49484452'
|
||||||
'000000010000000108060000001f15c4'
|
'000000010000000108060000001f15c4'
|
||||||
|
@ -489,6 +489,7 @@ 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:
|
||||||
|
if path.rpartition('.')[-1].lower() in {'jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp'}:
|
||||||
return QByteArray(bytearray.fromhex(
|
return QByteArray(bytearray.fromhex(
|
||||||
'89504e470d0a1a0a0000000d49484452'
|
'89504e470d0a1a0a0000000d49484452'
|
||||||
'000000010000000108060000001f15c4'
|
'000000010000000108060000001f15c4'
|
||||||
@ -498,7 +499,8 @@ class HTMLDisplay(QTextBrowser):
|
|||||||
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