This commit is contained in:
Kovid Goyal 2022-11-20 17:48:59 +05:30
commit aea3492d77
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -155,8 +155,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
name = icu_lower(str(self.gst_names.currentText()))
if not name:
return error_dialog(self.gui, _('Grouped search terms'),
_('The search term cannot be blank'),
_('The search term name cannot be blank'),
show=True)
if ' ' in name:
return error_dialog(self.gui, _('Invalid grouped search name'),
_('The grouped search term name cannot contain spaces'), show=True)
if idx != 0:
orig_name = str(self.gst_names.itemData(idx) or '')
else:
@ -176,7 +179,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
if not val:
return error_dialog(self.gui, _('Grouped search terms'),
_('The value box cannot be empty'), show=True)
if orig_name and name != orig_name:
del self.gst[orig_name]
self.gst_changed = True
@ -234,8 +236,16 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
'The option to have un-accented characters match accented characters has no effect'
' if you also turn on case-sensitive searching. So only turn on one of those options'), show=True)
raise AbortCommit()
ucs = (m.strip() for m in self.opt_grouped_search_make_user_categories.text().split(',') if m.strip())
ucs -= (self.gst.keys())
if ucs:
error_dialog(self, _('Missing grouped search terms'), _(
'The option "Make user categories from" contains names that '
"aren't grouped search terms: {}").format(', '.join(sorted(ucs))), show=True)
raise AbortCommit()
restart = ConfigWidgetBase.commit(self)
if self.gst_changed:
if self.gst_changed or self.muc_changed:
self.db.new_api.set_pref('grouped_search_terms', self.gst)
self.db.field_metadata.add_grouped_search_terms(self.gst)
self.db.new_api.set_pref('similar_authors_search_key',