3
3
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
4
4
5
5
6
+ import typing
7
+
6
8
import src .qt .modals .build_tag as build_tag
7
9
import structlog
8
10
from PySide6 .QtCore import QSize , Qt , Signal
32
34
33
35
logger = structlog .get_logger (__name__ )
34
36
37
+ # Only import for type checking/autocompletion, will not be imported at runtime.
38
+ if typing .TYPE_CHECKING :
39
+ from src .qt .modals .build_tag import BuildTagPanel
40
+
35
41
36
42
class TagSearchPanel (PanelWidget ):
37
43
tag_chosen = Signal (int )
@@ -41,7 +47,12 @@ class TagSearchPanel(PanelWidget):
41
47
is_tag_chooser : bool
42
48
exclude : list [int ]
43
49
44
- def __init__ (self , library : Library , exclude : list [int ] = None , is_tag_chooser : bool = True ):
50
+ def __init__ (
51
+ self ,
52
+ library : Library ,
53
+ exclude : list [int ] = None ,
54
+ is_tag_chooser : bool = True ,
55
+ ):
45
56
super ().__init__ ()
46
57
self .lib = library
47
58
self .exclude = exclude or []
@@ -93,6 +104,17 @@ def __build_row_item_widget(self, tag: Tag):
93
104
94
105
tag_widget .on_edit .connect (lambda t = tag : self .edit_tag (t ))
95
106
tag_widget .on_remove .connect (lambda t = tag : self .remove_tag (t ))
107
+
108
+ # NOTE: A solution to this would be to pass the driver to TagSearchPanel, however that
109
+ # creates an exponential amount of work trying to fix the preexisting tests.
110
+
111
+ # tag_widget.search_for_tag_action.triggered.connect(
112
+ # lambda checked=False, tag_id=tag.id: (
113
+ # self.driver.main_window.searchField.setText(f"tag_id:{tag_id}"),
114
+ # self.driver.filter_items(FilterState.from_tag_id(tag_id)),
115
+ # )
116
+ # )
117
+
96
118
row .addWidget (tag_widget )
97
119
98
120
primary_color = get_primary_color (tag )
@@ -196,7 +218,7 @@ def on_tag_modal_saved():
196
218
self .search_field .setText ("" )
197
219
self .update_tags ()
198
220
199
- self .build_tag_modal : build_tag . BuildTagPanel = build_tag .BuildTagPanel (self .lib )
221
+ self .build_tag_modal : BuildTagPanel = build_tag .BuildTagPanel (self .lib )
200
222
self .add_tag_modal : PanelModal = PanelModal (self .build_tag_modal , has_save = True )
201
223
Translations .translate_with_setter (self .add_tag_modal .setTitle , "tag.new" )
202
224
Translations .translate_with_setter (self .add_tag_modal .setWindowTitle , "tag.add" )
0 commit comments