Use a scale factor for link & note icons instead of an absolute size.

This commit is contained in:
Charles Haley 2025-01-10 12:51:42 +00:00
parent 136f188981
commit 7f9cbb5302
3 changed files with 18 additions and 10 deletions

View File

@ -485,7 +485,7 @@ def create_defs():
defs['dark_palettes'] = {}
defs['light_palettes'] = {}
defs['saved_layouts'] = {}
defs['book_details_note_link_icon_width'] = 16
defs['book_details_note_link_icon_width'] = 1.0
def migrate_tweak(tweak_name, pref_name):
# If the tweak has been changed then leave the tweak in the file so

View File

@ -15,6 +15,7 @@ from qt.core import (
QColor,
QDialog,
QEasingCurve,
QFontMetrics,
QIcon,
QKeySequence,
QMenu,
@ -394,12 +395,15 @@ def render_data(mi, use_roman_numbers=True, all_fields=False, pref_name='book_di
if db.notes_for(field, item_id):
return item_id
# Compute the size of the link and note icons by scaling the current font
# height by the option specified in Preferences / L&F / Book details.
icon_size = int(QFontMetrics(QApplication.font()).height() * gprefs['book_details_note_link_icon_width'])
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, item_id_if_has_note=item_id_if_has_note,
link_note_icon_size=gprefs['book_details_note_link_icon_width']
link_note_icon_size=icon_size
)
# }}}

View File

@ -1003,18 +1003,22 @@ A value of zero means calculate automatically.</string>
</widget>
</item>
<item>
<widget class="QSpinBox" name="opt_book_details_note_link_icon_width">
<widget class="QDoubleSpinBox" name="opt_book_details_note_link_icon_width">
<property name="toolTip">
<string>Specify the size (width and height) of the links and notes icons</string>
<string>Increase or decrease the size of the links and notes icons by this number. Larger
than one increases the icon size while smaller than one decreases it.</string>
</property>
<property name="suffix">
<string> pixels</string>
</property>
<property name="maximum">
<number>48</number>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<number>12</number>
<double>0.5</double>
</property>
<property name="maximum">
<double>4.0</double>
</property>
<property name="singleStep">
<double>0.1</double>
</property>
</widget>
</item>