Viewer: Add command line option to force reloading of all books

This commit is contained in:
Kovid Goyal 2019-10-26 14:28:14 +05:30
parent b206f89336
commit 243144f3b9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 3 deletions

View File

@ -159,6 +159,8 @@ View an e-book.
a('--full-screen', '--fullscreen', '-f', default=False, action='store_true',
help=_('If specified, viewer window will try to open '
'full screen when started.'))
a('--force-reload', default=False, action='store_true',
help=_('Force reload of all opened books'))
a('--open-at', default=None, help=_(
'The position at which to open the specified book. The position is '
'a location you can get by using the Goto action in the viewer controls. '
@ -203,7 +205,7 @@ def main(args=sys.argv):
app.load_builtin_fonts()
app.setWindowIcon(QIcon(I('viewer.png')))
migrate_previous_viewer_prefs()
main = EbookViewer(open_at=opts.open_at, continue_reading=opts.continue_reading)
main = EbookViewer(open_at=opts.open_at, continue_reading=opts.continue_reading, force_reload=opts.force_reload)
main.set_exception_handler()
if len(args) > 1:
acc.events.append(os.path.abspath(args[-1]))

View File

@ -77,8 +77,9 @@ class EbookViewer(MainWindow):
book_prepared = pyqtSignal(object, object)
MAIN_WINDOW_STATE_VERSION = 1
def __init__(self, open_at=None, continue_reading=None):
def __init__(self, open_at=None, continue_reading=None, force_reload=False):
MainWindow.__init__(self, None)
self.force_reload = force_reload
connect_lambda(self.book_preparation_started, self, lambda self: self.loading_overlay(_(
'Preparing book for first read, please wait')), type=Qt.QueuedConnection)
self.maximized_at_last_fullscreen = False
@ -302,7 +303,7 @@ class EbookViewer(MainWindow):
self.loading_overlay(_('Loading book, please wait'))
self.save_annotations()
self.current_book_data = {}
t = Thread(name='LoadBook', target=self._load_ebook_worker, args=(pathtoebook, open_at, reload_book))
t = Thread(name='LoadBook', target=self._load_ebook_worker, args=(pathtoebook, open_at, reload_book or self.force_reload))
t.daemon = True
t.start()