Register the clbr: fake network scheme with web engine

This commit is contained in:
Kovid Goyal 2019-02-16 11:05:06 +05:30
parent 289c42b87f
commit 08dfee0766
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 14 additions and 4 deletions

View File

@ -8,8 +8,9 @@ import sys
import time
from PyQt5.Qt import QIcon
from PyQt5.QtWebEngineCore import QWebEngineUrlScheme
from calibre.constants import EDITOR_APP_UID, islinux
from calibre.constants import EDITOR_APP_UID, FAKE_PROTOCOL, islinux
from calibre.gui2 import (
Application, decouple, set_gui_prefs, setup_gui_option_parser
)
@ -52,6 +53,10 @@ def _run(args, notify=None):
# Ensure we can continue to function if GUI is closed
os.environ.pop('CALIBRE_WORKER_TEMP_DIR', None)
reset_base_dir()
scheme = QWebEngineUrlScheme(FAKE_PROTOCOL.encode('ascii'))
scheme.setSyntax(QWebEngineUrlScheme.Syntax.Host)
scheme.setFlags(QWebEngineUrlScheme.SecureScheme)
QWebEngineUrlScheme.registerScheme(scheme)
# The following two lines are needed to prevent circular imports causing
# errors during initialization of plugins that use the polish container

View File

@ -11,9 +11,10 @@ import sys
from threading import Thread
from PyQt5.Qt import QIcon, QObject, Qt, QTimer, pyqtSignal
from PyQt5.QtWebEngineCore import QWebEngineUrlScheme
from calibre import as_unicode, prints
from calibre.constants import VIEWER_APP_UID, islinux, iswindows
from calibre.constants import FAKE_PROTOCOL, VIEWER_APP_UID, islinux, iswindows
from calibre.gui2 import (
Application, error_dialog, set_app_uid, setup_gui_option_parser
)
@ -125,6 +126,10 @@ def main(args=sys.argv):
# Ensure viewer can continue to function if GUI is closed
os.environ.pop('CALIBRE_WORKER_TEMP_DIR', None)
reset_base_dir()
scheme = QWebEngineUrlScheme(FAKE_PROTOCOL.encode('ascii'))
scheme.setSyntax(QWebEngineUrlScheme.Syntax.Host)
scheme.setFlags(QWebEngineUrlScheme.SecureScheme)
QWebEngineUrlScheme.registerScheme(scheme)
if iswindows:
# Ensure that all ebook viewer instances are grouped together in the task
# bar. This prevents them from being grouped with the editor process when

View File

@ -6,8 +6,8 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import json
from PyQt5.Qt import QObject, Qt, QWebEnginePage, pyqtSignal
from PyQt5.QtWebEngineWidgets import QWebEngineScript, QWebEngineView
from PyQt5.Qt import QObject, Qt, pyqtSignal
from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineScript, QWebEngineView
from calibre import prints
from calibre.utils.monotonic import monotonic