Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround crash on mac platform with non-default themes #282

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions koordinates/gui/date_filter_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
20 changes: 20 additions & 0 deletions koordinates/gui/range_slider.py
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 2 additions & 2 deletions koordinates/gui/resolution_filter_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)

Expand Down
Loading