Skip to content

Commit

Permalink
Use QDesktopServices instead of deprecated iface.openUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts authored and nyalldawson committed Jan 11, 2021
1 parent d82ff4b commit 05d836b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions python/utils.py
Expand Up @@ -26,7 +26,8 @@
"""

from qgis.PyQt.QtCore import QCoreApplication, QLocale, QThread, qDebug
from qgis.PyQt.QtCore import QCoreApplication, QLocale, QThread, qDebug, QUrl
from qgis.PyQt.QtGui import QDesktopServices
from qgis.PyQt.QtWidgets import QPushButton, QApplication
from qgis.core import Qgis, QgsMessageLog, qgsfunction, QgsMessageOutput
from qgis.gui import QgsMessageBar
Expand Down Expand Up @@ -499,8 +500,13 @@ def reloadPlugin(packageName):
startPlugin(packageName)


def showPluginHelp(packageName=None, filename="index", section=""):
""" show a help in the user's html browser. The help file should be named index-ll_CC.html or index-ll.html"""
def showPluginHelp(packageName: str = None, filename: str = "index", section: str = ""):
"""Open help in the user's html browser. The help file should be named index-ll_CC.html or index-ll.html or index.html.
:param str packageName: name of package folder, if None it's using the current file package. Defaults to None. Optional.
:param str filename: name of file to open. It can be a path like 'doc/index' for example. Defaults to 'index'.
:param str section: URL path to open. Defaults to empty string.
"""
try:
source = ""
if packageName is None:
Expand All @@ -526,7 +532,7 @@ def showPluginHelp(packageName=None, filename="index", section=""):
url = "file://" + helpfile
if section != "":
url = url + "#" + section
iface.openURL(url, False)
QDesktopServices.openUrl .openUrl(url, False)


def pluginDirectory(packageName):
Expand Down

0 comments on commit 05d836b

Please sign in to comment.