From a16e8e8ee1f0378b31ed258a5b44128dd751da2e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 23 Feb 2026 06:46:03 +0530 Subject: [PATCH] Fix Copilot's mistakes --- src/calibre/gui2/library/alternate_views.py | 13 +- .../preferences/look_feel_tabs/cover_grid.py | 4 +- .../preferences/look_feel_tabs/cover_grid.ui | 607 +++++++++--------- 3 files changed, 312 insertions(+), 312 deletions(-) diff --git a/src/calibre/gui2/library/alternate_views.py b/src/calibre/gui2/library/alternate_views.py index cbb21e79fa..a677417dcb 100644 --- a/src/calibre/gui2/library/alternate_views.py +++ b/src/calibre/gui2/library/alternate_views.py @@ -763,7 +763,7 @@ class CoverDelegate(QStyledItemDelegate): if self.title_height != 0: if self.flush_bottom: trect.setTop(rect.bottom() + 5) - self.paint_title(painter, trect, db, book_id) + self.paint_title(painter, trect, db, book_id, align_top=self.flush_bottom) if self.emblem_size > 0: # We don't draw embossed emblems as the ondevice/marked emblems are drawn in the gutter return @@ -787,15 +787,20 @@ class CoverDelegate(QStyledItemDelegate): with clip_border_radius(painter, rect): painter.drawPixmap(rect, pixmap) - def paint_title(self, painter, rect, db, book_id): + def paint_title(self, painter, rect, db, book_id, align_top: bool = False): painter.setRenderHint(QPainter.RenderHint.TextAntialiasing, True) title, is_stars = self.render_field(db, book_id) if is_stars: painter.setFont(self.rating_font) metrics = painter.fontMetrics() painter.setPen(self.highlight_color) - painter.drawText(rect, Qt.AlignmentFlag.AlignCenter|Qt.TextFlag.TextSingleLine, - metrics.elidedText(title, Qt.TextElideMode.ElideRight, rect.width())) + text = metrics.elidedText(title, Qt.TextElideMode.ElideRight, rect.width()) + align = Qt.TextFlag.TextSingleLine + if align_top: + align |= Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignHCenter + else: + align |= Qt.AlignmentFlag.AlignCenter + painter.drawText(rect, align, text) def paint_emblems(self, painter, rect, emblems): gutter = self.emblem_size + self.MARGIN diff --git a/src/calibre/gui2/preferences/look_feel_tabs/cover_grid.py b/src/calibre/gui2/preferences/look_feel_tabs/cover_grid.py index 8fcc50effe..58c535a1cc 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/cover_grid.py +++ b/src/calibre/gui2/preferences/look_feel_tabs/cover_grid.py @@ -11,12 +11,12 @@ from calibre.gui2 import gprefs from calibre.gui2.library.alternate_views import CM_TO_INCH, auto_height from calibre.gui2.preferences import LazyConfigWidgetBase from calibre.gui2.preferences.look_feel_tabs import RulesSetting -from calibre.gui2.preferences.look_feel_tabs.cover_grid_ui import Ui_Form +from calibre.gui2.preferences.look_feel_tabs.cover_grid_ui import Ui_cover_grid_tab from calibre.startup import connect_lambda from calibre.utils.icu import sort_key -class CoverGridTab(QTabWidget, LazyConfigWidgetBase, Ui_Form): +class CoverGridTab(QTabWidget, LazyConfigWidgetBase, Ui_cover_grid_tab): changed_signal = pyqtSignal() restart_now = pyqtSignal() diff --git a/src/calibre/gui2/preferences/look_feel_tabs/cover_grid.ui b/src/calibre/gui2/preferences/look_feel_tabs/cover_grid.ui index 150718aa40..ac02724368 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/cover_grid.ui +++ b/src/calibre/gui2/preferences/look_feel_tabs/cover_grid.ui @@ -1,293 +1,304 @@ - Form - - - 0 - - - - &Layout - - - - QFormLayout::ExpandingFieldsGrow - - - - - Control the Cover grid view. You can enable this view by clicking the "Layout" button in the bottom right corner of the main calibre window. - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - Field to show &under the covers: - - - opt_field_under_covers_in_grid - - - - - - - - - - Draw field text flush with the &bottom of the rendered cover - - - - - - - Spac&ing between covers: - - - opt_cover_grid_spacing - - - - - - - The spacing between covers. A value of zero means calculate automatically based on cover size. - - - Automatic - - - cm - - - 2 - - - 0.100000000000000 - - - - - - - Background for the Cover grid - - - - - - - Cover size - - - - - - Make the covers larger, maintaining current aspect ratio. - - - &Larger covers - - - - :/images/plus.png:/images/plus.png - - - - - - - Make the covers smaller, maintaining current aspect ratio. - - - &Smaller covers - - - - :/images/minus.png:/images/minus.png - - - - - - - Cover &height: - - - opt_cover_grid_height - - - - - - - Cover &width: - - - opt_cover_grid_width - - - - - - - The height of displayed covers. + cover_grid_tab + + + + 0 + 0 + 458 + 483 + + + + 0 + + + + &Layout + + + + QFormLayout::ExpandingFieldsGrow + + + + + Control the Cover grid view. You can enable this view by clicking the "Layout" button in the bottom right corner of the main calibre window. + + + true + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Show a &field (such as title) under the covers + + + + + + + Field to show &under the covers: + + + opt_field_under_covers_in_grid + + + + + + + + + + Spac&ing between covers: + + + opt_cover_grid_spacing + + + + + + + The spacing between covers. A value of zero means calculate automatically based on cover size. + + + Automatic + + + cm + + + 2 + + + 0.100000000000000 + + + + + + + Background for the Cover grid + + + + + + + Cover size + + + + + + Make the covers larger, maintaining current aspect ratio. + + + &Larger covers + + + + :/images/plus.png:/images/plus.png + + + + + + + Make the covers smaller, maintaining current aspect ratio. + + + &Smaller covers + + + + :/images/minus.png:/images/minus.png + + + + + + + Cover &height: + + + opt_cover_grid_height + + + + + + + Cover &width: + + + opt_cover_grid_width + + + + + + + The height of displayed covers. A value of zero means calculate automatically. - - - Automatic - - - cm - - - 1 - - - - - - - Reset size to automatic - - - &Reset size - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - The width of displayed covers. + + + Automatic + + + cm + + + 1 + + + + + + + Reset size to automatic + + + &Reset size + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + The width of displayed covers. A value of zero means calculate automatically. - - - Automatic - - - cm - - - 1 - - - - - - - - 0 - 0 - - - - By default, calibre chooses a cover size based on your computer's screen size. You can change the cover size here: - - - true - - - - - - - - - - px - - - 16 - - - 1000 - - - - - - - Size of the emblems (if any) shown &next to the covers: - - - opt_emblem_size - - - - - - - Show a &field (such as title) under the covers - - - - - - - &Location of the emblems shown next to the covers: - - - opt_emblem_position - - - - - - - - - - - &Emblems - - - - - &Performance - - + + + Automatic + + + cm + + + 1 + + + + + + + + 0 + 0 + + + + By default, calibre chooses a cover size based on your computer's screen size. You can change the cover size here: + + + true + + + + + + + + + + Size of the emblems (if any) shown &next to the covers: + + + opt_emblem_size + + + + + + + px + + + 16 + + + 1000 + + + + + + + &Location of the emblems shown next to the covers: + + + opt_emblem_position + + + + + + + + + + <p>By default, the text is drawn at the bottom of the cell, leaving a gap between text and cover when the cover is small or has a wide aspect ratio. This option instead causes the text to be drawn flush witht he bottom of the cover. + + + Draw text flush with the &bottom of the rendered cover + + + + + + + &Emblems + + + + + &Performance + + + ConfigWidgetBase @@ -311,7 +322,7 @@ A value of zero means calculate automatically. - + @@ -321,28 +332,12 @@ A value of zero means calculate automatically. setEnabled(bool) - 86 - 49 + 88 + 128 - 101 - 51 - - - - - opt_cover_grid_show_title - toggled(bool) - opt_cover_grid_text_flush_bottom - setEnabled(bool) - - - 86 - 49 - - - 101 - 75 + 376 + 159