mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix a regression in the previous release that caused comments in the Book details panel to be rendered below rather than at the side of the other information
This commit is contained in:
parent
becdf4ef9f
commit
cb4fc7905b
@ -287,6 +287,17 @@ def render_html(mi, vertical, widget, all_fields=False, render_data_func=None,
|
||||
ans = str(col.name())
|
||||
return ans
|
||||
|
||||
comments = ''
|
||||
if comment_fields:
|
||||
comments = '\n'.join('<div>%s</div>' % x for x in comment_fields)
|
||||
# Comments cause issues with rendering in QTextBrowser
|
||||
comments = comments_pat().sub('', comments)
|
||||
|
||||
html = render_parts(table, comments, vertical)
|
||||
return html, table, comments
|
||||
|
||||
|
||||
def render_parts(table, comments, vertical):
|
||||
templ = '''\
|
||||
<html>
|
||||
<head></head>
|
||||
@ -295,11 +306,6 @@ def render_html(mi, vertical, widget, all_fields=False, render_data_func=None,
|
||||
</body>
|
||||
<html>
|
||||
'''%('vertical' if vertical else 'horizontal')
|
||||
comments = ''
|
||||
if comment_fields:
|
||||
comments = '\n'.join('<div>%s</div>' % x for x in comment_fields)
|
||||
# Comments cause issues with rendering in QTextBrowser
|
||||
comments = comments_pat().sub('', comments)
|
||||
right_pane = comments
|
||||
|
||||
if vertical:
|
||||
@ -712,7 +718,7 @@ class CoverView(QWidget): # {{{
|
||||
def __init__(self, vertical, parent=None):
|
||||
QWidget.__init__(self, parent)
|
||||
self._current_pixmap_size = QSize(120, 120)
|
||||
self.vertical = vertical
|
||||
self.change_layout(vertical)
|
||||
|
||||
self.animation = QPropertyAnimation(self, b'current_pixmap_size', self)
|
||||
self.animation.setEasingCurve(QEasingCurve(QEasingCurve.Type.OutExpo))
|
||||
@ -720,9 +726,6 @@ class CoverView(QWidget): # {{{
|
||||
self.animation.setStartValue(QSize(0, 0))
|
||||
self.animation.valueChanged.connect(self.value_changed)
|
||||
|
||||
self.setSizePolicy(
|
||||
QSizePolicy.Policy.Expanding if vertical else QSizePolicy.Policy.Minimum,
|
||||
QSizePolicy.Policy.Expanding)
|
||||
|
||||
self.default_pixmap = QApplication.instance().cached_qpixmap('default_cover.png', device_pixel_ratio=self.devicePixelRatio())
|
||||
self.pixmap = self.default_pixmap
|
||||
@ -732,6 +735,12 @@ class CoverView(QWidget): # {{{
|
||||
|
||||
self.do_layout()
|
||||
|
||||
def change_layout(self, vertical):
|
||||
self.vertical = vertical
|
||||
self.setSizePolicy(
|
||||
QSizePolicy.Policy.Expanding if vertical else QSizePolicy.Policy.Minimum,
|
||||
QSizePolicy.Policy.Expanding)
|
||||
|
||||
def value_changed(self, val):
|
||||
self.update()
|
||||
|
||||
@ -988,6 +997,7 @@ class BookInfo(HTMLDisplay):
|
||||
def __init__(self, vertical, parent=None):
|
||||
HTMLDisplay.__init__(self, parent=parent, save_resources_in_document=False)
|
||||
self.vertical = vertical
|
||||
self.last_rendered_html = '', '', ''
|
||||
self.anchor_clicked.connect(self.link_activated)
|
||||
for x, icon in [
|
||||
('remove_format', 'trash.png'), ('save_format', 'save.png'),
|
||||
@ -1015,6 +1025,14 @@ class BookInfo(HTMLDisplay):
|
||||
self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
|
||||
self.setDefaultStyleSheet(css())
|
||||
|
||||
def change_layout(self, vertical):
|
||||
if vertical != self.vertical:
|
||||
self.vertical = vertical
|
||||
if self.last_rendered_html[0]:
|
||||
html = render_parts(self.last_rendered_html[1], self.last_rendered_html[2], self.vertical)
|
||||
self.last_rendered_html = html, self.last_rendered_html[1], self.last_rendered_html[2]
|
||||
self.setHtml(html)
|
||||
|
||||
def refresh_css(self):
|
||||
self.setDefaultStyleSheet(css(True))
|
||||
|
||||
@ -1069,7 +1087,7 @@ class BookInfo(HTMLDisplay):
|
||||
self.link_clicked.emit(link)
|
||||
|
||||
def show_data(self, mi):
|
||||
html = render_html(mi, self.vertical, self.parent())
|
||||
html, table, comments = self.last_rendered_html = render_html(mi, self.vertical, self.parent())
|
||||
set_html(mi, html, self)
|
||||
|
||||
def process_external_css(self, css):
|
||||
@ -1319,6 +1337,14 @@ class BookDetails(DetailsLayout): # {{{
|
||||
self.book_info.edit_identifiers.connect(self.edit_identifiers)
|
||||
self.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
|
||||
def change_layout(self, vertical):
|
||||
if vertical != self.vertical:
|
||||
self.vertical = vertical
|
||||
self.cover_view.change_layout(vertical)
|
||||
self.book_info.change_layout(vertical)
|
||||
self.setOrientation(Qt.Orientation.Vertical if self.vertical else Qt.Orientation.Horizontal)
|
||||
self.do_layout(self.rect())
|
||||
|
||||
def search_internet(self, data):
|
||||
if self.last_data:
|
||||
if data.author is None:
|
||||
|
@ -399,7 +399,7 @@ class CentralContainer(QWidget):
|
||||
ss = self.serialized_settings()
|
||||
before = ss[self.layout.name + '_visibility']
|
||||
after = ss[layout.name + '_visibility']
|
||||
gui.book_details.vertical = is_wide
|
||||
gui.book_details.change_layout(is_wide)
|
||||
self.layout = layout
|
||||
self.write_settings()
|
||||
# apply visibility changes by clicking buttons to ensure button
|
||||
|
@ -419,7 +419,7 @@ class BookInfo(QDialog):
|
||||
self.cover_pixmap.setDevicePixelRatio(dpr)
|
||||
self.marked = mi.marked
|
||||
self.resize_cover()
|
||||
html = render_html(mi, True, self, pref_name='popup_book_display_fields')
|
||||
html = render_html(mi, True, self, pref_name='popup_book_display_fields')[0]
|
||||
set_html(mi, html, self.details)
|
||||
self.update_cover_tooltip()
|
||||
|
||||
|
@ -733,7 +733,7 @@ class LayoutMixin: # {{{
|
||||
def read_layout_settings(self):
|
||||
# View states are restored automatically when set_database is called
|
||||
self.layout_container.read_settings()
|
||||
self.book_details.vertical = self.layout_container.is_wide
|
||||
self.book_details.change_layout(self.layout_container.is_wide)
|
||||
self.place_layout_buttons()
|
||||
self.grid_view_button.restore_state()
|
||||
self.search_bar_button.restore_state()
|
||||
|
Loading…
x
Reference in New Issue
Block a user