mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
GUI: View Book respects input plugins and can be used to view multiple books. Also, respects input format preferrence ordering.
This commit is contained in:
parent
83abb08b90
commit
78b3b9ba29
@ -47,6 +47,7 @@ from calibre.gui2.dialogs.book_info import BookInfo
|
|||||||
from calibre.ebooks import BOOK_EXTENSIONS
|
from calibre.ebooks import BOOK_EXTENSIONS
|
||||||
from calibre.library.database2 import LibraryDatabase2, CoverCache
|
from calibre.library.database2 import LibraryDatabase2, CoverCache
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
|
from calibre.customize.ui import available_input_formats
|
||||||
|
|
||||||
ADDRESS = r'\\.\pipe\CalibreGUI' if iswindows else \
|
ADDRESS = r'\\.\pipe\CalibreGUI' if iswindows else \
|
||||||
os.path.expanduser('~/.calibre-gui.socket')
|
os.path.expanduser('~/.calibre-gui.socket')
|
||||||
@ -1349,51 +1350,48 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
|
|
||||||
def view_book(self, triggered):
|
def view_book(self, triggered):
|
||||||
rows = self.current_view().selectionModel().selectedRows()
|
rows = self.current_view().selectionModel().selectedRows()
|
||||||
if self.current_view() is self.library_view:
|
|
||||||
if not rows or len(rows) == 0:
|
|
||||||
self._launch_viewer()
|
|
||||||
return
|
|
||||||
|
|
||||||
row = rows[0].row()
|
if not rows or len(rows) == 0:
|
||||||
formats = self.library_view.model().db.formats(row).upper()
|
self._launch_viewer()
|
||||||
formats = formats.split(',')
|
return
|
||||||
title = self.library_view.model().db.title(row)
|
|
||||||
id = self.library_view.model().db.id(row)
|
if len(rows) >= 3:
|
||||||
format = None
|
if not question_dialog(self, _('Multiple Books Selected'),
|
||||||
if len(formats) == 1:
|
_('You are attempting to open %i books. Opening to many '
|
||||||
format = formats[0]
|
'books at once can be slow and have an negative effect on the '
|
||||||
if 'LRF' in formats:
|
'responsiveness of your computer. Once started the process '
|
||||||
format = 'LRF'
|
'cannot be stopped until complete. Do you wish to continue?'
|
||||||
if 'EPUB' in formats:
|
% len(rows))):
|
||||||
format = 'EPUB'
|
|
||||||
if 'MOBI' in formats:
|
|
||||||
format = 'MOBI'
|
|
||||||
if not formats:
|
|
||||||
d = error_dialog(self, _('Cannot view'),
|
|
||||||
_('%s has no available formats.')%(title,))
|
|
||||||
d.exec_()
|
|
||||||
return
|
|
||||||
if format is None:
|
|
||||||
d = ChooseFormatDialog(self, _('Choose the format to view'),
|
|
||||||
formats)
|
|
||||||
d.exec_()
|
|
||||||
if d.result() == QDialog.Accepted:
|
|
||||||
format = d.format()
|
|
||||||
else:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.current_view() is self.library_view:
|
||||||
|
for row in rows:
|
||||||
|
row = row.row()
|
||||||
|
|
||||||
self.view_format(row, format)
|
formats = self.library_view.model().db.formats(row).lower()
|
||||||
|
formats = set(formats.split(',')).intersection(available_input_formats())
|
||||||
|
title = self.library_view.model().db.title(row)
|
||||||
|
|
||||||
|
if not formats:
|
||||||
|
error_dialog(self, _('Cannot view'),
|
||||||
|
_('%s has no available formats.')%(title,), show=True)
|
||||||
|
continue
|
||||||
|
|
||||||
|
print prefs['input_format_order']
|
||||||
|
for format in prefs['input_format_order']:
|
||||||
|
if format.lower() in formats:
|
||||||
|
self.view_format(row, format)
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
paths = self.current_view().model().paths(rows)
|
paths = self.current_view().model().paths(rows)
|
||||||
if paths:
|
for path in paths:
|
||||||
pt = PersistentTemporaryFile('_viewer_'+\
|
pt = PersistentTemporaryFile('_viewer_'+\
|
||||||
os.path.splitext(paths[0])[1])
|
os.path.splitext(path)[1])
|
||||||
self.persistent_files.append(pt)
|
self.persistent_files.append(pt)
|
||||||
pt.close()
|
pt.close()
|
||||||
self.device_manager.view_book(\
|
self.device_manager.view_book(\
|
||||||
Dispatcher(self.book_downloaded_for_viewing),
|
Dispatcher(self.book_downloaded_for_viewing),
|
||||||
paths[0], pt.name)
|
path, pt.name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user