mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Go to anchor explicitly in the preview
This commit is contained in:
parent
50ed25a6d9
commit
883717039e
@ -1260,7 +1260,9 @@ class Boss(QObject):
|
|||||||
_('Editing files of type %s is not supported' % mt), show=True)
|
_('Editing files of type %s is not supported' % mt), show=True)
|
||||||
editor = self.edit_file(name, syntax)
|
editor = self.edit_file(name, syntax)
|
||||||
if anchor and editor is not None:
|
if anchor and editor is not None:
|
||||||
if not editor.go_to_anchor(anchor) and show_anchor_not_found:
|
if editor.go_to_anchor(anchor):
|
||||||
|
self.gui.preview.go_to_anchor(anchor)
|
||||||
|
elif show_anchor_not_found:
|
||||||
error_dialog(self.gui, _('Not found'), _(
|
error_dialog(self.gui, _('Not found'), _(
|
||||||
'The anchor %s was not found in this file') % anchor, show=True)
|
'The anchor %s was not found in this file') % anchor, show=True)
|
||||||
|
|
||||||
|
@ -492,6 +492,9 @@ class Preview(QWidget):
|
|||||||
def find_prev(self):
|
def find_prev(self):
|
||||||
self.find('prev')
|
self.find('prev')
|
||||||
|
|
||||||
|
def go_to_anchor(self, anchor):
|
||||||
|
self.view._page.go_to_anchor(anchor)
|
||||||
|
|
||||||
def request_sync(self, tagname, href, lnum):
|
def request_sync(self, tagname, href, lnum):
|
||||||
if self.current_name:
|
if self.current_name:
|
||||||
c = current_container()
|
c = current_container()
|
||||||
@ -501,7 +504,7 @@ class Preview(QWidget):
|
|||||||
else:
|
else:
|
||||||
name = c.href_to_name(href, self.current_name) if href else None
|
name = c.href_to_name(href, self.current_name) if href else None
|
||||||
if name == self.current_name:
|
if name == self.current_name:
|
||||||
return self.view._page.go_to_anchor(urlparse(href).fragment)
|
return self.go_to_anchor(urlparse(href).fragment)
|
||||||
if name and c.exists(name) and c.mime_map[name] in OEB_DOCS:
|
if name and c.exists(name) and c.mime_map[name] in OEB_DOCS:
|
||||||
return self.link_clicked.emit(name, urlparse(href).fragment or TOP)
|
return self.link_clicked.emit(name, urlparse(href).fragment or TOP)
|
||||||
self.sync_requested.emit(self.current_name, lnum)
|
self.sync_requested.emit(self.current_name, lnum)
|
||||||
|
@ -336,7 +336,7 @@ class PreviewIntegration:
|
|||||||
address = get_sourceline_address(e)
|
address = get_sourceline_address(e)
|
||||||
# Find the closest containing link, if any
|
# Find the closest containing link, if any
|
||||||
href = tn = ''
|
href = tn = ''
|
||||||
while e and e != document.body and e != document and (tn is not 'a' or not href):
|
while e and e is not document.body and e is not document and e is not document.documentElement and (tn is not 'a' or not href):
|
||||||
tn = e.tagName.toLowerCase() if e.tagName else ''
|
tn = e.tagName.toLowerCase() if e.tagName else ''
|
||||||
href = e.getAttribute('href')
|
href = e.getAttribute('href')
|
||||||
e = e.parentNode
|
e = e.parentNode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user