From 0b0f6e6b9dccf81f293ba75b25814e13c4650a76 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 24 Jul 2016 09:42:28 +0530 Subject: [PATCH] Make heading-on-side for comments columns configurable --- src/calibre/ebooks/metadata/book/render.py | 10 ++++++++-- src/calibre/gui2/preferences/create_custom_column.py | 12 ++++++++++-- src/pyj/book_list/book_details.pyj | 4 ++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/calibre/ebooks/metadata/book/render.py b/src/calibre/ebooks/metadata/book/render.py index e0750a301a..6a8d3e6da5 100644 --- a/src/calibre/ebooks/metadata/book/render.py +++ b/src/calibre/ebooks/metadata/book/render.py @@ -98,9 +98,15 @@ def mi_to_html(mi, field_list=None, default_author_link=None, use_roman_numbers= val = markdown(val) else: val = comments_to_html(val) + add_comment = True if disp.get('show_heading'): - val = '

%s

%s' % (p(name), val) - comment_fields.append('
%s
' % (field.replace('#', '_'), val)) + if disp.get('heading_on_side'): + ans.append((field, row % (name, val))) + add_comment = False + else: + val = '

%s

%s' % (p(name), val) + if add_comment: + comment_fields.append('
%s
' % (field.replace('#', '_'), val)) elif metadata['datatype'] == 'rating': val = getattr(mi, field) if val: diff --git a/src/calibre/gui2/preferences/create_custom_column.py b/src/calibre/gui2/preferences/create_custom_column.py index e3ade463a5..e62a0f5684 100644 --- a/src/calibre/gui2/preferences/create_custom_column.py +++ b/src/calibre/gui2/preferences/create_custom_column.py @@ -165,6 +165,7 @@ class CreateCustomColumn(QDialog): self.format_box.setText(c['display'].get('number_format', '')) elif ct == 'comments': self.show_comments_heading.setChecked(c['display'].get('show_heading', False)) + self.comments_heading_on_side.setChecked(c['display'].get('heading_on_side', False)) idx = max(0, self.comments_type.findData(c['display'].get('interpret_as', 'html'))) self.comments_type.setCurrentIndex(idx) self.datatype_changed() @@ -207,6 +208,7 @@ class CreateCustomColumn(QDialog): self.composite_sort_by.setCurrentIndex(0) if which == 'text': self.show_comments_heading.setChecked(True) + self.comments_heading_on_side.setChecked(True) self.comments_type.setCurrentIndex(self.comments_type.findData('short-text')) # }}} @@ -307,9 +309,13 @@ class CreateCustomColumn(QDialog): self.composite_label = add_row(_("&Template"), h) # Comments properties - self.show_comments_heading = sch = QCheckBox(_('Show heading in book details panel')) + self.show_comments_heading = sch = QCheckBox(_('Show heading in the Book Details panel')) sch.setToolTip(_( - 'Choose whether to show the heading for this column in the Book Details Panel')) + 'Choose whether to show the heading for this column in the Book Details panel')) + add_row(None, sch) + self.comments_heading_on_side = sch = QCheckBox(_('Show column heading to the side of the text')) + sch.setToolTip(_( + 'Choose whether to show the heading above or to the side of the text in the Book Details panel')) add_row(None, sch) self.comments_type = ct = QComboBox(self) for k, text in ( @@ -418,6 +424,7 @@ class CreateCustomColumn(QDialog): self.show_comments_heading.setVisible(is_comments) self.comments_type.setVisible(is_comments) self.comments_type_label.setVisible(is_comments) + self.comments_heading_on_side.setVisible(is_comments) def accept(self): col = unicode(self.column_name_box.text()).strip() @@ -515,6 +522,7 @@ class CreateCustomColumn(QDialog): elif col_type == 'comments': display_dict['show_heading'] = bool(self.show_comments_heading.isChecked()) display_dict['interpret_as'] = type(u'')(self.comments_type.currentData()) + display_dict['heading_on_side'] = bool(self.comments_heading_on_side.isChecked()) if col_type in ['text', 'composite', 'enumeration'] and not is_multiple: display_dict['use_decorations'] = self.use_decorations.checkState() diff --git a/src/pyj/book_list/book_details.pyj b/src/pyj/book_list/book_details.pyj index cc8225e833..b987131d66 100644 --- a/src/pyj/book_list/book_details.pyj +++ b/src/pyj/book_list/book_details.pyj @@ -201,8 +201,8 @@ def render_metadata(mi, interface_data, table, field_list=None): datatype = fm.datatype val = mi[field] if field is 'comments' or datatype is 'comments': - if fm.display?.interpret_as is 'short-text': - add_row(name, val) + if fm.display?.heading_on_side: + add_row(name, val, is_html=fm.display?.interpret_as is not 'short-text') else: comments[field] = val return