parent
a14ef88acf
commit
acfb3aa26f
@ -193,6 +193,24 @@ def _set_http_headers(profile):
|
|||||||
profile.setHttpAcceptLanguage(accept_language)
|
profile.setHttpAcceptLanguage(accept_language)
|
||||||
|
|
||||||
|
|
||||||
|
def _init_js(profile):
|
||||||
|
"""Initialize QtWebEngine JavaScript on the given profile."""
|
||||||
|
js_code = '\n'.join([
|
||||||
|
'"use strict";',
|
||||||
|
'window._qutebrowser = {};',
|
||||||
|
utils.read_file('javascript/scroll.js'),
|
||||||
|
utils.read_file('javascript/webelem.js'),
|
||||||
|
])
|
||||||
|
|
||||||
|
script = QWebEngineScript()
|
||||||
|
script.setInjectionPoint(QWebEngineScript.DocumentCreation)
|
||||||
|
script.setSourceCode(js_code)
|
||||||
|
script.setWorldId(QWebEngineScript.ApplicationWorld)
|
||||||
|
# FIXME:qtwebengine What about runsOnSubFrames?
|
||||||
|
|
||||||
|
profile.scripts().insert(script)
|
||||||
|
|
||||||
|
|
||||||
def _update_settings(option):
|
def _update_settings(option):
|
||||||
"""Update global settings when qwebsettings changed."""
|
"""Update global settings when qwebsettings changed."""
|
||||||
websettings.update_mappings(MAPPINGS, option)
|
websettings.update_mappings(MAPPINGS, option)
|
||||||
@ -215,11 +233,13 @@ def _init_profiles():
|
|||||||
os.path.join(standarddir.data(), 'webengine'))
|
os.path.join(standarddir.data(), 'webengine'))
|
||||||
_init_stylesheet(default_profile)
|
_init_stylesheet(default_profile)
|
||||||
_set_http_headers(default_profile)
|
_set_http_headers(default_profile)
|
||||||
|
_init_js(default_profile)
|
||||||
|
|
||||||
private_profile = QWebEngineProfile()
|
private_profile = QWebEngineProfile()
|
||||||
assert private_profile.isOffTheRecord()
|
assert private_profile.isOffTheRecord()
|
||||||
_init_stylesheet(private_profile)
|
_init_stylesheet(private_profile)
|
||||||
_set_http_headers(private_profile)
|
_set_http_headers(private_profile)
|
||||||
|
_init_js(private_profile)
|
||||||
|
|
||||||
if qtutils.version_check('5.8'):
|
if qtutils.version_check('5.8'):
|
||||||
default_profile.setSpellCheckEnabled(True)
|
default_profile.setSpellCheckEnabled(True)
|
||||||
|
@ -526,27 +526,9 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||||||
self._set_widget(widget)
|
self._set_widget(widget)
|
||||||
self._connect_signals()
|
self._connect_signals()
|
||||||
self.backend = usertypes.Backend.QtWebEngine
|
self.backend = usertypes.Backend.QtWebEngine
|
||||||
self._init_js()
|
|
||||||
self._child_event_filter = None
|
self._child_event_filter = None
|
||||||
self._saved_zoom = None
|
self._saved_zoom = None
|
||||||
|
|
||||||
def _init_js(self):
|
|
||||||
js_code = '\n'.join([
|
|
||||||
'"use strict";',
|
|
||||||
'window._qutebrowser = {};',
|
|
||||||
utils.read_file('javascript/scroll.js'),
|
|
||||||
utils.read_file('javascript/webelem.js'),
|
|
||||||
])
|
|
||||||
script = QWebEngineScript()
|
|
||||||
script.setInjectionPoint(QWebEngineScript.DocumentCreation)
|
|
||||||
script.setSourceCode(js_code)
|
|
||||||
|
|
||||||
page = self._widget.page()
|
|
||||||
script.setWorldId(QWebEngineScript.ApplicationWorld)
|
|
||||||
|
|
||||||
# FIXME:qtwebengine what about runsOnSubFrames?
|
|
||||||
page.scripts().insert(script)
|
|
||||||
|
|
||||||
def _install_event_filter(self):
|
def _install_event_filter(self):
|
||||||
self._widget.focusProxy().installEventFilter(self._mouse_event_filter)
|
self._widget.focusProxy().installEventFilter(self._mouse_event_filter)
|
||||||
self._child_event_filter = mouse.ChildEventFilter(
|
self._child_event_filter = mouse.ChildEventFilter(
|
||||||
|
Loading…
Reference in New Issue
Block a user