mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Context menu works
This commit is contained in:
parent
fe25b8d8f6
commit
c5366521eb
@ -8,7 +8,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||
# live css
|
||||
# check that clicking on both internal and external links works
|
||||
# check if you can remove the restriction that prevents inspector dock from being undocked
|
||||
# check the context menu
|
||||
# check syncing of position back and forth
|
||||
# check all buttons in preview panel
|
||||
# rewrite JS from coffeescript to rapydscript
|
||||
@ -398,17 +397,18 @@ class WebView(QWebEngineView):
|
||||
|
||||
def contextMenuEvent(self, ev):
|
||||
menu = QMenu(self)
|
||||
p = self._page
|
||||
mf = p.mainFrame()
|
||||
r = mf.hitTestContent(ev.pos())
|
||||
url = unicode_type(r.linkUrl().toString(NO_URL_FORMATTING)).strip()
|
||||
data = self._page.contextMenuData()
|
||||
url = data.linkUrl()
|
||||
url = unicode_type(url.toString(NO_URL_FORMATTING)).strip()
|
||||
text = data.selectedText()
|
||||
if text:
|
||||
ca = self.pageAction(QWebEnginePage.Copy)
|
||||
if ca.isEnabled():
|
||||
menu.addAction(ca)
|
||||
menu.addAction(actions['reload-preview'])
|
||||
menu.addAction(QIcon(I('debug.png')), _('Inspect element'), self.inspect)
|
||||
if url.partition(':')[0].lower() in {'http', 'https'}:
|
||||
menu.addAction(_('Open link'), partial(open_url, r.linkUrl()))
|
||||
menu.addAction(_('Open link'), partial(open_url, data.linkUrl()))
|
||||
menu.exec_(ev.globalPos())
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user