Move send_event to AbstractTab
This means subclasses only need to implement _event_target.
This commit is contained in:
parent
a40dd7edf6
commit
a846a5b89f
@ -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
|
from PyQt5.QtWidgets import QWidget, QApplication
|
||||||
|
|
||||||
from qutebrowser.keyinput import modeman
|
from qutebrowser.keyinput import modeman
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
@ -562,9 +562,15 @@ 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 _event_target(self):
|
||||||
|
"""Return the widget events should be sent to."""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def send_event(self, evt):
|
def send_event(self, evt):
|
||||||
"""Send the given event to the underlying widget."""
|
"""Send the given event to the underlying widget."""
|
||||||
raise NotImplementedError
|
recipient = self._event_target()
|
||||||
|
QApplication.sendEvent(recipient, evt)
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot(QUrl)
|
@pyqtSlot(QUrl)
|
||||||
def _on_link_clicked(self, url):
|
def _on_link_clicked(self, url):
|
||||||
|
@ -26,7 +26,6 @@ import functools
|
|||||||
|
|
||||||
from PyQt5.QtCore import pyqtSlot, Qt, QEvent, QPoint, QUrl
|
from PyQt5.QtCore import pyqtSlot, Qt, QEvent, QPoint, QUrl
|
||||||
from PyQt5.QtGui import QKeyEvent, QIcon
|
from PyQt5.QtGui import QKeyEvent, QIcon
|
||||||
from PyQt5.QtWidgets import QApplication
|
|
||||||
# pylint: disable=no-name-in-module,import-error,useless-suppression
|
# pylint: disable=no-name-in-module,import-error,useless-suppression
|
||||||
from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineScript
|
from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineScript
|
||||||
# pylint: enable=no-name-in-module,import-error,useless-suppression
|
# pylint: enable=no-name-in-module,import-error,useless-suppression
|
||||||
@ -526,6 +525,5 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
log.stub('contentsSizeChanged, on Qt < 5.7')
|
log.stub('contentsSizeChanged, on Qt < 5.7')
|
||||||
|
|
||||||
def send_event(self, evt):
|
def _event_target(self):
|
||||||
recipient = self._widget.focusProxy()
|
return self._widget.focusProxy()
|
||||||
QApplication.sendEvent(recipient, evt)
|
|
||||||
|
@ -28,7 +28,6 @@ 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
|
||||||
@ -696,5 +695,5 @@ class WebKitTab(browsertab.AbstractTab):
|
|||||||
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 send_event(self, evt):
|
def _event_target(self):
|
||||||
QApplication.sendEvent(self._widget, evt)
|
return self._widget
|
||||||
|
Loading…
Reference in New Issue
Block a user