diff --git a/REUSE.toml b/REUSE.toml index 1d39078d..93f80ffe 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -50,6 +50,7 @@ path = [ "src/tagstudio/resources/qt/images/hint_field_add.png", "src/tagstudio/resources/qt/images/hint_field_create.png", "src/tagstudio/resources/qt/images/hint_tag_add.png", + "src/tagstudio/resources/qt/images/hint_tag_added.png", "src/tagstudio/resources/qt/images/hint_tag_create.png", ] SPDX-FileCopyrightText = "(c) github:google/material-design-icons Contributors" diff --git a/docs/assets/tag_field_bars/tag_bar_search_match_greyed.png b/docs/assets/tag_field_bars/tag_bar_search_match_greyed.png index 1921730a..0d1077d5 100644 Binary files a/docs/assets/tag_field_bars/tag_bar_search_match_greyed.png and b/docs/assets/tag_field_bars/tag_bar_search_match_greyed.png differ diff --git a/docs/usage.md b/docs/usage.md index 801b765e..f0200a01 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -34,7 +34,11 @@ Every step is keyboard-friendly, allowing for an efficient tagging "flow state" ![Empty File Entry](assets/tag_field_bars/add_buttons_normal.png){ width=80% }
![Empty File Entry](assets/tag_field_bars/tag_bar_empty.png){ width=80% } -
Clicking "Add Tag" or pressing Ctrl+T replaces the "Add" buttons with a tag search bar. Pressing Esc (or Enter with a blank search) will close the bar and return the "Add" buttons.
+
+ Clicking "Add Tag" or pressing Ctrl+T replaces the "Add" buttons with a tag search bar. +
+ You can close the search by pressing Enter or clicking away (with a blank search), or at any time by pressing Esc. +
@@ -64,7 +68,9 @@ Tags can be also viewed, created, edited, or deleted from the **Edit -> Manage T Pressing Enter with **one or more results** will **apply** :material-tag: the underlined tag to your selection (assuming it's not already on your selection). -Tags that are already present on your entries will be greyed out and ignored when pressing Enter. This lets you visually confirm that a tag already exists and has been applied to the selection. +Matching tags that are **already applied** :material-tag-check: to your entries will be greyed out placed at the end of the autofill results. This lets you visually confirm that a tag already exists and has been applied to the selection. Applying them again with Enter has no effect other than closing the search. + +You can navigate the list of autofill suggestions using the scroll wheel, and change the selected tag by pressing Tab or Shift+Tab to navigate right and left, respectively.
![Empty File Entry](assets/tag_field_bars/tag_bar_search_match.png){ width=80% } diff --git a/src/tagstudio/qt/controllers/suggest_box.py b/src/tagstudio/qt/controllers/suggest_box.py index c3a7c6f1..66e74e46 100644 --- a/src/tagstudio/qt/controllers/suggest_box.py +++ b/src/tagstudio/qt/controllers/suggest_box.py @@ -160,6 +160,7 @@ class SuggestBox[T](QWidget): ) else: underlined_widget.toggle_underline(is_hidden=True) + self._update_hint_icon() def _clear_search_query(self) -> None: self.layout().search_field.setText("") @@ -168,8 +169,8 @@ class SuggestBox[T](QWidget): raise NotImplementedError() def _on_search_query_changed(self, query: str) -> None: - self._update_hint_icon() self._update_items(query.strip()) + self._update_hint_icon() def _on_search_query_submitted(self, query: str, always_create: bool = False) -> None: # Focus search field if no query @@ -200,6 +201,12 @@ class SuggestBox[T](QWidget): def _is_excluded(self, item: T) -> bool: return _item_id(item) in self.excluded + def _is_selected_item_added(self) -> bool: + return bool( + len(self._search_results) > self._selection_index + and _item_id(self._search_results[self._selection_index]) in self.added + ) + def _update_hint_icon(self) -> None: raise NotImplementedError() diff --git a/src/tagstudio/qt/controllers/tag_suggest_box.py b/src/tagstudio/qt/controllers/tag_suggest_box.py index e9538d37..b14540fd 100644 --- a/src/tagstudio/qt/controllers/tag_suggest_box.py +++ b/src/tagstudio/qt/controllers/tag_suggest_box.py @@ -93,7 +93,10 @@ class TagSuggestBox(SuggestBox[Tag]): @override def _on_shift_held(self, held: bool) -> None: - if held: + # Bypass normal _update_hint_icon() behavior first + if not held and self._is_selected_item_added(): + self.set_hint_icon(self._rm.hint_tag_added) + elif held: self.set_hint_icon(self._rm.hint_tag_create) else: self._update_hint_icon() @@ -102,7 +105,11 @@ class TagSuggestBox(SuggestBox[Tag]): @override def _update_hint_icon(self) -> None: - if self.layout().search_field.text() and len(self._search_results) > 0: + results = bool(len(self._search_results) > 0) + + if results and self._is_selected_item_added(): + self.set_hint_icon(self._rm.hint_tag_added) + elif results: self.set_hint_icon(self._rm.hint_tag_add) elif self.layout().search_field.text(): self.set_hint_icon(self._rm.hint_tag_create) @@ -135,7 +142,7 @@ class TagSuggestBox(SuggestBox[Tag]): if item is None: return - # TODO: Add tabbing to different items, and use underline to indicate which will be added + # Select first item underlined_widget.toggle_underline(index != 0) # Disconnect previous callbacks diff --git a/src/tagstudio/qt/resource_manager.pyi b/src/tagstudio/qt/resource_manager.pyi index 46e6ca58..6ff32496 100644 --- a/src/tagstudio/qt/resource_manager.pyi +++ b/src/tagstudio/qt/resource_manager.pyi @@ -39,6 +39,7 @@ class ResourceManager: hint_field_add: Image.Image hint_field_create: Image.Image hint_tag_add: Image.Image + hint_tag_added: Image.Image hint_tag_create: Image.Image icon: Image.Image ignored_stat: Image.Image diff --git a/src/tagstudio/qt/resources.json b/src/tagstudio/qt/resources.json index 3fbdefba..7568ca53 100644 --- a/src/tagstudio/qt/resources.json +++ b/src/tagstudio/qt/resources.json @@ -83,6 +83,10 @@ "mode": "pil", "path": "qt/images/hint_tag_add.png" }, + "hint_tag_added": { + "mode": "pil", + "path": "qt/images/hint_tag_added.png" + }, "hint_tag_create": { "mode": "pil", "path": "qt/images/hint_tag_create.png" diff --git a/src/tagstudio/resources/qt/images/hint_tag_added.png b/src/tagstudio/resources/qt/images/hint_tag_added.png new file mode 100644 index 00000000..652930c3 Binary files /dev/null and b/src/tagstudio/resources/qt/images/hint_tag_added.png differ