From 4cfa6fdf1f7c720069cff4d6f3534a526b3d71e9 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Mon, 5 Jan 2015 17:25:26 +0100 Subject: [PATCH] Make case differences between author and author sort show red, while preserving the behavior of automatically correcting the case if the author changes. --- src/calibre/gui2/metadata/basic_widgets.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/metadata/basic_widgets.py b/src/calibre/gui2/metadata/basic_widgets.py index 2e8c5c0a12..7fb51a1715 100644 --- a/src/calibre/gui2/metadata/basic_widgets.py +++ b/src/calibre/gui2/metadata/basic_widgets.py @@ -461,6 +461,7 @@ class AuthorSortEdit(EnLineEdit, ToMetadataMixin): a_to_as.triggered.connect(self.author_to_sort) as_to_a.triggered.connect(self.sort_to_author) self.original_val = '' + self.first_time = True self.update_state() @dynamic_property @@ -480,8 +481,9 @@ class AuthorSortEdit(EnLineEdit, ToMetadataMixin): def update_state_and_val(self): # Handle case change if the authors box changed aus = authors_to_sort_string(self.authors_edit.current_val) - if strcmp(aus, self.current_val) == 0: + if not self.first_time and strcmp(aus, self.current_val) == 0: self.current_val = aus + self.first_time = False self.update_state() def update_state(self, *args): @@ -489,7 +491,7 @@ class AuthorSortEdit(EnLineEdit, ToMetadataMixin): au = re.sub(r'\s+et al\.$', '', au) au = self.db.author_sort_from_authors(string_to_authors(au)) - normal = strcmp(au, self.current_val) == 0 + normal = au == self.current_val col = OK_COLOR if normal else ERR_COLOR self.setStyleSheet(INDICATOR_SHEET % col) tt = self.tooltips[0 if normal else 1] @@ -536,6 +538,7 @@ class AuthorSortEdit(EnLineEdit, ToMetadataMixin): aus = self.current_val if aus != self.original_val or self.authors_edit.original_val != self.authors_edit.current_val: db.set_author_sort(id_, aus, notify=False, commit=False) + self.first_time = True return True def break_cycles(self):