When vieweing a book on the device by clicking in the book details panel, first copy the book off the device, this allows it to work for the smart device driver and the MTP driver

This commit is contained in:
Kovid Goyal 2012-09-02 00:06:54 +05:30
parent 4bc92ec184
commit 4e20f776bc
3 changed files with 16 additions and 11 deletions

View file

@ -256,6 +256,15 @@ def update_history(self, views, remove=frozenset()):
db.prefs['gui_view_history'] = history[:vh]
self.build_menus(db)
def view_device_book(self, path):
pt = PersistentTemporaryFile('_view_device_book'+\
os.path.splitext(path)[1])
self.persistent_files.append(pt)
pt.close()
self.gui.device_manager.view_book(
Dispatcher(self.book_downloaded_for_viewing),
path, pt.name)
def _view_books(self, rows):
if not rows or len(rows) == 0:
self._launch_viewer()
@ -270,12 +279,5 @@ def _view_books(self, rows):
else:
paths = self.gui.current_view().model().paths(rows)
for path in paths:
pt = PersistentTemporaryFile('_viewer_'+\
os.path.splitext(path)[1])
self.persistent_files.append(pt)
pt.close()
self.gui.device_manager.view_book(\
Dispatcher(self.book_downloaded_for_viewing),
path, pt.name)
self.view_device_book(path)

View file

@ -19,8 +19,8 @@
from calibre.ebooks.metadata.sources.identify import urls_from_identifiers
from calibre.constants import filesystem_encoding
from calibre.library.comments import comments_to_html
from calibre.gui2 import (config, open_local_file, open_url, pixmap_to_data,
gprefs, rating_font)
from calibre.gui2 import (config, open_url, pixmap_to_data, gprefs,
rating_font)
from calibre.utils.icu import sort_key
from calibre.utils.formatter import EvalFormatter
from calibre.utils.date import is_date_undefined
@ -569,6 +569,7 @@ class BookDetails(QWidget): # {{{
files_dropped = pyqtSignal(object, object)
cover_changed = pyqtSignal(object, object)
cover_removed = pyqtSignal(object)
view_device_book = pyqtSignal(object)
# Drag 'n drop {{{
DROPABBLE_EXTENSIONS = IMAGE_EXTENSIONS+BOOK_EXTENSIONS
@ -643,7 +644,7 @@ def handle_click(self, link):
id_, fmt = val.split(':')
self.view_specific_format.emit(int(id_), fmt)
elif typ == 'devpath':
open_local_file(val)
self.view_device_book.emit(val)
else:
try:
open_url(QUrl(link, QUrl.TolerantMode))

View file

@ -269,6 +269,8 @@ def finalize_layout(self):
self.iactions['Remove Books'].remove_format_by_id)
self.book_details.save_specific_format.connect(
self.iactions['Save To Disk'].save_library_format_by_ids)
self.book_details.view_device_book.connect(
self.iactions['View'].view_device_book)
m = self.library_view.model()
if m.rowCount(None) > 0: