From 136f1889818226eef776152930172a9f82660d7e Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Fri, 10 Jan 2025 10:26:15 +0000 Subject: [PATCH 1/2] Add an option to adjust the size of the link and note icons in book details. In the tag browser and booklist the icons resize automatically with the font. That doesn't happen in book details because there isn't any notion of a "row". With this option the user can make the size as desired. For more background see the first few posts of https://www.mobileread.com/forums/showthread.php?t=365537 --- src/calibre/ebooks/metadata/book/render.py | 8 ++-- src/calibre/gui2/__init__.py | 1 + src/calibre/gui2/book_details.py | 3 +- src/calibre/gui2/preferences/look_feel.py | 1 + src/calibre/gui2/preferences/look_feel.ui | 54 +++++++++++++++++++++- 5 files changed, 62 insertions(+), 5 deletions(-) diff --git a/src/calibre/ebooks/metadata/book/render.py b/src/calibre/ebooks/metadata/book/render.py index e973b3aeb9..4418213291 100644 --- a/src/calibre/ebooks/metadata/book/render.py +++ b/src/calibre/ebooks/metadata/book/render.py @@ -107,13 +107,15 @@ 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, item_id_if_has_note=None + for_qt=False, vertical_fields=(), show_links=True, item_id_if_has_note=None, + link_note_icon_size=16 ): link_markup = '↗️' if for_qt: - link_markup = '' - note_markup = '' + s = link_note_icon_size + link_markup = f'' + note_markup = f'' def get_link_map(column): try: return mi.link_maps[column] diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index c8793f9df6..6c73246e7f 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -485,6 +485,7 @@ def create_defs(): defs['dark_palettes'] = {} defs['light_palettes'] = {} defs['saved_layouts'] = {} + defs['book_details_note_link_icon_width'] = 16 def migrate_tweak(tweak_name, pref_name): # If the tweak has been changed then leave the tweak in the file so diff --git a/src/calibre/gui2/book_details.py b/src/calibre/gui2/book_details.py index b7b0e7caeb..fb66453598 100644 --- a/src/calibre/gui2/book_details.py +++ b/src/calibre/gui2/book_details.py @@ -398,7 +398,8 @@ def render_data(mi, use_roman_numbers=True, all_fields=False, pref_name='book_di 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 + 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'] ) # }}} diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index 6568558df3..39f61db12e 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -678,6 +678,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): r('booklist_grid', gprefs) r('book_details_comments_heading_pos', gprefs, choices=[ (_('Never'), 'hide'), (_('Above text'), 'above'), (_('Beside text'), 'side')]) + r('book_details_note_link_icon_width', gprefs) self.cover_browser_title_template_button.clicked.connect(self.edit_cb_title_template) self.id_links_button.clicked.connect(self.edit_id_link_rules) diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index 75173697f5..48138780cf 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -957,7 +957,7 @@ A value of zero means calculate automatically. - + @@ -979,6 +979,58 @@ A value of zero means calculate automatically. + + + + Qt::Horizontal + + + + 10 + 0 + + + + + + + + Link and note icon si&ze: + + + opt_book_details_note_link_icon_width + + + + + + + Specify the size (width and height) of the links and notes icons + + + pixels + + + 48 + + + 12 + + + + + + + Qt::Horizontal + + + + 30 + 0 + + + + From 7f9cbb53025c92b73c840bd99c61318a90886465 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Fri, 10 Jan 2025 12:51:42 +0000 Subject: [PATCH 2/2] Use a scale factor for link & note icons instead of an absolute size. --- src/calibre/gui2/__init__.py | 2 +- src/calibre/gui2/book_details.py | 6 +++++- src/calibre/gui2/preferences/look_feel.ui | 20 ++++++++++++-------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 6c73246e7f..fc337dbf56 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -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 diff --git a/src/calibre/gui2/book_details.py b/src/calibre/gui2/book_details.py index fb66453598..b734967088 100644 --- a/src/calibre/gui2/book_details.py +++ b/src/calibre/gui2/book_details.py @@ -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 ) # }}} diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index 48138780cf..a792021fe7 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -1003,18 +1003,22 @@ A value of zero means calculate automatically. - + - Specify the size (width and height) of the links and notes icons + 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. - - pixels - - - 48 + + 1 - 12 + 0.5 + + + 4.0 + + + 0.1