diff --git a/src/calibre/gui2/metadata/basic_widgets.py b/src/calibre/gui2/metadata/basic_widgets.py index bded17d40f..7d48468fd6 100644 --- a/src/calibre/gui2/metadata/basic_widgets.py +++ b/src/calibre/gui2/metadata/basic_widgets.py @@ -38,6 +38,9 @@ from calibre.ptempfile import PersistentTemporaryFile, SpooledTemporaryFile from calibre.gui2.languages import LanguagesEdit as LE from calibre.db import SPOOL_SIZE +OK_COLOR = 'rgba(0, 255, 0, 15%)' +ERR_COLOR = 'rgba(255, 0, 0, 15%)' + def save_dialog(parent, title, msg, det_msg=''): d = QMessageBox(parent) d.setWindowTitle(title) @@ -177,10 +180,7 @@ class TitleSortEdit(TitleEdit): def update_state(self, *args): ts = title_sort(self.title_edit.current_val, lang=self.book_lang) normal = ts == self.current_val - if normal: - col = 'rgb(0, 255, 0, 20%)' - else: - col = 'rgb(255, 0, 0, 20%)' + col = OK_COLOR if normal else ERR_COLOR self.setStyleSheet('QLineEdit { color: black; ' 'background-color: %s; }'%col) tt = self.tooltips[0 if normal else 1] @@ -381,10 +381,7 @@ class AuthorSortEdit(EnLineEdit): au = self.db.author_sort_from_authors(string_to_authors(au)) normal = strcmp(au, self.current_val) == 0 - if normal: - col = 'rgb(0, 255, 0, 20%)' - else: - col = 'rgb(255, 0, 0, 20%)' + col = OK_COLOR if normal else ERR_COLOR self.setStyleSheet('QLineEdit { color: black; ' 'background-color: %s; }'%col) tt = self.tooltips[0 if normal else 1] @@ -1322,10 +1319,10 @@ class IdentifiersEdit(QLineEdit): # {{{ if not isbn: col = 'none' elif check_isbn(isbn) is not None: - col = 'rgba(0,255,0,20%)' + col = OK_COLOR extra = '\n\n'+_('This ISBN number is valid') else: - col = 'rgba(255,0,0,20%)' + col = ERR_COLOR extra = '\n\n' + _('This ISBN number is invalid') self.setToolTip(tt+extra) self.setStyleSheet('QLineEdit { background-color: %s }'%col) @@ -1384,10 +1381,10 @@ class ISBNDialog(QDialog): # {{{ col = 'none' extra = '' elif check_isbn(isbn) is not None: - col = 'rgba(0,255,0,20%)' + col = OK_COLOR extra = _('This ISBN number is valid') else: - col = 'rgba(255,0,0,20%)' + col = ERR_COLOR extra = _('This ISBN number is invalid') self.line_edit.setToolTip(extra) self.line_edit.setStyleSheet('QLineEdit { background-color: %s }'%col)