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