From 298654d9fa7d42b0ec40fd334079a00e0edbb002 Mon Sep 17 00:00:00 2001 From: Eli Algranti Date: Thu, 12 Apr 2012 13:17:32 +1000 Subject: [PATCH] Added setup_help_handler to complement all the other handlers (set_value_handler, get_value_handler, connect_gui_obj_handler) This allows adding options not tied to a widget without having to change Widget --- src/calibre/gui2/convert/__init__.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/calibre/gui2/convert/__init__.py b/src/calibre/gui2/convert/__init__.py index 73b478ac47..7aee392d01 100644 --- a/src/calibre/gui2/convert/__init__.py +++ b/src/calibre/gui2/convert/__init__.py @@ -233,19 +233,22 @@ class Widget(QWidget): pass def setup_help(self, help_provider): - w = textwrap.TextWrapper(80) for name in self._options: g = getattr(self, 'opt_'+name, None) if g is None: continue help = help_provider(name) if not help: continue + if self.setup_help_handler(g, help): continue g._help = help - htext = u'
%s
'%prepare_string_for_xml( - '\n'.join(w.wrap(help))) - g.setToolTip(htext) - g.setWhatsThis(htext) - g.__class__.enterEvent = lambda obj, event: self.set_help(getattr(obj, '_help', obj.toolTip())) + self.setup_widget_help(g) + + def setup_widget_help(self, g): + w = textwrap.TextWrapper(80) + htext = u'
%s
'%prepare_string_for_xml('\n'.join(w.wrap(g._help))) + g.setToolTip(htext) + g.setWhatsThis(htext) + g.__class__.enterEvent = lambda obj, event: self.set_help(getattr(obj, '_help', obj.toolTip())) def set_value_handler(self, g, val): @@ -260,6 +263,9 @@ class Widget(QWidget): def post_get_value(self, g): pass + def setup_help_handler(self, g, help): + return False + def break_cycles(self): self.db = None