From 75c59da65a1028e2caa3c48b247f99825c1b0b6c Mon Sep 17 00:00:00 2001 From: Matthias Metelka <62722460+kleinerpirat@users.noreply.github.com> Date: Wed, 23 Nov 2022 00:28:27 +0100 Subject: [PATCH] Add setting for browser row padding to preferences --- ftl/core/preferences.ftl | 2 ++ qt/aqt/browser/table/table.py | 5 ++-- qt/aqt/forms/preferences.ui | 49 ++++++++++++++++++++++++++++++++--- qt/aqt/preferences.py | 3 ++- qt/aqt/profiles.py | 6 +++++ 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/ftl/core/preferences.ftl b/ftl/core/preferences.ftl index 779dc4f70..7f5b382f8 100644 --- a/ftl/core/preferences.ftl +++ b/ftl/core/preferences.ftl @@ -48,3 +48,5 @@ preferences-monthly-backups = Monthly backups to keep: preferences-minutes-between-backups = Minutes between automatic backups: preferences-reduce-motion = Reduce motion preferences-reduce-motion-tooltip = Disable various animations and transitions of the user interface +preferences-browser-row-height = Browser row height +preferences-browser-row-height-tooltip = Adjust the padding (= amount of pixels between text and separator) of browser rows diff --git a/qt/aqt/browser/table/table.py b/qt/aqt/browser/table/table.py index b72a38c6e..16516e5d8 100644 --- a/qt/aqt/browser/table/table.py +++ b/qt/aqt/browser/table/table.py @@ -348,11 +348,12 @@ class Table: self._view.setWordWrap(False) self._view.setHorizontalScrollMode(QAbstractItemView.ScrollMode.ScrollPerPixel) self._view.horizontalScrollBar().setSingleStep(10) - self._view.verticalHeader().setDefaultSectionSize(12 + 2 * self.browser.mw.pm.browser_row_height()) + self._view.verticalHeader().setDefaultSectionSize( + 12 + 2 * self.browser.mw.pm.browser_row_height() + ) self._view.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) qconnect(self._view.customContextMenuRequested, self._on_context_menu) - def _setup_headers(self) -> None: vh = self._view.verticalHeader() hh = self._view.horizontalHeader() diff --git a/qt/aqt/forms/preferences.ui b/qt/aqt/forms/preferences.ui index af8c46fff..993fa4527 100644 --- a/qt/aqt/forms/preferences.ui +++ b/qt/aqt/forms/preferences.ui @@ -6,8 +6,8 @@ 0 0 - 640 - 640 + 530 + 660 @@ -150,6 +150,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -166,8 +179,22 @@ + + + + - + + + preferences_browser_row_height_tooltip + + + preferences_browser_row_height + + + + + Qt::Horizontal @@ -179,6 +206,19 @@ + + + + 6 + + + 18 + + + 8 + + + @@ -666,7 +706,7 @@ - + preferences_some_settings_will_take_effect_after @@ -699,6 +739,7 @@ useCurrent default_search_text uiScale + bRowHeight showEstimates showProgress dayLearnFirst diff --git a/qt/aqt/preferences.py b/qt/aqt/preferences.py index 9f485764b..9d44838ef 100644 --- a/qt/aqt/preferences.py +++ b/qt/aqt/preferences.py @@ -209,6 +209,7 @@ class Preferences(QDialog): "Setup options global to all profiles." self.form.reduce_motion.setChecked(self.mw.pm.reduced_motion()) self.form.uiScale.setValue(int(self.mw.pm.uiScale() * 100)) + self.form.bRowHeight.setValue(int(self.mw.pm.browser_row_height())) themes = [ tr.preferences_theme_label(theme=theme) for theme in ( @@ -237,8 +238,8 @@ class Preferences(QDialog): self.mw.pm.setUiScale(newScale) restart_required = True + self.mw.pm.set_browser_row_height(self.form.bRowHeight.value()) self.mw.pm.set_reduced_motion(self.form.reduce_motion.isChecked()) - self.mw.pm.set_legacy_import_export(self.form.legacy_import_export.isChecked()) if restart_required: diff --git a/qt/aqt/profiles.py b/qt/aqt/profiles.py index 8fea6442f..39c862ab4 100644 --- a/qt/aqt/profiles.py +++ b/qt/aqt/profiles.py @@ -581,6 +581,12 @@ create table if not exists profiles def set_last_loaded_profile_name(self, name: str) -> None: self.meta["last_loaded_profile_name"] = name + def set_browser_row_height(self, height: int) -> None: + self.meta["browser_row_height"] = height + + def browser_row_height(self) -> int: + return self.meta.get("browser_row_height", 8) + # Profile-specific ######################################################################