Add QWebEngineView subclass

This commit is contained in:
Florian Bruhin 2016-07-04 16:39:54 +02:00
parent 822e193682
commit a1f4dcd542
2 changed files with 43 additions and 1 deletions

View File

@ -28,6 +28,7 @@ except ImportError:
QWebEnginePage = None
from qutebrowser.browser import tab
from qutebrowser.browser.webengine import webview
from qutebrowser.utils import usertypes, qtutils
@ -99,7 +100,7 @@ class WebEngineViewTab(tab.AbstractTab):
def __init__(self, win_id, parent=None):
super().__init__(win_id)
widget = QWebEngineView()
widget = webview.WebEngineView()
self.history = WebEngineHistory(self)
self.scroll = WebEngineScroller()
self.caret = WebEngineCaret(win_id=win_id, tab=self, parent=self)

View File

@ -0,0 +1,41 @@
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2014-2016 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
#
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""The main browser widget for QtWebEngine."""
from PyQt5.QtCore import pyqtSignal, Qt, QPoint
from PyQt5.QtWebEngineWidgets import QWebEngineView
class WebEngineView(QWebEngineView):
mouse_wheel_zoom = pyqtSignal(QPoint)
def wheelEvent(self, e):
"""Zoom on Ctrl-Mousewheel.
Args:
e: The QWheelEvent.
"""
if e.modifiers() & Qt.ControlModifier:
e.accept()
self.mouse_wheel_zoom.emit(e.angleDelta())
else:
super().wheelEvent(e)