From a3776e361b75347c31ad98b0940f1e09984cb57c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 13 Jul 2015 17:39:09 +0200 Subject: [PATCH] minimal_webkit_testbrowser: Add WebEngine support. --- scripts/minimal_webkit_testbrowser.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/minimal_webkit_testbrowser.py b/scripts/minimal_webkit_testbrowser.py index 0b0a02840..20e5e2eea 100755 --- a/scripts/minimal_webkit_testbrowser.py +++ b/scripts/minimal_webkit_testbrowser.py @@ -28,6 +28,12 @@ from PyQt5.QtWidgets import QApplication from PyQt5.QtWebKit import QWebSettings from PyQt5.QtWebKitWidgets import QWebView +try: + from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineSettings + WEBENGINE = True +except ImportError: + WEBENGINE = False + def parse_args(): """Parse commandline arguments.""" @@ -35,6 +41,9 @@ def parse_args(): parser.add_argument('url', help='The URL to open') parser.add_argument('--plugins', '-p', help='Enable plugins', default=False, action='store_true') + if WEBENGINE: + parser.add_argument('--webengine', help='Use QtWebEngine', + default=False, action='store_true') return parser.parse_args() @@ -42,12 +51,16 @@ if __name__ == '__main__': args = parse_args() app = QApplication(sys.argv) - wv = QWebView() + if WEBENGINE and args.webengine: + wv = QWebEngineView() + else: + wv = QWebView() + wv.loadStarted.connect(lambda: print("Loading started")) wv.loadProgress.connect(lambda p: print("Loading progress: {}%".format(p))) wv.loadFinished.connect(lambda: print("Loading finished")) - if args.plugins: + if args.plugins and not WEBENGINE: wv.settings().setAttribute(QWebSettings.PluginsEnabled, True) wv.load(QUrl.fromUserInput(args.url))