diff --git a/koordinates/gui/date_filter_widget.py b/koordinates/gui/date_filter_widget.py index 4164604..54cf8b9 100644 --- a/koordinates/gui/date_filter_widget.py +++ b/koordinates/gui/date_filter_widget.py @@ -14,12 +14,12 @@ QSizePolicy ) from qgis.gui import ( - QgsRangeSlider, QgsDateEdit ) from .filter_widget_combo_base import FilterWidgetComboBase from ..api import DataBrowserQuery +from .range_slider import RangeSlider DATE_FORMAT = 'dd MMM yyyy' @@ -66,7 +66,7 @@ def __init__(self, parent): published_date_label.setFont(bold_font) vl.addWidget(published_date_label) - self.published_date_slider = QgsRangeSlider() + self.published_date_slider = RangeSlider() self.published_date_slider.setMinimumHeight(self.fontMetrics().height()) vl.addWidget(self.published_date_slider) @@ -94,7 +94,7 @@ def __init__(self, parent): updated_date_label.setFont(bold_font) vl.addWidget(updated_date_label) - self.updated_date_slider = QgsRangeSlider() + self.updated_date_slider = RangeSlider() self.updated_date_slider.setMinimumHeight(self.fontMetrics().height()) vl.addWidget(self.updated_date_slider) diff --git a/koordinates/gui/range_slider.py b/koordinates/gui/range_slider.py new file mode 100644 index 0000000..d4e2c71 --- /dev/null +++ b/koordinates/gui/range_slider.py @@ -0,0 +1,20 @@ +import platform +from qgis.PyQt.QtCore import QSize +from qgis.gui import QgsRangeSlider + + +class RangeSlider(QgsRangeSlider): + """ + Avoids a crash when non-standard application themes are used on the + mac platform. + + Relates to https://bugreports.qt.io/browse/QTBUG-43398 + https://bugreports.qt.io/browse/QTBUG-44316?focusedCommentId=272257 + """ + + def sizeHint(self): + if platform.system() == 'Darwin': + # sizeHint crashes on mac for hidden QSlider widgets + return QSize(100, 30) + + return super().sizeHint() diff --git a/koordinates/gui/resolution_filter_widget.py b/koordinates/gui/resolution_filter_widget.py index 9492697..d411195 100644 --- a/koordinates/gui/resolution_filter_widget.py +++ b/koordinates/gui/resolution_filter_widget.py @@ -6,10 +6,10 @@ QHBoxLayout, QLabel ) -from qgis.gui import QgsRangeSlider from .filter_widget_combo_base import FilterWidgetComboBase from ..api import DataBrowserQuery +from .range_slider import RangeSlider class ResolutionFilterWidget(FilterWidgetComboBase): @@ -22,7 +22,7 @@ def __init__(self, parent): self.drop_down_widget = QWidget() vl = QVBoxLayout() - self.slider = QgsRangeSlider() + self.slider = RangeSlider() self.slider.setMinimumHeight(self.fontMetrics().height()) vl.addWidget(self.slider)