mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Fix page position incorrect after startup bookmark
E-book viewer: Fix a bug that could cause the reported position to be incorrect immediately after opening a previously opened book. This also fixes the Back button not working if a link is clicked on the page immediately after opening the book.
This commit is contained in:
parent
0ab4ebbfbd
commit
f75458224b
Binary file not shown.
@ -50,6 +50,8 @@ class BookIndexing
|
||||
this.last_check = [null, null]
|
||||
|
||||
cache_valid: (anchors) ->
|
||||
if not anchors
|
||||
return false
|
||||
for a in anchors
|
||||
if not Object.prototype.hasOwnProperty.call(this.cache, a)
|
||||
return false
|
||||
@ -65,6 +67,8 @@ class BookIndexing
|
||||
return this.cache
|
||||
|
||||
ans = {}
|
||||
if not anchors
|
||||
return ans
|
||||
for anchor in anchors
|
||||
elem = document.getElementById(anchor)
|
||||
if elem == null
|
||||
|
@ -772,12 +772,14 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
self.scrolled(self.view.scroll_fraction)
|
||||
|
||||
def internal_link_clicked(self, frac):
|
||||
self.update_page_number() # Ensure page number is accurate as it is used for history
|
||||
self.history.add(self.pos.value())
|
||||
|
||||
def link_clicked(self, url):
|
||||
path = os.path.abspath(unicode(url.toLocalFile()))
|
||||
frag = None
|
||||
if path in self.iterator.spine:
|
||||
self.update_page_number() # Ensure page number is accurate as it is used for history
|
||||
self.history.add(self.pos.value())
|
||||
path = self.iterator.spine[self.iterator.spine.index(path)]
|
||||
if url.hasFragment():
|
||||
@ -913,6 +915,14 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
else:
|
||||
self.view.document.page_position.restore()
|
||||
self.view.document.after_resize()
|
||||
# For some reason scroll_fraction returns incorrect results in paged
|
||||
# mode for some time after a resize is finished. No way of knowing
|
||||
# exactly how long, so we update it in a second, in the hopes that it
|
||||
# will be enough *most* of the time.
|
||||
QTimer.singleShot(1000, self.update_page_number)
|
||||
|
||||
def update_page_number(self):
|
||||
self.set_page_number(self.view.document.scroll_fraction)
|
||||
|
||||
def close_progress_indicator(self):
|
||||
self.pi.stop()
|
||||
|
Loading…
x
Reference in New Issue
Block a user