diff --git a/swiss_locator/core/settings.py b/swiss_locator/core/settings.py index c2889a6..a1b75df 100644 --- a/swiss_locator/core/settings.py +++ b/swiss_locator/core/settings.py @@ -103,3 +103,5 @@ def __init__(self): self.add_setting(Stringlist("feature_search_layers_list", Scope.Global, None)) self.add_setting(Bool("layers_include_opendataswiss", Scope.Global, True)) + + self.add_setting(Bool("with_qtwebkit", Scope.Global, True)) diff --git a/swiss_locator/gui/config_dialog.py b/swiss_locator/gui/config_dialog.py index 32abfe1..5939e81 100644 --- a/swiss_locator/gui/config_dialog.py +++ b/swiss_locator/gui/config_dialog.py @@ -97,6 +97,11 @@ def __init__(self, parent=None): self.settings = settings self.init_widgets() + if not settings.value("with_qtwebkit"): + map_tip = self.setting_widget("show_map_tip") + map_tip.widget.setEnabled(False) + map_tip.widget.setToolTip(self.tr("You need to install QtWebKit to use map tips.")) + def select_all(self, select: bool = True): for r in range(self.feature_search_layers_list.rowCount()): item = self.feature_search_layers_list.item(r, 0) diff --git a/swiss_locator/gui/maptip.py b/swiss_locator/gui/maptip.py index f1e24db..57ed4e6 100644 --- a/swiss_locator/gui/maptip.py +++ b/swiss_locator/gui/maptip.py @@ -22,8 +22,17 @@ """ from PyQt5.QtCore import Qt, QPoint, pyqtSignal -from PyQt5.QtWebKit import QWebSettings -from PyQt5.QtWebKitWidgets import QWebView, QWebPage +try: + from PyQt5.QtWebKit import QWebSettings + from PyQt5.QtWebKitWidgets import QWebView, QWebPage +except ModuleNotFoundError: + from swiss_locator.core.settings import Settings + settings = Settings() + settings.set_value("show_map_tip", False) + settings.set_value("with_qtwebkit", False) +else: + from swiss_locator.core.settings import Settings + Settings().set_value("with_qtwebkit", True) from PyQt5.QtWidgets import QSizePolicy, QDockWidget from PyQt5.QtGui import QPalette, QDesktopServices, QCloseEvent from qgis.core import Qgis, QgsPointXY, QgsMessageLog