mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 04:52:48 +02:00
Handle links with a target in the standalone viewer
This commit is contained in:
parent
566bfe6df2
commit
c7a2178d24
2 changed files with 7 additions and 2 deletions
|
|
@ -279,7 +279,8 @@ def acceptNavigationRequest(self, url, req_type, is_main_frame):
|
|||
return True
|
||||
if url.scheme() in (FAKE_PROTOCOL, 'data'):
|
||||
return True
|
||||
safe_open_url(url)
|
||||
if url.scheme() in ('http', 'https'):
|
||||
safe_open_url(url)
|
||||
return False
|
||||
|
||||
def go_to_anchor(self, anchor):
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
)
|
||||
from read_book.footnotes import is_footnote_link
|
||||
from read_book.globals import (
|
||||
current_book, current_layout_mode, current_spine_item, set_boss,
|
||||
current_book, current_layout_mode, current_spine_item, runtime, set_boss,
|
||||
set_current_spine_item, set_layout_mode
|
||||
)
|
||||
from read_book.mathjax import apply_mathjax
|
||||
|
|
@ -380,6 +380,10 @@ def connect_links(self):
|
|||
link_attr = 'data-' + self.book.manifest.link_uid
|
||||
for a in document.body.querySelectorAll('a[{}]'.format(link_attr)):
|
||||
a.addEventListener('click', self.link_activated)
|
||||
if runtime.is_standalone_viewer:
|
||||
# links with a target get turned into requests to open a new window by Qt
|
||||
for a in document.body.querySelectorAll('a[target]'):
|
||||
a.removeAttribute('target')
|
||||
|
||||
def link_activated(self, evt):
|
||||
link_attr = 'data-' + self.book.manifest.link_uid
|
||||
|
|
|
|||
Loading…
Reference in a new issue