This commit is contained in:
Kovid Goyal 2012-04-13 21:17:45 +05:30
parent 9226771fd3
commit 9db407c2ec

View File

@ -232,6 +232,7 @@ class SearchAndReplaceWidget(Widget, Ui_Form):
'''
new_val = None
legacy = {}
rest = {}
for name, val in recs.items():
if name == 'search_replace':
new_val = val
@ -239,6 +240,11 @@ class SearchAndReplaceWidget(Widget, Ui_Form):
self.search_replace.setDisabled(True)
elif name.startswith('sr'):
legacy[name] = val if val else ''
else:
rest[name] = val
if rest:
super(SearchAndReplaceWidget, self).apply_recommendations(rest)
if new_val is None and legacy:
for i in range(1, 4):
@ -250,6 +256,14 @@ class SearchAndReplaceWidget(Widget, Ui_Form):
if new_val is not None:
self.set_value(self.opt_search_replace, new_val)
def restore_defaults(self, get_option):
super(SearchAndReplaceWidget, self).restore_defaults(get_option)
# This method is only called to set global defaults, not per book
# defaults. Therefore, we ensure that the value is None. Without this,
# apply_recommendations will not work, as it only applies the value if
# it is not None.
self.set_value(self.opt_search_replace, None)
def setup_help_handler(self, g, help):
if g is self.opt_search_replace:
self.search_replace._help = _(