From 6e288afd8c153667f8520dc94872650f2616f291 Mon Sep 17 00:00:00 2001 From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com> Date: Fri, 14 Aug 2026 08:49:35 -0700 Subject: [PATCH] refactor: consolidate added item detection on shift --- src/tagstudio/qt/controllers/suggest_box.py | 5 ++++- .../qt/controllers/tag_suggest_box.py | 21 +------------------ 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/tagstudio/qt/controllers/suggest_box.py b/src/tagstudio/qt/controllers/suggest_box.py index 5dccd023..faf35795 100644 --- a/src/tagstudio/qt/controllers/suggest_box.py +++ b/src/tagstudio/qt/controllers/suggest_box.py @@ -119,7 +119,10 @@ class SuggestBox[T](QWidget): opacity_effect = QGraphicsOpacityEffect(self) opacity_effect.setOpacity(0.3) underlined_widget.widget.setGraphicsEffect(opacity_effect) - else: + elif ( + len(self._search_results) > i + and _item_id(self._search_results[i]) not in self.added + ): self._is_shift_held = False underlined_widget.widget.setGraphicsEffect(None) # pyright: ignore[reportArgumentType] diff --git a/src/tagstudio/qt/controllers/tag_suggest_box.py b/src/tagstudio/qt/controllers/tag_suggest_box.py index 19b4eb0d..e9538d37 100644 --- a/src/tagstudio/qt/controllers/tag_suggest_box.py +++ b/src/tagstudio/qt/controllers/tag_suggest_box.py @@ -98,26 +98,7 @@ class TagSuggestBox(SuggestBox[Tag]): else: self._update_hint_icon() - # NOTE: This code is similar to the base method, but needs to reference the tag IDs for each - # widget and compare those against the self.added list. - for i in range(0, self.layout().content_layout.count()): - underlined_widget = self.layout().content_layout.itemAt(i).widget() - assert isinstance(underlined_widget, UnderlinedWidget) - - if held and i == self._selection_index: - self._is_shift_held = True - opacity_effect = QGraphicsOpacityEffect(self) - opacity_effect.setOpacity(0.3) - underlined_widget.widget.setGraphicsEffect(opacity_effect) - else: - tag_widget = underlined_widget.widget - if not isinstance(tag_widget, TagWidget): - return - if not tag_widget.tag: - return - if tag_widget.tag.id not in self.added: - self._is_shift_held = False - underlined_widget.widget.setGraphicsEffect(None) # pyright: ignore[reportArgumentType] + return super()._on_shift_held(held) @override def _update_hint_icon(self) -> None: