From 5691bd84bdce93e07b16183ac003f45b444c4b50 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 14 Sep 2023 13:49:45 +1000 Subject: [PATCH] Drop font size in compact layout mode --- koordinates/gui/dataset_browser_items.py | 51 ++++++++++++++++-------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/koordinates/gui/dataset_browser_items.py b/koordinates/gui/dataset_browser_items.py index bf323b4..304594b 100644 --- a/koordinates/gui/dataset_browser_items.py +++ b/koordinates/gui/dataset_browser_items.py @@ -597,29 +597,14 @@ def __init__(self, title_layout.addWidget(self.title_label, 1) self.dataset_layout.set_title_layout(title_layout) - main_title_size = 11 - title_font_size = 11 detail_font_size = 9 if platform.system() == 'Darwin': # fonts looks smaller on a mac, where things "just work" :P - main_title_size = 14 - title_font_size = 14 detail_font_size = 10 elif font_scale > 1: - main_title_size = int(12 / font_scale) - title_font_size = int(12 / font_scale) detail_font_size = int(10 / font_scale) - publisher_name = self.dataset.publisher().name() if \ - self.dataset.publisher() else '' - self.title_label.setText( - f"""

{self.dataset.title()}
""" - f"""{publisher_name}

""" - ) + self._update_title() license = self.dataset.details.get('license') self.license_label = None @@ -702,6 +687,38 @@ def __init__(self, self.set_column_count(column_count) + def _update_title(self): + arrangement = self.dataset_layout.arrangement() + try: + font_scale = self.screen().logicalDotsPerInch() / 92 + except AttributeError: + # requires Qt 5.14+ + font_scale = 1 + + main_title_size = 11 if arrangement != CardLayout.Compact else 10 + title_font_size = 11 if arrangement != CardLayout.Compact else 10 + if platform.system() == 'Darwin': + # fonts looks smaller on a mac, where things "just work" :P + main_title_size = 14 if arrangement != CardLayout.Compact else 12 + title_font_size = 14 if arrangement != CardLayout.Compact else 12 + elif font_scale > 1: + main_title_size = int(12 / font_scale) if arrangement != CardLayout.Compact else int(11 / font_scale) + title_font_size = int(12 / font_scale) if arrangement != CardLayout.Compact else int(11 / font_scale) + + publisher_name = self.dataset.publisher().name() if \ + self.dataset.publisher() else '' + self.title_label.setText( + f"""

{self.dataset.title()}
""" + f"""{publisher_name}

""" + ) + + def _update_arrangement(self): + self._update_title() + def set_column_count(self, count: int): if count == self.column_count: return @@ -713,6 +730,7 @@ def set_column_count(self, count: int): self.defer_update_thumbnail() self.old_arrangement = arrangement + self._update_arrangement() def defer_update_thumbnail(self): if self.timer is not None: @@ -924,6 +942,7 @@ def resizeEvent(self, event): self.defer_update_thumbnail() self.old_arrangement = arrangement + self._update_arrangement() def mousePressEvent(self, event): if event.button() == Qt.LeftButton: