mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pep8
This commit is contained in:
parent
7900b4ac69
commit
348fdd514a
@ -14,9 +14,8 @@ from PyQt4.Qt import (QWidget, QSpinBox, QDoubleSpinBox, QLineEdit, QTextEdit,
|
||||
QFontInfo)
|
||||
|
||||
from calibre.customize.conversion import OptionRecommendation
|
||||
from calibre.ebooks.conversion.config import load_defaults, \
|
||||
save_defaults as save_defaults_, \
|
||||
load_specifics, GuiRecommendations
|
||||
from calibre.ebooks.conversion.config import (
|
||||
load_defaults, save_defaults as save_defaults_, load_specifics, GuiRecommendations)
|
||||
from calibre import prepare_string_for_xml
|
||||
from calibre.customize.ui import plugin_for_input_format
|
||||
from calibre.gui2.font_family_chooser import FontFamilyChooser
|
||||
@ -104,7 +103,6 @@ class Widget(QWidget):
|
||||
process_child(g)
|
||||
process_child(self)
|
||||
|
||||
|
||||
def restore_defaults(self, get_option):
|
||||
defaults = GuiRecommendations()
|
||||
defaults.merge_recommendations(get_option, OptionRecommendation.LOW,
|
||||
@ -121,14 +119,16 @@ class Widget(QWidget):
|
||||
recs = GuiRecommendations()
|
||||
for name in self._options:
|
||||
gui_opt = getattr(self, 'opt_'+name, None)
|
||||
if gui_opt is None: continue
|
||||
if gui_opt is None:
|
||||
continue
|
||||
recs[name] = self.get_value(gui_opt)
|
||||
return recs
|
||||
|
||||
def apply_recommendations(self, recs):
|
||||
for name, val in recs.items():
|
||||
gui_opt = getattr(self, 'opt_'+name, None)
|
||||
if gui_opt is None: continue
|
||||
if gui_opt is None:
|
||||
continue
|
||||
self.set_value(gui_opt, val)
|
||||
if name in getattr(recs, 'disabled_options', []):
|
||||
gui_opt.setDisabled(True)
|
||||
@ -215,7 +215,8 @@ class Widget(QWidget):
|
||||
if isinstance(g, (QSpinBox, QDoubleSpinBox)):
|
||||
g.setValue(val)
|
||||
elif isinstance(g, (QLineEdit, QTextEdit)):
|
||||
if not val: val = ''
|
||||
if not val:
|
||||
val = ''
|
||||
getattr(g, 'setPlainText', g.setText)(val)
|
||||
getattr(g, 'setCursorPosition', lambda x: x)(0)
|
||||
elif isinstance(g, QFontComboBox):
|
||||
@ -255,8 +256,10 @@ class Widget(QWidget):
|
||||
if g is None:
|
||||
continue
|
||||
help = help_provider(name)
|
||||
if not help: continue
|
||||
if self.setup_help_handler(g, help): continue
|
||||
if not help:
|
||||
continue
|
||||
if self.setup_help_handler(g, help):
|
||||
continue
|
||||
g._help = help
|
||||
self.setup_widget_help(g)
|
||||
|
||||
@ -267,7 +270,6 @@ class Widget(QWidget):
|
||||
g.setWhatsThis(htext)
|
||||
g.__class__.enterEvent = lambda obj, event: self.set_help(getattr(obj, '_help', obj.toolTip()))
|
||||
|
||||
|
||||
def set_value_handler(self, g, val):
|
||||
'Return True iff you handle setting the value for g'
|
||||
return False
|
||||
|
Loading…
x
Reference in New Issue
Block a user