mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-08-17 01:29:44 +02:00
ui: add unique icon for applied tags in suggest box
This commit is contained in:
@@ -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"
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
+8
-2
@@ -34,7 +34,11 @@ Every step is keyboard-friendly, allowing for an efficient tagging "flow state"
|
||||
{ width=80% }
|
||||
<br>
|
||||
{ width=80% }
|
||||
<figcaption>Clicking "Add Tag" or pressing <kbd>Ctrl</kbd>+<kbd>T</kbd> replaces the "Add" buttons with a tag search bar. Pressing <kbd>Esc</kbd> (or <kbd>Enter</kbd> with a blank search) will close the bar and return the "Add" buttons.</figcaption>
|
||||
<figcaption>
|
||||
Clicking "Add Tag" or pressing <kbd>Ctrl</kbd>+<kbd>T</kbd> replaces the "Add" buttons with a tag search bar.
|
||||
<br>
|
||||
You can close the search by pressing <kbd>Enter</kbd> or clicking away (with a blank search), or at any time by pressing <kbd>Esc</kbd>.
|
||||
</figcaption>
|
||||
</figure>
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
@@ -64,7 +68,9 @@ Tags can be also viewed, created, edited, or deleted from the **Edit -> Manage T
|
||||
|
||||
Pressing <kbd>Enter</kbd> 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 <kbd>Enter</kbd>. 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 <kbd>Enter</kbd> 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 <kbd>Tab</kbd> or <kbd>Shift</kbd>+<kbd>Tab</kbd> to navigate right and left, respectively.
|
||||
|
||||
<figure markdown="span">
|
||||
{ width=80% }
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Reference in New Issue
Block a user