mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix incorrect help strings being used in Preferences->Input/Output Options when multiple formats use the same option name
This commit is contained in:
parent
ff05a6a5fe
commit
ae8bfcae83
@ -80,8 +80,19 @@ class Base(ConfigWidgetBase):
|
||||
merge_plugin_recs=False)
|
||||
|
||||
def widget_factory(cls):
|
||||
return cls(self, self.plumber.get_option_by_name,
|
||||
self.plumber.get_option_help, None, None)
|
||||
plugin = getattr(cls, 'conv_plugin', None)
|
||||
if plugin is None:
|
||||
hfunc = self.plumber.get_option_by_name
|
||||
else:
|
||||
options = plugin.options.union(plugin.common_options)
|
||||
|
||||
def hfunc(name):
|
||||
for rec in options:
|
||||
if rec.option == name:
|
||||
ans = getattr(rec, 'help', None)
|
||||
if ans is not None:
|
||||
return ans.replace('%default', str(rec.recommended_value))
|
||||
return cls(self, self.plumber.get_option_by_name, hfunc, None, None)
|
||||
|
||||
self.load_conversion_widgets()
|
||||
widgets = list(map(widget_factory, self.conversion_widgets))
|
||||
@ -131,6 +142,7 @@ class InputOptions(Base):
|
||||
for plugin in input_format_plugins():
|
||||
pw = config_widget_for_input_plugin(plugin)
|
||||
if pw is not None:
|
||||
pw.conv_plugin = plugin
|
||||
self.conversion_widgets.append(pw)
|
||||
|
||||
|
||||
@ -144,14 +156,15 @@ class OutputOptions(Base):
|
||||
output_widget = importlib.import_module(
|
||||
'calibre.gui2.convert.'+name)
|
||||
pw = output_widget.PluginWidget
|
||||
pw.conv_plugin = plugin
|
||||
self.conversion_widgets.append(pw)
|
||||
except ImportError:
|
||||
continue
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from PyQt5.Qt import QApplication
|
||||
app = QApplication([])
|
||||
from calibre.gui2 import Application
|
||||
app = Application([])
|
||||
# test_widget('Conversion', 'Input Options')
|
||||
# test_widget('Conversion', 'Common Options')
|
||||
test_widget('Conversion', 'Output Options')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user