mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a right click menu ation to set the date to today
This commit is contained in:
parent
6795ce98ae
commit
00de2544a2
@ -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)
|
||||
# }}}
|
||||
|
@ -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,11 +257,11 @@ class TitleSortEdit(TitleEdit, ToMetadataMixin):
|
||||
self.languages_edit = languages_edit
|
||||
|
||||
base = self.TOOLTIP
|
||||
ok_tooltip = '<p>' + textwrap.fill(base+'<br><br>'+
|
||||
_(' The green color indicates that the current '
|
||||
ok_tooltip = '<p>' + textwrap.fill(base+'<br><br>' + _(
|
||||
' The green color indicates that the current '
|
||||
'title sort matches the current title'))
|
||||
bad_tooltip = '<p>'+textwrap.fill(base + '<br><br>'+
|
||||
_(' The red color warns that the current '
|
||||
bad_tooltip = '<p>'+textwrap.fill(base + '<br><br>' + _(
|
||||
' 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)
|
||||
@ -450,11 +452,11 @@ class AuthorSortEdit(EnLineEdit, ToMetadataMixin):
|
||||
self.db = db
|
||||
|
||||
base = self.TOOLTIP
|
||||
ok_tooltip = '<p>' + textwrap.fill(base+'<br><br>'+
|
||||
_(' The green color indicates that the current '
|
||||
ok_tooltip = '<p>' + textwrap.fill(base+'<br><br>' + _(
|
||||
' The green color indicates that the current '
|
||||
'author sort matches the current author'))
|
||||
bad_tooltip = '<p>'+textwrap.fill(base + '<br><br>'+
|
||||
_(' The red color indicates that the current '
|
||||
bad_tooltip = '<p>'+textwrap.fill(base + '<br><br>'+ _(
|
||||
' 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)
|
||||
@ -898,9 +900,8 @@ class FormatsManager(QWidget):
|
||||
return
|
||||
|
||||
def add_format(self, *args):
|
||||
files = choose_files(self, 'add formats dialog',
|
||||
_("Choose formats for ") +
|
||||
self.dialog.title.current_val,
|
||||
files = choose_files(
|
||||
self, 'add formats dialog', _("Choose formats for ") + self.dialog.title.current_val,
|
||||
[(_('Books'), BOOK_EXTENSIONS)])
|
||||
self._add_formats(files)
|
||||
|
||||
@ -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'),
|
||||
_("<p>There was an error reading from file: <br /><b>") +
|
||||
_file + "</b></p><br />"+str(e))
|
||||
d = error_dialog(
|
||||
self, _('Error reading file'),
|
||||
_("<p>There was an error reading from file: <br /><b>") + _file + "</b></p><br />"+str(e))
|
||||
d.exec_()
|
||||
if cover:
|
||||
orig = self.current_val
|
||||
|
Loading…
x
Reference in New Issue
Block a user