Skip to content

Commit

Permalink
Make sure map tips are not shown if QtWebKit is not installed (if tha…
Browse files Browse the repository at this point in the history
…t's the case, disable map tips and its correspondant widget, showing a nice tooltip)
  • Loading branch information
gacarrillor committed May 20, 2024
1 parent 27a4b03 commit c983799
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions swiss_locator/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
5 changes: 5 additions & 0 deletions swiss_locator/gui/config_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions swiss_locator/gui/maptip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c983799

Please sign in to comment.