mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
add clear/touch keyb shortcuts to custom column date edit widgets as well
This commit is contained in:
parent
861d1ff53e
commit
73a8f519fa
@ -7,10 +7,10 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
from functools import partial
|
||||
|
||||
from PyQt4.Qt import QComboBox, QLabel, QSpinBox, QDoubleSpinBox, QDateTimeEdit, \
|
||||
QDateTime, QGroupBox, QVBoxLayout, QSizePolicy, QGridLayout, \
|
||||
QSpacerItem, QIcon, QCheckBox, QWidget, QHBoxLayout, SIGNAL, \
|
||||
QPushButton, QMessageBox, QToolButton
|
||||
from PyQt4.Qt import (QComboBox, QLabel, QSpinBox, QDoubleSpinBox, QDateTimeEdit,
|
||||
QDateTime, QGroupBox, QVBoxLayout, QSizePolicy, QGridLayout,
|
||||
QSpacerItem, QIcon, QCheckBox, QWidget, QHBoxLayout, SIGNAL,
|
||||
QPushButton, QMessageBox, QToolButton, Qt)
|
||||
|
||||
from calibre.utils.date import qt_to_dt, now
|
||||
from calibre.gui2.complete2 import EditWithComplete
|
||||
@ -39,7 +39,6 @@ class Base(object):
|
||||
def gui_val(self):
|
||||
return self.getter()
|
||||
|
||||
|
||||
def commit(self, book_id, notify=False):
|
||||
val = self.gui_val
|
||||
val = self.normalize_ui_val(val)
|
||||
@ -159,6 +158,17 @@ class DateTimeEdit(QDateTimeEdit):
|
||||
def set_to_clear(self):
|
||||
self.setDateTime(UNDEFINED_QDATETIME)
|
||||
|
||||
def keyPressEvent(self, ev):
|
||||
if ev.key() == Qt.Key_Minus:
|
||||
ev.accept()
|
||||
self.setDateTime(self.minimumDateTime())
|
||||
elif ev.key() == Qt.Key_Equal:
|
||||
ev.accept()
|
||||
self.setDateTime(QDateTime.currentDateTime())
|
||||
else:
|
||||
return QDateTimeEdit.keyPressEvent(self, ev)
|
||||
|
||||
|
||||
class DateTime(Base):
|
||||
|
||||
def setup_ui(self, parent):
|
||||
@ -595,7 +605,6 @@ class BulkBase(Base):
|
||||
self._cached_gui_val_ = self.getter()
|
||||
return self._cached_gui_val_
|
||||
|
||||
|
||||
def get_initial_value(self, book_ids):
|
||||
values = set([])
|
||||
for book_id in book_ids:
|
||||
@ -1054,3 +1063,5 @@ bulk_widgets = {
|
||||
'series': BulkSeries,
|
||||
'enumeration': BulkEnumeration,
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user