mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-26 06:27:12 +01:00
Implement --continue
This commit is contained in:
parent
4476d63b27
commit
cd71b471e1
2 changed files with 13 additions and 6 deletions
|
|
@ -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 @@ def option_parser():
|
|||
'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 @@ def create_dock(title, name, area, areas=Qt.LeftDockWidgetArea | Qt.RightDockWid
|
|||
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,9 +183,15 @@ def ask_for_open(self, path=None):
|
|||
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))
|
||||
self.setWindowTitle(_('Loading book… — {}').format(self.base_window_title))
|
||||
self.web_view.show_preparing_message()
|
||||
self.save_annotations()
|
||||
self.current_book_data = {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue