Add post_event to tab API
This commit is contained in:
parent
6f24221c54
commit
1b3d693a5e
@ -23,7 +23,7 @@ import itertools
|
|||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QUrl, QObject, QSizeF
|
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QUrl, QObject, QSizeF
|
||||||
from PyQt5.QtGui import QIcon
|
from PyQt5.QtGui import QIcon
|
||||||
from PyQt5.QtWidgets import QWidget, QApplication
|
from PyQt5.QtWidgets import QWidget
|
||||||
|
|
||||||
from qutebrowser.keyinput import modeman
|
from qutebrowser.keyinput import modeman
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
@ -532,6 +532,10 @@ class AbstractTab(QWidget):
|
|||||||
self._load_status = val
|
self._load_status = val
|
||||||
self.load_status_changed.emit(val.name)
|
self.load_status_changed.emit(val.name)
|
||||||
|
|
||||||
|
def post_event(self, evt):
|
||||||
|
"""Send the given event to the underlying widget."""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
@pyqtSlot('QMouseEvent')
|
@pyqtSlot('QMouseEvent')
|
||||||
def _on_hint_mouse_event(self, evt):
|
def _on_hint_mouse_event(self, evt):
|
||||||
"""Post a new mouse event from a hintmanager."""
|
"""Post a new mouse event from a hintmanager."""
|
||||||
@ -540,7 +544,7 @@ class AbstractTab(QWidget):
|
|||||||
# focusProxy()?
|
# focusProxy()?
|
||||||
log.modes.debug("Hint triggered, focusing {!r}".format(self))
|
log.modes.debug("Hint triggered, focusing {!r}".format(self))
|
||||||
self._widget.setFocus()
|
self._widget.setFocus()
|
||||||
QApplication.postEvent(self._widget, evt)
|
self.post_event(evt)
|
||||||
|
|
||||||
@pyqtSlot(QUrl)
|
@pyqtSlot(QUrl)
|
||||||
def _on_link_clicked(self, url):
|
def _on_link_clicked(self, url):
|
||||||
|
@ -200,12 +200,9 @@ class WebEngineScroller(browsertab.AbstractScroller):
|
|||||||
# FIXME:qtwebengine Abort scrolling if the minimum/maximum was reached.
|
# FIXME:qtwebengine Abort scrolling if the minimum/maximum was reached.
|
||||||
press_evt = QKeyEvent(QEvent.KeyPress, key, Qt.NoModifier, 0, 0, 0)
|
press_evt = QKeyEvent(QEvent.KeyPress, key, Qt.NoModifier, 0, 0, 0)
|
||||||
release_evt = QKeyEvent(QEvent.KeyRelease, key, Qt.NoModifier, 0, 0, 0)
|
release_evt = QKeyEvent(QEvent.KeyRelease, key, Qt.NoModifier, 0, 0, 0)
|
||||||
recipient = self._widget.focusProxy()
|
|
||||||
for _ in range(count):
|
for _ in range(count):
|
||||||
# If we get a segfault here, we might want to try sendEvent
|
self._tab.post_event(press_evt)
|
||||||
# instead.
|
self._tab.post_event(release_evt)
|
||||||
QApplication.postEvent(recipient, press_evt)
|
|
||||||
QApplication.postEvent(recipient, release_evt)
|
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def _update_pos(self):
|
def _update_pos(self):
|
||||||
@ -516,3 +513,9 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||||||
page.contentsSizeChanged.connect(self.contents_size_changed)
|
page.contentsSizeChanged.connect(self.contents_size_changed)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
log.stub('contentsSizeChanged, on Qt < 5.7')
|
log.stub('contentsSizeChanged, on Qt < 5.7')
|
||||||
|
|
||||||
|
def post_event(self, evt):
|
||||||
|
# If we get a segfault here, we might want to try sendEvent
|
||||||
|
# instead.
|
||||||
|
recipient = self._widget.focusProxy()
|
||||||
|
QApplication.postEvent(recipient, evt)
|
||||||
|
@ -28,6 +28,7 @@ from PyQt5.QtCore import (pyqtSlot, Qt, QEvent, QUrl, QPoint, QTimer, QSizeF,
|
|||||||
from PyQt5.QtGui import QKeyEvent
|
from PyQt5.QtGui import QKeyEvent
|
||||||
from PyQt5.QtWebKitWidgets import QWebPage, QWebFrame
|
from PyQt5.QtWebKitWidgets import QWebPage, QWebFrame
|
||||||
from PyQt5.QtWebKit import QWebSettings
|
from PyQt5.QtWebKit import QWebSettings
|
||||||
|
from PyQt5.QtWidgets import QApplication
|
||||||
from PyQt5.QtPrintSupport import QPrinter
|
from PyQt5.QtPrintSupport import QPrinter
|
||||||
|
|
||||||
from qutebrowser.browser import browsertab
|
from qutebrowser.browser import browsertab
|
||||||
@ -677,3 +678,8 @@ class WebKitTab(browsertab.AbstractTab):
|
|||||||
frame.contentsSizeChanged.connect(self._on_contents_size_changed)
|
frame.contentsSizeChanged.connect(self._on_contents_size_changed)
|
||||||
frame.initialLayoutCompleted.connect(self._on_history_trigger)
|
frame.initialLayoutCompleted.connect(self._on_history_trigger)
|
||||||
page.link_clicked.connect(self._on_link_clicked)
|
page.link_clicked.connect(self._on_link_clicked)
|
||||||
|
|
||||||
|
def post_event(self, evt):
|
||||||
|
# If we get a segfault here, we might want to try sendEvent
|
||||||
|
# instead.
|
||||||
|
QApplication.postEvent(self._widget, evt)
|
||||||
|
Loading…
Reference in New Issue
Block a user