mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add buttons to follow the footnote link and close the footnote window
This commit is contained in:
parent
2f404dbdcd
commit
a2f008766e
@ -1334,6 +1334,11 @@ class DocumentView(QWebView): # {{{
|
||||
self.manager.internal_link_clicked(prev_pos)
|
||||
return ret
|
||||
|
||||
def follow_footnote_link(self):
|
||||
qurl = self.footnotes.showing_url
|
||||
if qurl and qurl.isValid():
|
||||
self.link_clicked(qurl)
|
||||
|
||||
# }}}
|
||||
|
||||
|
||||
|
@ -9,7 +9,9 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
import json
|
||||
from collections import defaultdict
|
||||
|
||||
from PyQt5.Qt import QUrl, QWidget, QHBoxLayout, QSize, pyqtSlot
|
||||
from PyQt5.Qt import (
|
||||
QUrl, QWidget, QHBoxLayout, QSize, pyqtSlot, QVBoxLayout, QToolButton,
|
||||
QIcon, pyqtSignal)
|
||||
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
|
||||
from PyQt5.QtWebKit import QWebSettings
|
||||
|
||||
@ -62,13 +64,25 @@ class FootnotesPage(QWebPage):
|
||||
|
||||
class FootnotesView(QWidget):
|
||||
|
||||
follow_link = pyqtSignal()
|
||||
close_view = pyqtSignal()
|
||||
|
||||
def __init__(self, parent):
|
||||
QWidget.__init__(self, parent)
|
||||
self.l = l = QHBoxLayout(self)
|
||||
self.vl = vl = QVBoxLayout()
|
||||
self.view = v = QWebView(self)
|
||||
self._page = FootnotesPage(v)
|
||||
v.setPage(self._page)
|
||||
l.addWidget(v)
|
||||
l.addWidget(v), l.addLayout(vl)
|
||||
self.goto_button = b = QToolButton(self)
|
||||
b.setIcon(QIcon(I('forward.png'))), b.setToolTip(_('Go to this footnote in the main view'))
|
||||
b.clicked.connect(self.follow_link)
|
||||
vl.addWidget(b)
|
||||
self.close_button = b = QToolButton(self)
|
||||
b.setIcon(QIcon(I('window-close.png'))), b.setToolTip(_('Close the footnotes window'))
|
||||
b.clicked.connect(self.close_view)
|
||||
vl.addWidget(b)
|
||||
|
||||
def page(self):
|
||||
return self._page
|
||||
|
@ -272,6 +272,8 @@ class Main(MainWindow):
|
||||
|
||||
self.footnotes_dock = d = QDockWidget(_('Footnotes'), self)
|
||||
self.footnotes_view = FootnotesView(self)
|
||||
self.footnotes_view.follow_link.connect(self.view.follow_footnote_link)
|
||||
self.footnotes_view.close_view.connect(d.close)
|
||||
self.view.footnotes.set_footnotes_view(self.footnotes_view)
|
||||
d.setObjectName('footnotes-dock')
|
||||
d.setWidget(self.footnotes_view)
|
||||
|
Loading…
x
Reference in New Issue
Block a user