This commit is contained in:
Kovid Goyal 2024-03-17 17:00:10 +05:30
commit 52a8da38ac
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 24 additions and 9 deletions

View File

@ -874,6 +874,11 @@ def get_field_list(db, use_defaults=False, pref_data_override=None):
return [(k,v) for k,v in result.items()]
def get_custom_columns_to_display_in_editor(db):
return list([k[0] for k in
get_field_list(db, use_defaults=db.prefs['edit_metadata_ignore_display_order']) if k[1]])
def populate_metadata_page(layout, db, book_id, bulk=False, two_column=False, parent=None):
def widget_factory(typ, key):
if bulk:
@ -886,7 +891,7 @@ def populate_metadata_page(layout, db, book_id, bulk=False, two_column=False, pa
fm = db.field_metadata
# Get list of all non-composite custom fields. We must make widgets for these
cols = [k[0] for k in get_field_list(db, use_defaults=db.prefs['edit_metadata_ignore_display_order']) if k[1]]
cols = get_custom_columns_to_display_in_editor(db)
# This deals with the historical behavior where comments fields go to the
# bottom, starting on the left hand side. If a comment field is moved to
# somewhere else then it isn't moved to either side.

View File

@ -972,6 +972,7 @@ class GridView(QListView):
cache_valid = None
else:
# A cover is in the cache. Check whether it is up to date.
# Note that if tcdata is not None then it is already a PIL image.
has_cover, tcdata, timestamp = db.new_api.cover_or_cache(book_id, timestamp,
as_what='pil_image')
if has_cover:
@ -1012,12 +1013,6 @@ class GridView(QListView):
if cover_tuple.has_cover:
# cdata contains either the resized thumbnail, the full cover.jpg
# rendered as a PIL image, or None if cover.jpg isn't valid
if cdata.getbbox() is None and cover_tuple.cache_valid:
# Something wrong with the cover data in the cache. Remove it
# from the cache and queue it to render again.
tc.invalidate((book_id,))
self.render_queue.put(book_id)
return None
if not cover_tuple.cache_valid:
# The cover isn't in the cache, is stale, or isn't a valid
# image. We might have the image from cover.jpg, in which case
@ -1052,6 +1047,20 @@ class GridView(QListView):
# The cover data isn't valid. Remove it from the cache
tc.invalidate((book_id,))
else:
# Test to see if there is something wrong with the cover data in
# the cache. If so, remove it from the cache and queue it to
# render again. It isn't clear that this can ever happen. One
# possibility is if different versions of calibre are used
# interchangeably.
def getbbox(img):
try:
return img.getbbox()
except Exception:
return None
if getbbox(cdata) is None:
tc.invalidate((book_id,))
self.render_queue.put(book_id)
return None
# The data from the cover cache is valid and is already a thumb.
thumb = cdata
else:

View File

@ -19,7 +19,8 @@ from calibre.constants import ismacos
from calibre.ebooks.metadata import authors_to_string, string_to_authors
from calibre.ebooks.metadata.book.base import Metadata
from calibre.gui2 import error_dialog, gprefs, pixmap_to_data
from calibre.gui2.custom_column_widgets import Comments, populate_metadata_page
from calibre.gui2.custom_column_widgets import (
Comments, populate_metadata_page, get_custom_columns_to_display_in_editor)
from calibre.gui2.dialogs.confirm_delete import confirm
from calibre.gui2.metadata.basic_widgets import (
AuthorsEdit, AuthorSortEdit, BuddyLabel, CommentsEdit, Cover, DateEdit,
@ -121,7 +122,7 @@ class MetadataSingleDialogBase(QDialog):
self.create_basic_metadata_widgets()
if len(self.db.custom_column_label_map):
if len(get_custom_columns_to_display_in_editor(self.db)):
self.create_custom_metadata_widgets()
self.comments_edit_state_at_apply = {self.comments:None}