Sync to trunk.

This commit is contained in:
John Schember 2011-04-08 20:11:48 -04:00
commit 87be713558
4 changed files with 36 additions and 13 deletions

View File

@ -13,7 +13,7 @@ from functools import partial
from calibre.ebooks import ConversionError, DRMError
from calibre.ptempfile import PersistentTemporaryFile
from calibre import isosx, iswindows, islinux, isfreebsd
from calibre.constants import isosx, iswindows, islinux, isfreebsd
from calibre import CurrentDir
PDFTOHTML = 'pdftohtml'
@ -43,6 +43,8 @@ def pdftohtml(output_dir, pdf_path, no_images):
# This is neccessary as pdftohtml doesn't always (linux) respect absolute paths
pdf_path = os.path.abspath(pdf_path)
cmd = [PDFTOHTML, '-enc', 'UTF-8', '-noframes', '-p', '-nomerge', '-nodrm', '-q', pdf_path, os.path.basename(index)]
if isfreebsd:
cmd.remove('-nodrm')
if no_images:
cmd.append('-i')

View File

@ -238,7 +238,7 @@ class Spacer(QWidget): # {{{
self.l.addStretch(10)
# }}}
class MenuAction(QAction):
class MenuAction(QAction): # {{{
def __init__(self, clone, parent):
QAction.__init__(self, clone.text(), parent)
@ -247,7 +247,7 @@ class MenuAction(QAction):
def clone_changed(self):
self.setText(self.clone.text())
# }}}
class MenuBar(QMenuBar): # {{{

View File

@ -398,12 +398,24 @@ class IdentifyWidget(QWidget): # {{{
self.abort.set()
# }}}
class FullFetch(QDialog): # {{{
class CoverWidget(QWidget): # {{{
def __init__(self, log, parent=None):
QDialog.__init__(self, parent)
QWidget.__init__(self, parent)
self.log = log
def start(self, book, current_cover, title, authors):
self.book, self.current_cover = book, current_cover
self.title, self.authors = title, authors
self.log('\n\nStarting cover download for:', book.title)
# }}}
class FullFetch(QDialog): # {{{
def __init__(self, log, current_cover=None, parent=None):
QDialog.__init__(self, parent)
self.log, self.current_cover = log, current_cover
self.setWindowTitle(_('Downloading metadata...'))
self.setWindowIcon(QIcon(I('metadata.png')))
@ -428,12 +440,19 @@ class FullFetch(QDialog): # {{{
self.identify_widget.results_found.connect(self.identify_results_found)
self.identify_widget.book_selected.connect(self.book_selected)
self.stack.addWidget(self.identify_widget)
self.cover_widget = CoverWidget(self.log, parent=self)
self.stack.addWidget(self.cover_widget)
self.resize(850, 500)
def book_selected(self, book):
print (book)
self.next_button.setVisible(False)
self.ok_button.setVisible(True)
self.book = book
self.stack.setCurrentIndex(1)
self.cover_widget.start(book, self.current_cover,
self.title, self.authors)
def accept(self):
# Prevent the usual dialog accept mechanisms from working
@ -453,6 +472,7 @@ class FullFetch(QDialog): # {{{
pass
def start(self, title=None, authors=None, identifiers={}):
self.title, self.authors = title, authors
self.identify_widget.start(title=title, authors=authors,
identifiers=identifiers)
self.exec_()

View File

@ -80,6 +80,12 @@ class BaseModel(QAbstractListModel):
ans.append(n)
return ans
def has_action(self, name):
for a in self._data:
if a.name == name:
return True
return False
class AllModel(BaseModel):
@ -291,13 +297,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
def commit(self):
# Ensure preferences are showing in either the toolbar or
# the menubar.
pref_in_toolbar = lm_in_toolbar = False
cm = self.models['toolbar']
for x in cm[1]._data:
if x.name == 'Preferences':
pref_in_toolbar = True
if x.name == 'Location Manager':
lm_in_toolbar = True
pref_in_toolbar = self.models['toolbar'][1].has_action('Preferences')
lm_in_toolbar = self.models['toolbar-device'][1].has_action('Location Manager')
if not pref_in_toolbar:
self.models['menubar'][1].add(['Preferences'])
if not lm_in_toolbar: