diff --git a/src/calibre/gui2/dialogs/epub.py b/src/calibre/gui2/dialogs/epub.py index 88607b1f8d..0773440b01 100644 --- a/src/calibre/gui2/dialogs/epub.py +++ b/src/calibre/gui2/dialogs/epub.py @@ -6,14 +6,14 @@ __docformat__ = 'restructuredtext en' ''' The GUI for conversion to EPUB. ''' -import os +import os, uuid from PyQt4.Qt import QDialog, QSpinBox, QDoubleSpinBox, QComboBox, QLineEdit, \ QTextEdit, QCheckBox, Qt, QPixmap, QIcon, QListWidgetItem, SIGNAL from lxml.etree import XPath from calibre.gui2.dialogs.choose_format import ChooseFormatDialog -from calibre.gui2.dialogs.epub_ui import Ui_Dialog +from calibre.gui2.dialogs.epub_ui import Ui_Dialog from calibre.gui2 import error_dialog, choose_images, pixmap_to_data, ResizableDialog from calibre.ebooks.epub.from_any import SOURCE_FORMATS, config as epubconfig from calibre.ebooks.metadata import MetaInformation @@ -23,16 +23,16 @@ from calibre.ebooks.metadata import authors_to_string, string_to_authors class Config(ResizableDialog, Ui_Dialog): - + OUTPUT = 'EPUB' - + def __init__(self, parent, db, row=None, config=epubconfig): ResizableDialog.__init__(self, parent) self.hide_controls() self.connect(self.category_list, SIGNAL('itemEntered(QListWidgetItem *)'), self.show_category_help) self.connect(self.cover_button, SIGNAL("clicked()"), self.select_cover) - + self.cover_changed = False self.db = db self.id = None @@ -52,7 +52,7 @@ class Config(ResizableDialog, Ui_Dialog): self.setWindowTitle(_('Bulk convert to ')+self.OUTPUT) else: self.setWindowTitle((_(u'Convert %s to ')%unicode(self.title.text()))+self.OUTPUT) - + def hide_controls(self): self.source_profile_label.setVisible(False) self.opt_source_profile.setVisible(False) @@ -63,7 +63,7 @@ class Config(ResizableDialog, Ui_Dialog): self.opt_rescale_images.setVisible(False) self.opt_ignore_tables.setVisible(False) self.opt_prefer_author_sort.setVisible(False) - + def initialize(self): self.__w = [] self.__w.append(QIcon(':/images/dialog_information.svg')) @@ -76,11 +76,11 @@ class Config(ResizableDialog, Ui_Dialog): self.item4 = QListWidgetItem(self.__w[-1], _('Chapter Detection').replace(' ','\n'), self.category_list) self.setup_tooltips() self.initialize_options() - + def set_help(self, msg): if msg and getattr(msg, 'strip', lambda:True)(): self.help_view.setPlainText(msg) - + def setup_tooltips(self): for opt in self.config.option_set.preferences: g = getattr(self, 'opt_'+opt.name, False) @@ -90,19 +90,19 @@ class Config(ResizableDialog, Ui_Dialog): g.setToolTip(help.replace('<', '<').replace('>', '>')) g.setWhatsThis(help.replace('<', '<').replace('>', '>')) g.__class__.enterEvent = lambda obj, event: self.set_help(getattr(obj, '_help', obj.toolTip())) - + def show_category_help(self, item): text = unicode(item.text()) help = { _('Metadata') : _('Specify metadata such as title and author for the book.\n\nMetadata will be updated in the database as well as the generated %s file.')%self.OUTPUT, _('Look & Feel') : _('Adjust the look of the generated ebook by specifying things like font sizes.'), _('Page Setup') : _('Specify the page layout settings like margins.'), - _('Chapter Detection') : _('Fine tune the detection of chapter and section headings.'), + _('Chapter Detection') : _('Fine tune the detection of chapter and section headings.'), } self.set_help(help[text.replace('\n', ' ')]) - + def select_cover(self): - files = choose_images(self, 'change cover dialog', + files = choose_images(self, 'change cover dialog', _('Choose cover for ') + unicode(self.title.text())) if not files: return @@ -110,7 +110,7 @@ class Config(ResizableDialog, Ui_Dialog): if _file: _file = os.path.abspath(_file) if not os.access(_file, os.R_OK): - d = error_dialog(self.window, _('Cannot read'), + d = error_dialog(self.window, _('Cannot read'), _('You do not have permission to read the file: ') + _file) d.exec_() return @@ -118,7 +118,7 @@ class Config(ResizableDialog, Ui_Dialog): try: cf = open(_file, "rb") cover = cf.read() - except IOError, e: + except IOError, e: d = error_dialog(self.window, _('Error reading file'), _("
There was an error reading from file:
") + _file + "