Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web_viewer): switch from QtWebKit to QtWebEngine #186

Merged
merged 5 commits into from
Aug 1, 2024

Conversation

lbartoletti
Copy link
Contributor

As discussed in #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.

Tested on FreeBSD and Windows (Osgeo4w). PyQt with QtWebEngine must be installed.

cc @kikislater

As discussed in geotribu#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.
@lbartoletti lbartoletti requested a review from Guts July 31, 2024 11:49
@lbartoletti lbartoletti self-assigned this Jul 31, 2024
Copy link

codecov bot commented Jul 31, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 14.39%. Comparing base (fffdbbe) to head (cef3659).
Report is 140 commits behind head on main.

Files Patch % Lines
qtribu/logic/web_viewer.py 0.00% 4 Missing ⚠️
qtribu/toolbelt/commons.py 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #186      +/-   ##
==========================================
- Coverage   21.52%   14.39%   -7.14%     
==========================================
  Files          17       21       +4     
  Lines         734     1091     +357     
  Branches       76      140      +64     
==========================================
- Hits          158      157       -1     
- Misses        575      933     +358     
  Partials        1        1              
Files Coverage Δ
qtribu/logic/__init__.py 100.00% <ø> (ø)
qtribu/toolbelt/commons.py 0.00% <0.00%> (ø)
qtribu/logic/web_viewer.py 0.00% <0.00%> (-36.12%) ⬇️

@Guts
Copy link
Member

Guts commented Jul 31, 2024

Salut @lbartoletti, sur Ubuntu 22.04, le plugin fait planter QGIS LTR (dépôts officiels) alors que ça ne plante pas sur master.

La trace :

ModuleNotFoundError: No module named 'qgis.PyQt.QtWebEngineWidgets' 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 423, in _startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "/home/jmo/Git/Geotribu/qtribu/qtribu/__init__.py", line 21, in classFactory
    from .plugin_main import GeotribuPlugin
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 892, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jmo/Git/Geotribu/qtribu/qtribu/plugin_main.py", line 21, in 
    from qtribu.gui.dlg_contents import GeotribuContentsDialog
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 892, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jmo/Git/Geotribu/qtribu/qtribu/gui/dlg_contents.py", line 17, in 
    from qtribu.gui.form_article import ArticleForm
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 892, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jmo/Git/Geotribu/qtribu/qtribu/gui/form_article.py", line 22, in 
    from qtribu.toolbelt.commons import open_url_in_browser
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 892, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jmo/Git/Geotribu/qtribu/qtribu/toolbelt/commons.py", line 4, in 
    from qtribu.logic import WebViewer
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 892, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jmo/Git/Geotribu/qtribu/qtribu/logic/__init__.py", line 5, in 
    from .web_viewer import WebViewer  # noqa: F401
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 892, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jmo/Git/Geotribu/qtribu/qtribu/logic/web_viewer.py", line 21, in 
    from qgis.PyQt.QtWebEngineWidgets import QWebEngineView as QWebView
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 892, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'qgis.PyQt.QtWebEngineWidgets'

PyQt with QtWebEngine must be installed.

Quelle est la commande d'install sur Debian et ubuntu ?

@Guts
Copy link
Member

Guts commented Jul 31, 2024

sudo apt install qtwebengine5

?

@lbartoletti
Copy link
Contributor Author

sudo apt install qtwebengine5

?

Certainement, quelque chose comme python3-pyqt5.qtwebengine ou 6 pour Qt6

@kikislater
Copy link
Contributor

kikislater commented Jul 31, 2024

sudo apt install qtwebengine5

?

Certainement, quelque chose comme python3-pyqt5.qtwebengine ou 6 pour Qt6

C'est celui là le bon oui

qtribu/logic/web_viewer.py Outdated Show resolved Hide resolved
@Guts Guts added the bug Houston, we've got a problem... label Aug 1, 2024
Copy link

sonarcloud bot commented Aug 1, 2024

@Guts Guts merged commit d143a74 into geotribu:main Aug 1, 2024
10 checks passed
@lbartoletti lbartoletti deleted the fix_QWebView branch August 2, 2024 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Houston, we've got a problem...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants