From 03b05b6a06af6fe0e4910e2a0b44e281720c008a Mon Sep 17 00:00:00 2001 From: Abdo Date: Tue, 28 Feb 2023 05:23:34 +0300 Subject: [PATCH] Add a button in the preferences to reset window sizes (#2405) * Add a button in the preferences to reset window sizes * Add post-reset pop-up so the user knows something's happened (dae) --- ftl/core/preferences.ftl | 2 ++ qt/aqt/forms/preferences.ui | 29 ++++++++++++++++++----------- qt/aqt/preferences.py | 8 ++++++++ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ftl/core/preferences.ftl b/ftl/core/preferences.ftl index 4ebb21585..a2555992f 100644 --- a/ftl/core/preferences.ftl +++ b/ftl/core/preferences.ftl @@ -68,6 +68,8 @@ preferences-scheduler = Scheduler preferences-user-interface = User Interface preferences-import-export = Import/Export preferences-network-timeout = Network timeout +preferences-reset-window-sizes = Reset Window Sizes +preferences-reset-window-sizes-complete = Window sizes and locations have been reset. ## NO NEED TO TRANSLATE. This text is no longer used by Anki, and will be removed in the future. diff --git a/qt/aqt/forms/preferences.ui b/qt/aqt/forms/preferences.ui index 8803b82ce..fc2600a34 100644 --- a/qt/aqt/forms/preferences.ui +++ b/qt/aqt/forms/preferences.ui @@ -85,13 +85,6 @@ preferences_user_interface - - - - - - - @@ -111,10 +104,10 @@ - - - - preferences_user_interface_size + + + + @@ -132,6 +125,20 @@ + + + + preferences_user_interface_size + + + + + + + preferences_reset_window_sizes + + + diff --git a/qt/aqt/preferences.py b/qt/aqt/preferences.py index 5fa3da198..7061ac5cf 100644 --- a/qt/aqt/preferences.py +++ b/qt/aqt/preferences.py @@ -276,6 +276,7 @@ class Preferences(QDialog): self.form.styleLabel.setVisible(not is_win) self.form.styleComboBox.setVisible(not is_win) self.form.legacy_import_export.setChecked(self.mw.pm.legacy_import_export()) + qconnect(self.form.resetWindowSizes.clicked, self.on_reset_window_sizes) self.setup_language() self.setup_video_driver() @@ -302,6 +303,13 @@ class Preferences(QDialog): def on_theme_changed(self, index: int) -> None: self.mw.set_theme(Theme(index)) + def on_reset_window_sizes(self) -> None: + suffixes = ["Geom", "State", "Splitter"] + for key in list(self.prof.keys()): + if any(key.endswith(suffix) for suffix in suffixes): + del self.prof[key] + showInfo(tr.preferences_reset_window_sizes_complete()) + # legacy - one of Henrik's add-ons is currently wrapping them def setupOptions(self) -> None: