Slow an initial load spinner while book is being rendered

This commit is contained in:
Kovid Goyal 2019-08-04 15:02:25 +05:30
parent 67fcb5345d
commit 55fbc89eb6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 17 additions and 2 deletions

View File

@ -74,6 +74,7 @@ class EbookViewer(MainWindow):
def load_ebook(self, pathtoebook, open_at=None):
# TODO: Implement open_at
self.web_view.show_preparing_message()
if self.save_annotations_debounce_timer.isActive():
self.save_annotations()
self.current_book_data = {}

View File

@ -169,6 +169,7 @@ class ViewerBridge(Bridge):
set_session_data = from_js(object, object)
create_view = to_js()
show_preparing_message = to_js()
start_book_load = to_js()
@ -315,10 +316,17 @@ class WebView(RestartingWebEngineView):
def start_book_load(self, initial_cfi=None):
key = (set_book_path.path,)
self.execute_when_ready('start_book_load', key, initial_cfi)
def execute_when_ready(self, action, *args):
if self.bridge.ready:
self.bridge.start_book_load(key, initial_cfi)
getattr(self.bridge, action)(*args)
else:
self.pending_bridge_ready_actions['start_book_load'] = key, initial_cfi
self.pending_bridge_ready_actions[action] = args
def show_preparing_message(self):
msg = _('Preparing book for reading, please wait…')
self.execute_when_ready('show_preparing_message', msg)
def set_session_data(self, key, val):
if key == '*' and val is None:

View File

@ -180,6 +180,12 @@ def create_view(prefs):
create_session_data(prefs)
view = View(document.getElementById('view'))
@from_python
def show_preparing_message(msg):
view.show_loading_message(msg)
@from_python
def start_book_load(key, initial_cfi):
xhr = ajax('manifest', manifest_received.bind(None, key, initial_cfi), ok_code=0)