From 53a8622020524f1543121e4a8d0aca05e72451bf Mon Sep 17 00:00:00 2001 From: pax Date: Sat, 11 Apr 2026 22:20:46 -0500 Subject: [PATCH] main_window: preserve tab selection on switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tab switch previously cleared all grid selections and nulled _current_post, losing the user's place and leaving toolbar actions dead. Now only clears the other tabs' selections — the target tab keeps its selection so switching back and forth preserves state. behavior change: switching tabs no longer clears the current tab's grid selection or preview post. --- booru_viewer/gui/main_window.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/booru_viewer/gui/main_window.py b/booru_viewer/gui/main_window.py index bdd1472..ac256c7 100644 --- a/booru_viewer/gui/main_window.py +++ b/booru_viewer/gui/main_window.py @@ -585,23 +585,18 @@ class BooruApp(QMainWindow): # them again is meaningless. Disabling the QAction also disables # its keyboard shortcut. self._batch_action.setEnabled(index == 0) - # Clear grid selections and current post to prevent cross-tab action conflicts - # Preview media stays visible but actions are disabled until a new post is selected - self._grid.clear_selection() - self._bookmarks_view._grid.clear_selection() - self._library_view._grid.clear_selection() - self._preview._current_post = None - self._preview._current_site_id = None + # Clear other tabs' selections to prevent cross-tab action + # conflicts (B/S keys acting on a stale selection from another + # tab). The target tab keeps its selection so the user doesn't + # lose their place when switching back and forth. + if index != 0: + self._grid.clear_selection() + if index != 1: + self._bookmarks_view._grid.clear_selection() + if index != 2: + self._library_view._grid.clear_selection() is_library = index == 2 self._preview.update_bookmark_state(False) - # On the library tab the Save button is the only toolbar action - # left visible (Bookmark / BL Tag / BL Post are hidden a few lines - # down). Library files are saved by definition, so the button - # should read "Unsave" the entire time the user is in that tab — - # forcing the state to True here makes that true even before the - # user clicks anything (the toolbar might already be showing old - # media from the previous tab; this is fine because the same media - # is also in the library if it was just saved). self._preview.update_save_state(is_library) # Show/hide preview toolbar buttons per tab self._preview._bookmark_btn.setVisible(not is_library)