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 functools import partial
|
||||||
|
|
||||||
from PyQt4.Qt import QComboBox, QLabel, QSpinBox, QDoubleSpinBox, QDateTimeEdit, \
|
from PyQt4.Qt import (QComboBox, QLabel, QSpinBox, QDoubleSpinBox, QDateTimeEdit,
|
||||||
QDateTime, QGroupBox, QVBoxLayout, QSizePolicy, QGridLayout, \
|
QDateTime, QGroupBox, QVBoxLayout, QSizePolicy, QGridLayout,
|
||||||
QSpacerItem, QIcon, QCheckBox, QWidget, QHBoxLayout, SIGNAL, \
|
QSpacerItem, QIcon, QCheckBox, QWidget, QHBoxLayout, SIGNAL,
|
||||||
QPushButton, QMessageBox, QToolButton
|
QPushButton, QMessageBox, QToolButton, Qt)
|
||||||
|
|
||||||
from calibre.utils.date import qt_to_dt, now
|
from calibre.utils.date import qt_to_dt, now
|
||||||
from calibre.gui2.complete2 import EditWithComplete
|
from calibre.gui2.complete2 import EditWithComplete
|
||||||
@ -39,7 +39,6 @@ class Base(object):
|
|||||||
def gui_val(self):
|
def gui_val(self):
|
||||||
return self.getter()
|
return self.getter()
|
||||||
|
|
||||||
|
|
||||||
def commit(self, book_id, notify=False):
|
def commit(self, book_id, notify=False):
|
||||||
val = self.gui_val
|
val = self.gui_val
|
||||||
val = self.normalize_ui_val(val)
|
val = self.normalize_ui_val(val)
|
||||||
@ -159,6 +158,17 @@ class DateTimeEdit(QDateTimeEdit):
|
|||||||
def set_to_clear(self):
|
def set_to_clear(self):
|
||||||
self.setDateTime(UNDEFINED_QDATETIME)
|
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):
|
class DateTime(Base):
|
||||||
|
|
||||||
def setup_ui(self, parent):
|
def setup_ui(self, parent):
|
||||||
@ -211,7 +221,7 @@ class Comments(Base):
|
|||||||
self._layout = QVBoxLayout()
|
self._layout = QVBoxLayout()
|
||||||
self._tb = CommentsEditor(self._box)
|
self._tb = CommentsEditor(self._box)
|
||||||
self._tb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
|
self._tb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||||
#self._tb.setTabChangesFocus(True)
|
# self._tb.setTabChangesFocus(True)
|
||||||
self._layout.addWidget(self._tb)
|
self._layout.addWidget(self._tb)
|
||||||
self._box.setLayout(self._layout)
|
self._box.setLayout(self._layout)
|
||||||
self.widgets = [self._box]
|
self.widgets = [self._box]
|
||||||
@ -534,7 +544,7 @@ def populate_metadata_page(layout, db, book_id, bulk=False, two_column=False, pa
|
|||||||
column = row = base_row = max_row = 0
|
column = row = base_row = max_row = 0
|
||||||
for key in cols:
|
for key in cols:
|
||||||
if not fm[key]['is_editable']:
|
if not fm[key]['is_editable']:
|
||||||
continue # this almost never happens
|
continue # this almost never happens
|
||||||
dt = fm[key]['datatype']
|
dt = fm[key]['datatype']
|
||||||
if dt == 'composite' or (bulk and dt == 'comments'):
|
if dt == 'composite' or (bulk and dt == 'comments'):
|
||||||
continue
|
continue
|
||||||
@ -595,7 +605,6 @@ class BulkBase(Base):
|
|||||||
self._cached_gui_val_ = self.getter()
|
self._cached_gui_val_ = self.getter()
|
||||||
return self._cached_gui_val_
|
return self._cached_gui_val_
|
||||||
|
|
||||||
|
|
||||||
def get_initial_value(self, book_ids):
|
def get_initial_value(self, book_ids):
|
||||||
values = set([])
|
values = set([])
|
||||||
for book_id in book_ids:
|
for book_id in book_ids:
|
||||||
@ -633,7 +642,7 @@ class BulkBase(Base):
|
|||||||
self.main_widget = main_widget_class(w)
|
self.main_widget = main_widget_class(w)
|
||||||
l.addWidget(self.main_widget)
|
l.addWidget(self.main_widget)
|
||||||
l.setStretchFactor(self.main_widget, 10)
|
l.setStretchFactor(self.main_widget, 10)
|
||||||
self.a_c_checkbox = QCheckBox( _('Apply changes'), w)
|
self.a_c_checkbox = QCheckBox(_('Apply changes'), w)
|
||||||
l.addWidget(self.a_c_checkbox)
|
l.addWidget(self.a_c_checkbox)
|
||||||
self.ignore_change_signals = True
|
self.ignore_change_signals = True
|
||||||
|
|
||||||
@ -1054,3 +1063,5 @@ bulk_widgets = {
|
|||||||
'series': BulkSeries,
|
'series': BulkSeries,
|
||||||
'enumeration': BulkEnumeration,
|
'enumeration': BulkEnumeration,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user