Fix :debug-webaction
This commit is contained in:
parent
deb0a10973
commit
70b7314b76
@ -32,6 +32,10 @@ from PyQt5.QtCore import Qt, QUrl, QEvent
|
||||
from PyQt5.QtGui import QKeyEvent
|
||||
from PyQt5.QtPrintSupport import QPrintDialog, QPrintPreviewDialog
|
||||
from PyQt5.QtWebKitWidgets import QWebPage
|
||||
try:
|
||||
from PyQt5.QtWebEngineWidgets import QWebEnginePage
|
||||
except ImportError:
|
||||
QWebEnginePage = None
|
||||
import pygments
|
||||
import pygments.lexers
|
||||
import pygments.formatters
|
||||
@ -1644,13 +1648,23 @@ class CommandDispatcher:
|
||||
action: The action to execute, e.g. MoveToNextChar.
|
||||
count: How many times to repeat the action.
|
||||
"""
|
||||
tab = self._current_widget()
|
||||
|
||||
if tab.backend == tabmod.Backend.QtWebKit:
|
||||
assert QWebPage is not None
|
||||
member = getattr(QWebPage, action, None)
|
||||
if not isinstance(member, QWebPage.WebAction):
|
||||
base = QWebPage.WebAction
|
||||
elif tab.backend == tabmod.Backend.QtWebEngine:
|
||||
assert QWebEnginePage is not None
|
||||
member = getattr(QWebEnginePage, action, None)
|
||||
base = QWebEnginePage.WebAction
|
||||
|
||||
if not isinstance(member, base):
|
||||
raise cmdexc.CommandError("{} is not a valid web action!".format(
|
||||
action))
|
||||
view = self._current_widget()
|
||||
|
||||
for _ in range(count):
|
||||
view.triggerPageAction(member)
|
||||
tab.run_webaction(member)
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
||||
maxsplit=0, no_cmd_split=True)
|
||||
|
@ -482,6 +482,9 @@ class AbstractTab(QWidget):
|
||||
def icon(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def run_webaction(self, action):
|
||||
raise NotImplementedError
|
||||
|
||||
def __repr__(self):
|
||||
url = utils.elide(self.cur_url.toDisplayString(QUrl.EncodeUnicode),
|
||||
100)
|
||||
|
@ -156,6 +156,9 @@ class WebEngineViewTab(tab.AbstractTab):
|
||||
def icon(self):
|
||||
return self._widget.icon()
|
||||
|
||||
def run_webaction(self, action):
|
||||
self._widget.triggerPageAction(action)
|
||||
|
||||
def _connect_signals(self):
|
||||
view = self._widget
|
||||
page = view.page()
|
||||
|
@ -487,7 +487,7 @@ class WebViewTab(tab.AbstractTab):
|
||||
action = QWebPage.ReloadAndBypassCache
|
||||
else:
|
||||
action = QWebPage.Reload
|
||||
self._widget.triggerPageAction(action)
|
||||
self.run_webaction(action)
|
||||
|
||||
def stop(self):
|
||||
self._widget.stop()
|
||||
@ -499,6 +499,9 @@ class WebViewTab(tab.AbstractTab):
|
||||
nam = self._widget.page().networkAccessManager()
|
||||
nam.clear_all_ssl_errors()
|
||||
|
||||
def run_webaction(self, action):
|
||||
self._widget.triggerPageAction(action)
|
||||
|
||||
def _connect_signals(self):
|
||||
view = self._widget
|
||||
page = view.page()
|
||||
|
Loading…
Reference in New Issue
Block a user