mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement --continue
This commit is contained in:
parent
4476d63b27
commit
cd71b471e1
@ -2,8 +2,6 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
# TODO: --open-at and --continue command line options
|
||||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
@ -112,7 +110,8 @@ View an e-book.
|
||||
'The position at which to open the specified book. The position is '
|
||||
'a location as displayed in the top left corner of the viewer. '
|
||||
'Alternately, you can use the form toc:something and it will open '
|
||||
'at the location of the first Table of Contents entry that contains the string "something".'))
|
||||
'at the location of the first Table of Contents entry that contains '
|
||||
'the string "something".'))
|
||||
a('--continue', default=False, action='store_true', dest='continue_reading',
|
||||
help=_('Continue reading at the previously opened book'))
|
||||
|
||||
@ -154,7 +153,7 @@ def main(args=sys.argv):
|
||||
app.file_event_hook = acc
|
||||
app.load_builtin_fonts()
|
||||
app.setWindowIcon(QIcon(I('viewer.png')))
|
||||
main = EbookViewer()
|
||||
main = EbookViewer(open_at=open_at, continue_reading=opts.continue_reading)
|
||||
main.set_exception_handler()
|
||||
if len(args) > 1:
|
||||
acc.events.append(args[-1])
|
||||
|
@ -47,7 +47,7 @@ class EbookViewer(MainWindow):
|
||||
book_prepared = pyqtSignal(object, object)
|
||||
MAIN_WINDOW_STATE_VERSION = 1
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, open_at=None, continue_reading=None):
|
||||
MainWindow.__init__(self, None)
|
||||
self.base_window_title = _('E-book viewer')
|
||||
self.setWindowTitle(self.base_window_title)
|
||||
@ -99,6 +99,8 @@ class EbookViewer(MainWindow):
|
||||
self.web_view.ask_for_open.connect(self.ask_for_open, type=Qt.QueuedConnection)
|
||||
self.setCentralWidget(self.web_view)
|
||||
self.restore_state()
|
||||
if continue_reading:
|
||||
self.continue_reading()
|
||||
|
||||
def toggle_inspector(self):
|
||||
visible = self.inspector_dock.toggleViewAction().isChecked()
|
||||
@ -181,6 +183,12 @@ class EbookViewer(MainWindow):
|
||||
path = files[0]
|
||||
self.load_ebook(path)
|
||||
|
||||
def continue_reading(self):
|
||||
rl = vprefs['session_data'].get('standalone_recently_opened')
|
||||
if rl:
|
||||
entry = rl[0]
|
||||
self.load_ebook(entry['pathtoebook'])
|
||||
|
||||
def load_ebook(self, pathtoebook, open_at=None, reload_book=False):
|
||||
# TODO: Implement open_at
|
||||
self.setWindowTitle(_('Loading book… — {}').format(self.base_window_title))
|
||||
|
Loading…
x
Reference in New Issue
Block a user