From 8423f761af8b4a103e74fc70931c2c06fc32d44b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 17 Jan 2022 13:02:11 +0530 Subject: [PATCH] Hide date conditions when match type is set/unset --- src/calibre/gui2/dialogs/search.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/calibre/gui2/dialogs/search.py b/src/calibre/gui2/dialogs/search.py index 8f6ed17161..059d0a7e20 100644 --- a/src/calibre/gui2/dialogs/search.py +++ b/src/calibre/gui2/dialogs/search.py @@ -164,8 +164,21 @@ def create_simple_tab(self, db): self.general_combo.findText(self.box_last_values['general_index'])) +def toggle_date_conditions_visibility(self): + dcl = self.date_tab.date_condition_layouts + op = current_dateop(self.dateop_date) + visible = op not in 'su' + for l in dcl: + for i in range(l.count()): + x = l.itemAt(i) + w = x.widget() + if w is not None: + w.setVisible(visible) + + def create_date_tab(self, db): self.date_tab = w = QWidget(self.tab_widget) + w.date_condition_layouts = dcl = [] self.tab_widget.addTab(w, _("&Date search")) w.l = l = QVBoxLayout(w) @@ -192,11 +205,13 @@ def create_date_tab(self, db): h.addWidget(df) self.dateop_date = dd = add(_("date column for books whose &date is "), QComboBox(w)) init_dateop(dd) + connect_lambda(dd.currentIndexChanged, self, toggle_date_conditions_visibility) w.la3 = la = QLabel('...') h.addWidget(la) h.addStretch(10) w.h2 = h = QHBoxLayout() + dcl.append(h) l.addLayout(h) self.sel_date = a(QRadioButton(_('&year'), w)) self.date_year = dy = a(QSpinBox(w)) @@ -211,6 +226,7 @@ def create_date_tab(self, db): h.addStretch(10) w.h3 = h = QHBoxLayout() + dcl.append(h) l.addLayout(h) self.sel_daysago = a(QRadioButton('', w)) self.date_daysago = da = a(QSpinBox(w)) @@ -222,6 +238,7 @@ def create_date_tab(self, db): w.h4 = h = QHBoxLayout() l.addLayout(h) + dcl.append(h) self.sel_human = a(QRadioButton('', w)) self.date_human = dh = a(QComboBox(w)) for val, text in [('today', _('Today')), ('yesterday', _('Yesterday')), ('thismonth', _('This month'))]: @@ -235,6 +252,7 @@ def create_date_tab(self, db): h.addStretch(10) l.addStretch(10) + toggle_date_conditions_visibility(self) def create_template_tab(self):