Book details panel: De-emphasize titles making the actual data stand out more. Fixes #2029723 [[Enhancement] Suggestions to make the Book details panel look nicer](https://bugs.launchpad.net/calibre/+bug/2029723)

This commit is contained in:
Kovid Goyal 2023-08-16 20:07:46 +05:30
parent f1537ba35e
commit 7c7ff4cf08
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 15 additions and 6 deletions

View File

@ -93,7 +93,7 @@ def mi_to_html(
mi,
field_list=None, default_author_link=None, use_roman_numbers=True,
rating_font='Liberation Serif', rtl=False, comments_heading_pos='hide',
for_qt=False, vertical_fields=(), show_links=True,
for_qt=False, vertical_fields=(), show_links=True, gray='#7f7f7f',
):
link_markup = '↗️'
@ -147,7 +147,8 @@ def mi_to_html(
name = metadata['name']
if not name:
name = field
name += ':'
sep = '\xa0'
name += sep
disp = metadata['display']
if (metadata['datatype'] == 'comments' or field == 'comments'
or disp.get('composite_show_in_comments', '')):
@ -224,7 +225,7 @@ def mi_to_html(
num_of_folders = 2
break
text = _('Book files')
name = ngettext('Folder:', 'Folders:', num_of_folders)
name = ngettext('Folder', 'Folders', num_of_folders) + sep
links = ['<a href="{}" title="{}">{}</a>{}'.format(action(scheme, book_id=book_id, loc=loc),
prepare_string_for_xml(path, True), text, extra)]
if num_of_folders > 1:
@ -425,7 +426,11 @@ def mi_to_html(
classname(fieldl), html) for fieldl, html in ans]
# print '\n'.join(ans)
direction = 'rtl' if rtl else 'ltr'
rans = '<style>table.fields td { vertical-align:top}</style><table class="fields" style="direction: %s; ' % direction
rans = (
'<style>table.fields td { vertical-align:top} table.fields td.title {'
f'text-align: right; color: {gray}; font-style: italic; font-weight: normal '
'}</style>'
'<table class="fields" style="direction: %s; ' % direction)
if not for_qt:
# This causes wasted space at the edge of the table in Qt's rich text
# engine, see https://bugs.launchpad.net/calibre/+bug/1881488

View File

@ -8,7 +8,7 @@ from collections import namedtuple
from contextlib import suppress
from functools import lru_cache, partial
from qt.core import (
QAction, QApplication, QClipboard, QColor, QDialog, QEasingCurve, QIcon,
QAction, QApplication, QClipboard, QColor, QDialog, QEasingCurve, QIcon, QPalette,
QKeySequence, QMenu, QMimeData, QPainter, QPen, QPixmap, QPropertyAnimation, QRect,
QSize, QSizePolicy, QSplitter, Qt, QTimer, QUrl, QWidget, pyqtProperty, pyqtSignal,
)
@ -292,11 +292,15 @@ def render_data(mi, use_roman_numbers=True, all_fields=False, pref_name='book_di
field_list = get_field_list(getattr(mi, 'field_metadata', field_metadata),
pref_name=pref_name, mi=mi)
field_list = [(x, all_fields or display) for x, display in field_list]
gray = '#888'
app = QApplication.instance()
if app is not None and app.is_dark_theme:
gray = app.palette().color(QPalette.ColorRole.PlaceholderText).name()
return mi_to_html(
mi, field_list=field_list, use_roman_numbers=use_roman_numbers, rtl=is_rtl(),
rating_font=rating_font(), default_author_link=default_author_link(),
comments_heading_pos=gprefs['book_details_comments_heading_pos'], for_qt=True,
vertical_fields=vertical_fields, show_links=show_links
vertical_fields=vertical_fields, show_links=show_links, gray=gray
)
# }}}