From d3d589008a192b368e344d85d6aed03027ca9770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Wed, 31 Jul 2024 13:48:35 +0200 Subject: [PATCH 1/5] fix(web_viewer): switch from QtWebKit to QtWebEngine As discussed in https://github.com/geotribu/qtribu/pull/99, QtWebKit is deprecated. The previous fix was not portable. Even when QGIS has QtWebKitWidgets, it fails if not present on the system. This change adopts a more sustainable method using only QtWebEngineWidgets, which will also be available in Qt6. Additionally, instead of calling PyQt (which can be PyQt5 or PyQt6 depending on the system), we now use the link provided by QGIS with qgis.PyQt. --- qtribu/logic/web_viewer.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/qtribu/logic/web_viewer.py b/qtribu/logic/web_viewer.py index bece78c2..694fae1b 100644 --- a/qtribu/logic/web_viewer.py +++ b/qtribu/logic/web_viewer.py @@ -17,11 +17,8 @@ from qgis.PyQt.QtCore import QCoreApplication, Qt from qgis.PyQt.QtGui import QDesktopServices -try: - from qgis.PyQt.QtWebKitWidgets import QWebView -except: - QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) - from PyQt.QtWebEngineWidgets import QWebEngineView as QWebView +QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) +from qgis.PyQt.QtWebEngineWidgets import QWebEngineView as QWebView from qgis.PyQt.QtWidgets import QVBoxLayout, QWidget From ed97b372bbffa4b659ea925470e00a78c5d8ff5a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:50:00 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- qtribu/logic/web_viewer.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qtribu/logic/web_viewer.py b/qtribu/logic/web_viewer.py index 694fae1b..f2e314d0 100644 --- a/qtribu/logic/web_viewer.py +++ b/qtribu/logic/web_viewer.py @@ -19,7 +19,6 @@ QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) from qgis.PyQt.QtWebEngineWidgets import QWebEngineView as QWebView - from qgis.PyQt.QtWidgets import QVBoxLayout, QWidget # project From 01431c8822f4bd19cd9cc585fe2c93dde1ca6bfe Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 1 Aug 2024 22:48:45 +0200 Subject: [PATCH 3/5] Update qtribu/logic/web_viewer.py Signed-off-by: Julien --- qtribu/logic/web_viewer.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qtribu/logic/web_viewer.py b/qtribu/logic/web_viewer.py index f2e314d0..ddf99613 100644 --- a/qtribu/logic/web_viewer.py +++ b/qtribu/logic/web_viewer.py @@ -17,8 +17,11 @@ from qgis.PyQt.QtCore import QCoreApplication, Qt from qgis.PyQt.QtGui import QDesktopServices -QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) -from qgis.PyQt.QtWebEngineWidgets import QWebEngineView as QWebView +try: + QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) + from qgis.PyQt.QtWebEngineWidgets import QWebEngineView as QWebView +except Exception: + from qgis.PyQt.QtWebKitWidgets import QWebView from qgis.PyQt.QtWidgets import QVBoxLayout, QWidget # project From 6d9f8f9298294d765b42a0be1afd1d2c2b1e3e6a Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Thu, 1 Aug 2024 22:49:56 +0200 Subject: [PATCH 4/5] fix(web_viewer): fix import order --- qtribu/logic/web_viewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qtribu/logic/web_viewer.py b/qtribu/logic/web_viewer.py index ddf99613..64ba3780 100644 --- a/qtribu/logic/web_viewer.py +++ b/qtribu/logic/web_viewer.py @@ -16,13 +16,13 @@ # PyQGIS from qgis.PyQt.QtCore import QCoreApplication, Qt from qgis.PyQt.QtGui import QDesktopServices +from qgis.PyQt.QtWidgets import QVBoxLayout, QWidget try: QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) from qgis.PyQt.QtWebEngineWidgets import QWebEngineView as QWebView except Exception: from qgis.PyQt.QtWebKitWidgets import QWebView -from qgis.PyQt.QtWidgets import QVBoxLayout, QWidget # project from qtribu.toolbelt import NetworkRequestsManager, PlgLogger, PlgOptionsManager From cef365927ef42517926b74cfcad7ab13036a611f Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Thu, 1 Aug 2024 22:51:22 +0200 Subject: [PATCH 5/5] change(imports): use absolute import instead of relative --- qtribu/logic/__init__.py | 1 - qtribu/toolbelt/commons.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/qtribu/logic/__init__.py b/qtribu/logic/__init__.py index 51ea86e4..f76fcbbb 100644 --- a/qtribu/logic/__init__.py +++ b/qtribu/logic/__init__.py @@ -2,4 +2,3 @@ from .custom_datatypes import RssItem # noqa: F401 from .rss_reader import RssMiniReader # noqa: F401 from .splash_changer import SplashChanger # noqa: F401 -from .web_viewer import WebViewer # noqa: F401 diff --git a/qtribu/toolbelt/commons.py b/qtribu/toolbelt/commons.py index b24c1e0f..0eea3d09 100644 --- a/qtribu/toolbelt/commons.py +++ b/qtribu/toolbelt/commons.py @@ -1,7 +1,7 @@ from qgis.PyQt.QtCore import QUrl from qgis.PyQt.QtGui import QDesktopServices -from qtribu.logic import WebViewer +from qtribu.logic.web_viewer import WebViewer web_viewer = WebViewer()