parent
1ef793fa66
commit
530befd681
@ -22,6 +22,11 @@
|
|||||||
from PyQt5.QtCore import QBuffer, QIODevice, QUrl
|
from PyQt5.QtCore import QBuffer, QIODevice, QUrl
|
||||||
from PyQt5.QtWebEngineCore import (QWebEngineUrlSchemeHandler,
|
from PyQt5.QtWebEngineCore import (QWebEngineUrlSchemeHandler,
|
||||||
QWebEngineUrlRequestJob)
|
QWebEngineUrlRequestJob)
|
||||||
|
try:
|
||||||
|
from PyQt5.QtWebEngineCore import QWebEngineUrlScheme # type: ignore
|
||||||
|
except ImportError:
|
||||||
|
# Added in Qt 5.12
|
||||||
|
QWebEngineUrlScheme = None
|
||||||
|
|
||||||
from qutebrowser.browser import qutescheme
|
from qutebrowser.browser import qutescheme
|
||||||
from qutebrowser.utils import log, qtutils
|
from qutebrowser.utils import log, qtutils
|
||||||
@ -33,6 +38,9 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler):
|
|||||||
|
|
||||||
def install(self, profile):
|
def install(self, profile):
|
||||||
"""Install the handler for qute:// URLs on the given profile."""
|
"""Install the handler for qute:// URLs on the given profile."""
|
||||||
|
if QWebEngineUrlScheme is not None:
|
||||||
|
assert QWebEngineUrlScheme.schemeByName(b'qute') is not None
|
||||||
|
|
||||||
profile.installUrlSchemeHandler(b'qute', self)
|
profile.installUrlSchemeHandler(b'qute', self)
|
||||||
if (qtutils.version_check('5.11', compiled=False) and
|
if (qtutils.version_check('5.11', compiled=False) and
|
||||||
not qtutils.version_check('5.12', compiled=False)):
|
not qtutils.version_check('5.12', compiled=False)):
|
||||||
@ -131,3 +139,16 @@ class QuteSchemeHandler(QWebEngineUrlSchemeHandler):
|
|||||||
buf.seek(0)
|
buf.seek(0)
|
||||||
buf.close()
|
buf.close()
|
||||||
job.reply(mimetype.encode('ascii'), buf)
|
job.reply(mimetype.encode('ascii'), buf)
|
||||||
|
|
||||||
|
|
||||||
|
def init():
|
||||||
|
"""Register the qute:// scheme.
|
||||||
|
|
||||||
|
Note this needs to be called early, before constructing any QtWebEngine
|
||||||
|
classes.
|
||||||
|
"""
|
||||||
|
if QWebEngineUrlScheme is not None:
|
||||||
|
scheme = QWebEngineUrlScheme(b'qute')
|
||||||
|
scheme.setFlags(QWebEngineUrlScheme.LocalScheme |
|
||||||
|
QWebEngineUrlScheme.LocalAccessAllowed)
|
||||||
|
QWebEngineUrlScheme.registerScheme(scheme)
|
||||||
|
@ -30,7 +30,7 @@ from PyQt5.QtGui import QFont
|
|||||||
from PyQt5.QtWebEngineWidgets import (QWebEngineSettings, QWebEngineProfile,
|
from PyQt5.QtWebEngineWidgets import (QWebEngineSettings, QWebEngineProfile,
|
||||||
QWebEnginePage)
|
QWebEnginePage)
|
||||||
|
|
||||||
from qutebrowser.browser.webengine import spell
|
from qutebrowser.browser.webengine import spell, webenginequtescheme
|
||||||
from qutebrowser.config import config, websettings
|
from qutebrowser.config import config, websettings
|
||||||
from qutebrowser.config.websettings import AttributeInfo as Attr
|
from qutebrowser.config.websettings import AttributeInfo as Attr
|
||||||
from qutebrowser.utils import utils, standarddir, qtutils, message, log
|
from qutebrowser.utils import utils, standarddir, qtutils, message, log
|
||||||
@ -298,6 +298,7 @@ def init(args):
|
|||||||
not hasattr(QWebEnginePage, 'setInspectedPage')): # only Qt < 5.11
|
not hasattr(QWebEnginePage, 'setInspectedPage')): # only Qt < 5.11
|
||||||
os.environ['QTWEBENGINE_REMOTE_DEBUGGING'] = str(utils.random_port())
|
os.environ['QTWEBENGINE_REMOTE_DEBUGGING'] = str(utils.random_port())
|
||||||
|
|
||||||
|
webenginequtescheme.init()
|
||||||
spell.init()
|
spell.init()
|
||||||
|
|
||||||
_init_profiles()
|
_init_profiles()
|
||||||
|
Loading…
Reference in New Issue
Block a user