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 = QMenu(self)
|
||||||
m.addAction(_('Set date to undefined') + '\t' + QKeySequence(Qt.Key_Minus).toString(QKeySequence.NativeText),
|
m.addAction(_('Set date to undefined') + '\t' + QKeySequence(Qt.Key_Minus).toString(QKeySequence.NativeText),
|
||||||
self.clear_date)
|
self.clear_date)
|
||||||
|
m.addAction(_('Set date to today') + '\t' + QKeySequence(Qt.Key_Equal).toString(QKeySequence.NativeText),
|
||||||
|
self.today_date)
|
||||||
m.addSeparator()
|
m.addSeparator()
|
||||||
populate_standard_spinbox_context_menu(self, m)
|
populate_standard_spinbox_context_menu(self, m)
|
||||||
m.popup(ev.globalPos())
|
m.popup(ev.globalPos())
|
||||||
|
|
||||||
|
def today_date(self):
|
||||||
|
self.setDateTime(QDateTime.currentDateTime())
|
||||||
|
|
||||||
def clear_date(self):
|
def clear_date(self):
|
||||||
self.setDateTime(UNDEFINED_QDATETIME)
|
self.setDateTime(UNDEFINED_QDATETIME)
|
||||||
|
|
||||||
@ -135,8 +140,8 @@ class DateTimeEdit(QDateTimeEdit): # {{{
|
|||||||
ev.accept()
|
ev.accept()
|
||||||
self.clear_date()
|
self.clear_date()
|
||||||
elif ev.key() == Qt.Key_Equal:
|
elif ev.key() == Qt.Key_Equal:
|
||||||
|
self.today_date()
|
||||||
ev.accept()
|
ev.accept()
|
||||||
self.setDateTime(QDateTime.currentDateTime())
|
|
||||||
else:
|
else:
|
||||||
return QDateTimeEdit.keyPressEvent(self, ev)
|
return QDateTimeEdit.keyPressEvent(self, ev)
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -164,6 +164,8 @@ def make_undoable(spinbox):
|
|||||||
if hasattr(self, 'setDateTime'):
|
if hasattr(self, 'setDateTime'):
|
||||||
m.addAction(_('Set date to undefined') + '\t' + QKeySequence(Qt.Key_Minus).toString(QKeySequence.NativeText),
|
m.addAction(_('Set date to undefined') + '\t' + QKeySequence(Qt.Key_Minus).toString(QKeySequence.NativeText),
|
||||||
lambda : self.setDateTime(self.minimumDateTime()))
|
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(_('&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.addAction(_('&Redo') + access_key(QKeySequence.Redo), self.redo).setEnabled(self.undo_stack.canRedo())
|
||||||
m.addSeparator()
|
m.addSeparator()
|
||||||
@ -255,13 +257,13 @@ class TitleSortEdit(TitleEdit, ToMetadataMixin):
|
|||||||
self.languages_edit = languages_edit
|
self.languages_edit = languages_edit
|
||||||
|
|
||||||
base = self.TOOLTIP
|
base = self.TOOLTIP
|
||||||
ok_tooltip = '<p>' + textwrap.fill(base+'<br><br>'+
|
ok_tooltip = '<p>' + textwrap.fill(base+'<br><br>' + _(
|
||||||
_(' The green color indicates that the current '
|
' The green color indicates that the current '
|
||||||
'title sort matches the current title'))
|
'title sort matches the current title'))
|
||||||
bad_tooltip = '<p>'+textwrap.fill(base + '<br><br>'+
|
bad_tooltip = '<p>'+textwrap.fill(base + '<br><br>' + _(
|
||||||
_(' The red color warns that the current '
|
' The red color warns that the current '
|
||||||
'title sort does not match the current title. '
|
'title sort does not match the current title. '
|
||||||
'No action is required if this is what you want.'))
|
'No action is required if this is what you want.'))
|
||||||
self.tooltips = (ok_tooltip, bad_tooltip)
|
self.tooltips = (ok_tooltip, bad_tooltip)
|
||||||
|
|
||||||
self.title_edit.textChanged.connect(self.update_state_and_val, type=Qt.QueuedConnection)
|
self.title_edit.textChanged.connect(self.update_state_and_val, type=Qt.QueuedConnection)
|
||||||
@ -450,13 +452,13 @@ class AuthorSortEdit(EnLineEdit, ToMetadataMixin):
|
|||||||
self.db = db
|
self.db = db
|
||||||
|
|
||||||
base = self.TOOLTIP
|
base = self.TOOLTIP
|
||||||
ok_tooltip = '<p>' + textwrap.fill(base+'<br><br>'+
|
ok_tooltip = '<p>' + textwrap.fill(base+'<br><br>' + _(
|
||||||
_(' The green color indicates that the current '
|
' The green color indicates that the current '
|
||||||
'author sort matches the current author'))
|
'author sort matches the current author'))
|
||||||
bad_tooltip = '<p>'+textwrap.fill(base + '<br><br>'+
|
bad_tooltip = '<p>'+textwrap.fill(base + '<br><br>'+ _(
|
||||||
_(' The red color indicates that the current '
|
' The red color indicates that the current '
|
||||||
'author sort does not match the current author. '
|
'author sort does not match the current author. '
|
||||||
'No action is required if this is what you want.'))
|
'No action is required if this is what you want.'))
|
||||||
self.tooltips = (ok_tooltip, bad_tooltip)
|
self.tooltips = (ok_tooltip, bad_tooltip)
|
||||||
|
|
||||||
self.authors_edit.editTextChanged.connect(self.update_state_and_val, type=Qt.QueuedConnection)
|
self.authors_edit.editTextChanged.connect(self.update_state_and_val, type=Qt.QueuedConnection)
|
||||||
@ -898,10 +900,9 @@ class FormatsManager(QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def add_format(self, *args):
|
def add_format(self, *args):
|
||||||
files = choose_files(self, 'add formats dialog',
|
files = choose_files(
|
||||||
_("Choose formats for ") +
|
self, 'add formats dialog', _("Choose formats for ") + self.dialog.title.current_val,
|
||||||
self.dialog.title.current_val,
|
[(_('Books'), BOOK_EXTENSIONS)])
|
||||||
[(_('Books'), BOOK_EXTENSIONS)])
|
|
||||||
self._add_formats(files)
|
self._add_formats(files)
|
||||||
|
|
||||||
def restore_fmt(self, fmt):
|
def restore_fmt(self, fmt):
|
||||||
@ -1109,9 +1110,9 @@ class Cover(ImageView): # {{{
|
|||||||
cf = open(_file, "rb")
|
cf = open(_file, "rb")
|
||||||
cover = cf.read()
|
cover = cf.read()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
d = error_dialog(self, _('Error reading file'),
|
d = error_dialog(
|
||||||
_("<p>There was an error reading from file: <br /><b>") +
|
self, _('Error reading file'),
|
||||||
_file + "</b></p><br />"+str(e))
|
_("<p>There was an error reading from file: <br /><b>") + _file + "</b></p><br />"+str(e))
|
||||||
d.exec_()
|
d.exec_()
|
||||||
if cover:
|
if cover:
|
||||||
orig = self.current_val
|
orig = self.current_val
|
||||||
|
Loading…
x
Reference in New Issue
Block a user