Skip to content

Commit

Permalink
Merge branch 'webengine2' into 'develop'
Browse files Browse the repository at this point in the history
Use QWebEngineView for Manual Panel (2nd attempt)

Closes taurus-org#1163

See merge request taurus-org/taurus!1213
  • Loading branch information
Carlos Pascual committed Aug 17, 2021
2 parents 7241851 + f1f8039 commit f94b712
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 17 deletions.
21 changes: 21 additions & 0 deletions lib/taurus/external/qt/QtWebEngine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
#
# Copyright © 2014-2015 Colin Duquesnoy
# Copyright © 2009- The Spyder Development Team
#
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)

"""
Provides QtWebEngine classes and functions.
"""

from . import PYQT5, PYSIDE2, PythonQtError


if PYQT5:
from PyQt5.QtWebEngine import * # noqa: F403,F401
elif PYSIDE2:
from PySide2.QtWebEngine import * # noqa: F403,F401
else:
raise PythonQtError("No Qt bindings could be found")
21 changes: 21 additions & 0 deletions lib/taurus/external/qt/QtWebEngineWidgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
#
# Copyright © 2014-2015 Colin Duquesnoy
# Copyright © 2009- The Spyder Development Team
#
# Licensed under the terms of the MIT License
# (see LICENSE.txt for details)

"""
Provides QtWebEngineWidgets classes and functions.
"""

from . import PYQT5, PYSIDE2, PythonQtError


if PYQT5:
from PyQt5.QtWebEngineWidgets import * # noqa: F403,F401
elif PYSIDE2:
from PySide2.QtWebEngineWidgets import * # noqa: F403,F401
else:
raise PythonQtError("No Qt bindings could be found")
2 changes: 2 additions & 0 deletions lib/taurus/external/test/test_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def setUp(self):
"QtSvg",
"QtUiTools",
"QtWebKit",
"QtWebEngine",
"QtWebEngineWidgets",
"uic",
)

Expand Down
30 changes: 13 additions & 17 deletions lib/taurus/qt/qtgui/container/taurusmainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@
from functools import partial

from taurus import tauruscustomsettings, Release
from taurus.core.util.log import deprecation_decorator
from taurus.core.util.log import deprecation_decorator, warning
from taurus.external.qt import Qt, compat

try:
from taurus.external.qt import QtWebEngineWidgets
except ImportError as e:
warning("ManualBrowser won't be available (%s)", e)
QtWebEngineWidgets = None
from .taurusbasecontainer import TaurusBaseContainer

from taurus.qt.qtcore.configuration import BaseConfigurableClass
Expand Down Expand Up @@ -1112,24 +1118,12 @@ def getQtDesignerPluginInfo(cls):
return None

def setHelpManualURI(self, uri):
if QtWebEngineWidgets is None:
return
self.__helpManualURI = uri
if self.helpManualBrowser is None:
try:
from taurus.external.qt.QtWebKit import QWebView

self.helpManualBrowser = QWebView()
except Exception:
self.helpManualBrowser = Qt.QLabel("QWebkit is not available")

def dummyload(*args):
pass

self.helpManualBrowser.load = dummyload
return
try:
url = Qt.QUrl.fromUserInput(uri)
except Exception:
url = Qt.QUrl(uri) # fallback for Qt<4.6
self.helpManualBrowser = QtWebEngineWidgets.QWebEngineView()
url = Qt.QUrl.fromUserInput(uri)
self.helpManualBrowser.load(url)

def getHelpManualURI(self):
Expand All @@ -1156,6 +1150,8 @@ def showHelpAbout(self):
def onShowManual(self, anchor=None):
"""Shows the User Manual in a dockwidget"""
if self.helpManualDW is None:
if QtWebEngineWidgets is None:
return
self.helpManualDW = Qt.QDockWidget("Manual", self)
self.helpManualDW.setWidget(self.helpManualBrowser)
self.helpManualDW.setObjectName("helpManualDW")
Expand Down

0 comments on commit f94b712

Please sign in to comment.