diff --git a/src/calibre/gui2/library/delegates.py b/src/calibre/gui2/library/delegates.py index c026bfeb00..4e0aa5cdb8 100644 --- a/src/calibre/gui2/library/delegates.py +++ b/src/calibre/gui2/library/delegates.py @@ -123,10 +123,15 @@ class DateTimeEdit(QDateTimeEdit): # {{{ m = QMenu(self) m.addAction(_('Set date to undefined') + '\t' + QKeySequence(Qt.Key_Minus).toString(QKeySequence.NativeText), self.clear_date) + m.addAction(_('Set date to today') + '\t' + QKeySequence(Qt.Key_Equal).toString(QKeySequence.NativeText), + self.today_date) m.addSeparator() populate_standard_spinbox_context_menu(self, m) m.popup(ev.globalPos()) + def today_date(self): + self.setDateTime(QDateTime.currentDateTime()) + def clear_date(self): self.setDateTime(UNDEFINED_QDATETIME) @@ -135,8 +140,8 @@ class DateTimeEdit(QDateTimeEdit): # {{{ ev.accept() self.clear_date() elif ev.key() == Qt.Key_Equal: + self.today_date() ev.accept() - self.setDateTime(QDateTime.currentDateTime()) else: return QDateTimeEdit.keyPressEvent(self, ev) # }}} diff --git a/src/calibre/gui2/metadata/basic_widgets.py b/src/calibre/gui2/metadata/basic_widgets.py index 7f03c32e14..82776e86d4 100644 --- a/src/calibre/gui2/metadata/basic_widgets.py +++ b/src/calibre/gui2/metadata/basic_widgets.py @@ -164,6 +164,8 @@ def make_undoable(spinbox): if hasattr(self, 'setDateTime'): m.addAction(_('Set date to undefined') + '\t' + QKeySequence(Qt.Key_Minus).toString(QKeySequence.NativeText), lambda : self.setDateTime(self.minimumDateTime())) + m.addAction(_('Set date to today') + '\t' + QKeySequence(Qt.Key_Equal).toString(QKeySequence.NativeText), + lambda : self.setDateTime(QDateTime.currentDateTime())) m.addAction(_('&Undo') + access_key(QKeySequence.Undo), self.undo).setEnabled(self.undo_stack.canUndo()) m.addAction(_('&Redo') + access_key(QKeySequence.Redo), self.redo).setEnabled(self.undo_stack.canRedo()) m.addSeparator() @@ -255,13 +257,13 @@ class TitleSortEdit(TitleEdit, ToMetadataMixin): self.languages_edit = languages_edit base = self.TOOLTIP - ok_tooltip = '

' + textwrap.fill(base+'

'+ - _(' The green color indicates that the current ' - 'title sort matches the current title')) - bad_tooltip = '

'+textwrap.fill(base + '

'+ - _(' The red color warns that the current ' - 'title sort does not match the current title. ' - 'No action is required if this is what you want.')) + ok_tooltip = '

' + textwrap.fill(base+'

' + _( + ' The green color indicates that the current ' + 'title sort matches the current title')) + bad_tooltip = '

'+textwrap.fill(base + '

' + _( + ' The red color warns that the current ' + 'title sort does not match the current title. ' + 'No action is required if this is what you want.')) self.tooltips = (ok_tooltip, bad_tooltip) self.title_edit.textChanged.connect(self.update_state_and_val, type=Qt.QueuedConnection) @@ -450,13 +452,13 @@ class AuthorSortEdit(EnLineEdit, ToMetadataMixin): self.db = db base = self.TOOLTIP - ok_tooltip = '

' + textwrap.fill(base+'

'+ - _(' The green color indicates that the current ' - 'author sort matches the current author')) - bad_tooltip = '

'+textwrap.fill(base + '

'+ - _(' The red color indicates that the current ' - 'author sort does not match the current author. ' - 'No action is required if this is what you want.')) + ok_tooltip = '

' + textwrap.fill(base+'

' + _( + ' The green color indicates that the current ' + 'author sort matches the current author')) + bad_tooltip = '

'+textwrap.fill(base + '

'+ _( + ' The red color indicates that the current ' + 'author sort does not match the current author. ' + 'No action is required if this is what you want.')) self.tooltips = (ok_tooltip, bad_tooltip) self.authors_edit.editTextChanged.connect(self.update_state_and_val, type=Qt.QueuedConnection) @@ -898,10 +900,9 @@ class FormatsManager(QWidget): return def add_format(self, *args): - files = choose_files(self, 'add formats dialog', - _("Choose formats for ") + - self.dialog.title.current_val, - [(_('Books'), BOOK_EXTENSIONS)]) + files = choose_files( + self, 'add formats dialog', _("Choose formats for ") + self.dialog.title.current_val, + [(_('Books'), BOOK_EXTENSIONS)]) self._add_formats(files) def restore_fmt(self, fmt): @@ -1109,9 +1110,9 @@ class Cover(ImageView): # {{{ cf = open(_file, "rb") cover = cf.read() except IOError as e: - d = error_dialog(self, _('Error reading file'), - _("

There was an error reading from file:
") + - _file + "


"+str(e)) + d = error_dialog( + self, _('Error reading file'), + _("

There was an error reading from file:
") + _file + "


"+str(e)) d.exec_() if cover: orig = self.current_val