mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Do not save resources in document for book details panel as I dont know what hte lifetime of saved resources is
This commit is contained in:
parent
308c6d4389
commit
ae5ea18ccf
@ -972,7 +972,7 @@ class BookInfo(HTMLDisplay):
|
|||||||
notes_resource_scheme = RESOURCE_URL_SCHEME
|
notes_resource_scheme = RESOURCE_URL_SCHEME
|
||||||
|
|
||||||
def __init__(self, vertical, parent=None):
|
def __init__(self, vertical, parent=None):
|
||||||
HTMLDisplay.__init__(self, parent)
|
HTMLDisplay.__init__(self, parent=parent, save_resources_in_document=False)
|
||||||
self.vertical = vertical
|
self.vertical = vertical
|
||||||
self.anchor_clicked.connect(self.link_activated)
|
self.anchor_clicked.connect(self.link_activated)
|
||||||
for x, icon in [
|
for x, icon in [
|
||||||
|
@ -520,8 +520,9 @@ class HTMLDisplay(QTextBrowser):
|
|||||||
anchor_clicked = pyqtSignal(object)
|
anchor_clicked = pyqtSignal(object)
|
||||||
notes_resource_scheme = '' # set to scheme to use to load resources for notes from the current db
|
notes_resource_scheme = '' # set to scheme to use to load resources for notes from the current db
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None, save_resources_in_document=True):
|
||||||
QTextBrowser.__init__(self, parent)
|
QTextBrowser.__init__(self, parent)
|
||||||
|
self.save_resources_in_document = save_resources_in_document
|
||||||
self.last_set_html = ''
|
self.last_set_html = ''
|
||||||
self.default_css = self.external_css = ''
|
self.default_css = self.external_css = ''
|
||||||
app = QApplication.instance()
|
app = QApplication.instance()
|
||||||
@ -586,11 +587,13 @@ class HTMLDisplay(QTextBrowser):
|
|||||||
'890000000a49444154789c6300010000'
|
'890000000a49444154789c6300010000'
|
||||||
'0500010d0a2db40000000049454e44ae'
|
'0500010d0a2db40000000049454e44ae'
|
||||||
'426082'))
|
'426082'))
|
||||||
self.document().addResource(rtype, qurl, r)
|
if self.save_resources_in_document:
|
||||||
|
self.document().addResource(rtype, qurl, r)
|
||||||
return r
|
return r
|
||||||
else:
|
else:
|
||||||
r = QByteArray(data)
|
r = QByteArray(data)
|
||||||
self.document().addResource(rtype, qurl, r)
|
if self.save_resources_in_document:
|
||||||
|
self.document().addResource(rtype, qurl, r)
|
||||||
return r
|
return r
|
||||||
elif qurl.scheme() == 'calibre-icon':
|
elif qurl.scheme() == 'calibre-icon':
|
||||||
r = QIcon.icon_as_png(qurl.path().lstrip('/'), as_bytearray=True)
|
r = QIcon.icon_as_png(qurl.path().lstrip('/'), as_bytearray=True)
|
||||||
@ -604,7 +607,8 @@ class HTMLDisplay(QTextBrowser):
|
|||||||
resource = db.get_notes_resource(f'{qurl.host()}:{qurl.path()[1:]}')
|
resource = db.get_notes_resource(f'{qurl.host()}:{qurl.path()[1:]}')
|
||||||
if resource is not None:
|
if resource is not None:
|
||||||
r = QByteArray(resource['data'])
|
r = QByteArray(resource['data'])
|
||||||
self.document().addResource(rtype, qurl, r)
|
if self.save_resources_in_document:
|
||||||
|
self.document().addResource(rtype, qurl, r)
|
||||||
return r
|
return r
|
||||||
else:
|
else:
|
||||||
return QTextBrowser.loadResource(self, rtype, qurl)
|
return QTextBrowser.loadResource(self, rtype, qurl)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user