|
18 | 18 | ) |
19 | 19 | from src.core.library import Library, Tag |
20 | 20 | from src.core.library.alchemy.enums import TagColor |
21 | | -from src.core.palette import ColorType, get_tag_color |
| 21 | +from src.core.palette import ColorType, UiColor, get_tag_color, get_ui_color |
22 | 22 | from src.qt.modals.tag_search import TagSearchPanel |
23 | 23 | from src.qt.widgets.panel import PanelModal, PanelWidget |
24 | 24 | from src.qt.widgets.tag import TagWidget |
@@ -51,6 +51,9 @@ def __init__(self, library: Library, tag: Tag | None = None): |
51 | 51 | self.name_title.setText("Name") |
52 | 52 | self.name_layout.addWidget(self.name_title) |
53 | 53 | self.name_field = QLineEdit() |
| 54 | + self.name_field.setFixedHeight(24) |
| 55 | + self.name_field.textChanged.connect(self.on_name_changed) |
| 56 | + self.name_field.setPlaceholderText("Tag Name (Required)") |
54 | 57 | self.name_layout.addWidget(self.name_field) |
55 | 58 |
|
56 | 59 | # Shorthand ------------------------------------------------------------ |
@@ -162,6 +165,8 @@ def __init__(self, library: Library, tag: Tag | None = None): |
162 | 165 | # TODO - fill subtags |
163 | 166 | self.subtags: set[int] = set() |
164 | 167 | self.set_tag(tag or Tag(name="New Tag")) |
| 168 | + if tag is None: |
| 169 | + self.name_field.selectAll() |
165 | 170 |
|
166 | 171 | def add_subtag_callback(self, tag_id: int): |
167 | 172 | logger.info("add_subtag_callback", tag_id=tag_id) |
@@ -204,6 +209,18 @@ def set_tag(self, tag: Tag): |
204 | 209 |
|
205 | 210 | self.tag = tag |
206 | 211 |
|
| 212 | + def on_name_changed(self): |
| 213 | + is_empty = not self.name_field.text().strip() |
| 214 | + |
| 215 | + self.name_field.setStyleSheet( |
| 216 | + f"border: 1px solid {get_ui_color(ColorType.PRIMARY, UiColor.RED)}; border-radius: 2px" |
| 217 | + if is_empty |
| 218 | + else "" |
| 219 | + ) |
| 220 | + |
| 221 | + if self.panel_save_button is not None: |
| 222 | + self.panel_save_button.setDisabled(is_empty) |
| 223 | + |
207 | 224 | def build_tag(self) -> Tag: |
208 | 225 | color = self.color_field.currentData() or TagColor.DEFAULT |
209 | 226 |
|
|
0 commit comments