Remove unused code

This commit is contained in:
Kovid Goyal 2019-03-16 09:06:47 +05:30
parent d3ccd4369b
commit 4a967a28c3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 0 additions and 299 deletions

View File

@ -1,91 +0,0 @@
from __future__ import with_statement
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
''''''
from PyQt5.Qt import QDialog
from calibre.gui2.dialogs.comicconf_ui import Ui_Dialog
from calibre.ebooks.lrf.comic.convert_from import config, PROFILES
from polyglot.builtins import unicode_type
def set_conversion_defaults(window):
d = ComicConf(window)
d.exec_()
def get_bulk_conversion_options(window):
d = ComicConf(window, config_defaults=config(None).as_string())
if d.exec_() == QDialog.Accepted:
return d.config.parse()
def get_conversion_options(window, defaults, title, author):
if defaults is None:
defaults = config(None).as_string()
defaults += '\ntitle=%s\nauthor=%s'%(repr(title), repr(author))
d = ComicConf(window, config_defaults=defaults, generic=False)
if d.exec_() == QDialog.Accepted:
return d.config.parse(), d.config.src
return None, None
class ComicConf(QDialog, Ui_Dialog):
def __init__(self, window, config_defaults=None, generic=True,
title=_('Set defaults for conversion of comics (CBR/CBZ files)')):
QDialog.__init__(self, window)
Ui_Dialog.__init__(self)
self.setupUi(self)
self.setWindowTitle(title)
self.config = config(config_defaults)
opts = self.config.parse()
if generic:
for i in ('title', 'author'):
getattr(self, 'opt_'+i).setVisible(False)
getattr(self, i+'_label').setVisible(False)
else:
title = opts.title
if not title:
title = _('Unknown')
self.setWindowTitle(_('Set options for converting %s')%title)
author = opts.author
self.opt_title.setText(title)
self.opt_author.setText(author)
self.opt_colors.setValue(opts.colors)
self.opt_profile.addItem(opts.profile)
for x in PROFILES.keys():
if x != opts.profile:
self.opt_profile.addItem(x)
self.opt_dont_normalize.setChecked(opts.dont_normalize)
self.opt_keep_aspect_ratio.setChecked(opts.keep_aspect_ratio)
self.opt_dont_sharpen.setChecked(opts.dont_sharpen)
self.opt_landscape.setChecked(opts.landscape)
self.opt_no_sort.setChecked(opts.no_sort)
self.opt_despeckle.setChecked(opts.despeckle)
self.opt_wide.setChecked(opts.wide)
self.opt_right2left.setChecked(opts.right2left)
for opt in self.config.option_set.preferences:
g = getattr(self, 'opt_'+opt.name, False)
if opt.help and g:
g.setToolTip(opt.help)
def accept(self):
for opt in self.config.option_set.preferences:
g = getattr(self, 'opt_'+opt.name, False)
if not g or not g.isVisible():
continue
if hasattr(g, 'isChecked'):
val = bool(g.isChecked())
elif hasattr(g, 'value'):
val = g.value()
elif hasattr(g, 'itemText'):
val = unicode_type(g.itemText(g.currentIndex()))
elif hasattr(g, 'text'):
val = unicode_type(g.text())
else:
raise Exception('Bad coding')
self.config.set(opt.name, val)
return QDialog.accept(self)

View File

@ -1,202 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>646</width>
<height>503</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/convert.png</normaloff>:/images/convert.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="title_label">
<property name="text">
<string>&amp;Title:</string>
</property>
<property name="buddy">
<cstring>opt_title</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="EnLineEdit" name="opt_title"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="author_label">
<property name="text">
<string>&amp;Author(s):</string>
</property>
<property name="buddy">
<cstring>opt_author</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="EnLineEdit" name="opt_author"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&amp;Number of colors:</string>
</property>
<property name="buddy">
<cstring>opt_colors</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="opt_colors">
<property name="minimum">
<number>8</number>
</property>
<property name="maximum">
<number>3200000</number>
</property>
<property name="singleStep">
<number>8</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&amp;Profile:</string>
</property>
<property name="buddy">
<cstring>opt_profile</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="opt_profile"/>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="opt_dont_normalize">
<property name="text">
<string>Disable &amp;normalize</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="opt_keep_aspect_ratio">
<property name="text">
<string>Keep &amp;aspect ratio</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="opt_dont_sharpen">
<property name="text">
<string>Disable &amp;sharpening</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="opt_landscape">
<property name="text">
<string>&amp;Landscape</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QCheckBox" name="opt_no_sort">
<property name="text">
<string>Don't so&amp;rt</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QCheckBox" name="opt_right2left">
<property name="text">
<string>&amp;Right to left</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QCheckBox" name="opt_despeckle">
<property name="text">
<string>De&amp;speckle</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="opt_wide">
<property name="text">
<string>&amp;Wide</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="opt_disable_trim">
<property name="text">
<string>Disable &amp;trimming</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>EnLineEdit</class>
<extends>QLineEdit</extends>
<header>calibre/gui2/widgets.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../resources/images.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -288,12 +288,6 @@ class Config(ConfigInterface):
traceback.print_exc()
return self.option_set.parse_string(src)
def as_string(self):
if not os.path.exists(self.config_file_path):
return ''
with ExclusiveFile(self.config_file_path) as f:
return f.read().decode('utf-8')
def set(self, name, val):
if not self.option_set.has_option(name):
raise ValueError('The option %s is not defined.'%name)