mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add 'set to today' buttons to metadata editors
This commit is contained in:
parent
924b8a3b3e
commit
acdc3d864a
@ -10,9 +10,10 @@ from functools import partial
|
||||
|
||||
from PyQt4.Qt import QComboBox, QLabel, QSpinBox, QDoubleSpinBox, QDateEdit, \
|
||||
QDate, QGroupBox, QVBoxLayout, QPlainTextEdit, QSizePolicy, \
|
||||
QSpacerItem, QIcon, QCheckBox, QWidget, QHBoxLayout, SIGNAL
|
||||
QSpacerItem, QIcon, QCheckBox, QWidget, QHBoxLayout, SIGNAL, \
|
||||
QPushButton
|
||||
|
||||
from calibre.utils.date import qt_to_dt
|
||||
from calibre.utils.date import qt_to_dt, now
|
||||
from calibre.gui2.widgets import TagsLineEdit, EnComboBox
|
||||
from calibre.gui2 import UNDEFINED_QDATE
|
||||
from calibre.utils.config import tweaks
|
||||
@ -138,19 +139,24 @@ class DateEdit(QDateEdit):
|
||||
self.setSpecialValueText(_('Undefined'))
|
||||
QDateEdit.focusOutEvent(self, x)
|
||||
|
||||
def set_to_today(self):
|
||||
self.setDate(now())
|
||||
|
||||
class DateTime(Base):
|
||||
|
||||
def setup_ui(self, parent):
|
||||
self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent),
|
||||
DateEdit(parent)]
|
||||
cm = self.col_metadata
|
||||
self.widgets = [QLabel('&'+cm['name']+':', parent), DateEdit(parent),
|
||||
QLabel(''), QPushButton(_('Set \'%s\' to today')%cm['name'], parent)]
|
||||
w = self.widgets[1]
|
||||
format = self.col_metadata['display'].get('date_format','')
|
||||
format = cm['display'].get('date_format','')
|
||||
if not format:
|
||||
format = 'dd MMM yyyy'
|
||||
w.setDisplayFormat(format)
|
||||
w.setCalendarPopup(True)
|
||||
w.setMinimumDate(UNDEFINED_QDATE)
|
||||
w.setSpecialValueText(_('Undefined'))
|
||||
self.widgets[3].clicked.connect(w.set_to_today)
|
||||
|
||||
def setter(self, val):
|
||||
if val is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user