Skip to content

feat: Make the create tag panel have empty tag name field #592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
94061dc
[Feature Request]: Make the create tag panel have empty tag name field
yedpodtrzitko Nov 18, 2024
f9c7f5d
[Feature Request]: Make the create tag panel have empty tag name field
Cool-Game-Dev Nov 18, 2024
51f3649
Revert "[Feature Request]: Make the create tag panel have empty tag n…
Cool-Game-Dev Nov 18, 2024
e5df3e0
[Feature Request]: Make the create tag panel have empty tag name field
Cool-Game-Dev Nov 18, 2024
a887519
Revert "[Feature Request]: Make the create tag panel have empty tag n…
Cool-Game-Dev Nov 18, 2024
7b51500
Update .gitignore
Cool-Game-Dev Nov 18, 2024
4d3fc83
Updated as per disscussion in issue #591 (DRAFT
Cool-Game-Dev Nov 18, 2024
7e6a1d4
Updated as per disscussion in issue #591 (DRAFT
Cool-Game-Dev Nov 18, 2024
d0f47dc
Merge branch 'TagStudioDev:main' into main
Cool-Game-Dev Nov 18, 2024
7d53479
Added formatting
Cool-Game-Dev Nov 18, 2024
9ae9f05
Merge remote-tracking branch 'origin/main'
Cool-Game-Dev Nov 18, 2024
9695aff
Add formatting (Again)
Cool-Game-Dev Nov 18, 2024
80fda90
Merge remote-tracking branch 'origin/main'
Cool-Game-Dev Nov 18, 2024
8cdeba4
Call signals correctly (still doesnt work)
Cool-Game-Dev Nov 18, 2024
e66ce08
Merge remote-tracking branch 'origin/main'
Cool-Game-Dev Nov 18, 2024
e6a572b
Updated code as per discussion is #592
Cool-Game-Dev Nov 19, 2024
71d775c
Updated code as per discussion is #592 (again)
Cool-Game-Dev Nov 19, 2024
dc7c862
Fixed spacing
Cool-Game-Dev Nov 19, 2024
2d961e6
Add placeholder text to name field.
Cool-Game-Dev Nov 19, 2024
7d27ff2
Use universal red color for red border.
Cool-Game-Dev Nov 19, 2024
d72b4ea
fix: add `src.core.palette` imports
CyanVoxel Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion tagstudio/src/qt/modals/build_tag.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)
from src.core.library import Library, Tag
from src.core.library.alchemy.enums import TagColor
from src.core.palette import ColorType, get_tag_color
from src.core.palette import ColorType, UiColor, get_tag_color, get_ui_color
from src.qt.modals.tag_search import TagSearchPanel
from src.qt.widgets.panel import PanelModal, PanelWidget
from src.qt.widgets.tag import TagWidget
Expand Down Expand Up @@ -51,6 +51,9 @@ def __init__(self, library: Library, tag: Tag | None = None):
self.name_title.setText("Name")
self.name_layout.addWidget(self.name_title)
self.name_field = QLineEdit()
self.name_field.setFixedHeight(24)
self.name_field.textChanged.connect(self.on_name_changed)
self.name_field.setPlaceholderText("Tag Name (Required)")
self.name_layout.addWidget(self.name_field)

# Shorthand ------------------------------------------------------------
Expand Down Expand Up @@ -162,6 +165,8 @@ def __init__(self, library: Library, tag: Tag | None = None):
# TODO - fill subtags
self.subtags: set[int] = set()
self.set_tag(tag or Tag(name="New Tag"))
if tag is None:
self.name_field.selectAll()

def add_subtag_callback(self, tag_id: int):
logger.info("add_subtag_callback", tag_id=tag_id)
Expand Down Expand Up @@ -204,6 +209,18 @@ def set_tag(self, tag: Tag):

self.tag = tag

def on_name_changed(self):
is_empty = not self.name_field.text().strip()

self.name_field.setStyleSheet(
f"border: 1px solid {get_ui_color(ColorType.PRIMARY, UiColor.RED)}; border-radius: 2px"
if is_empty
else ""
)

if self.panel_save_button is not None:
self.panel_save_button.setDisabled(is_empty)

def build_tag(self) -> Tag:
color = self.color_field.currentData() or TagColor.DEFAULT

Expand Down
6 changes: 6 additions & 0 deletions tagstudio/src/qt/widgets/panel.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(
self.done_button.clicked.connect(self.hide)
if done_callback:
self.done_button.clicked.connect(done_callback)
self.widget.panel_done_button = self.done_button
self.button_layout.addWidget(self.done_button)

if save_callback or has_save:
Expand All @@ -62,13 +63,15 @@ def __init__(
self.cancel_button.clicked.connect(self.hide)
self.cancel_button.clicked.connect(widget.reset)
# self.cancel_button.clicked.connect(cancel_callback)
self.widget.panel_cancel_button = self.cancel_button
self.button_layout.addWidget(self.cancel_button)

self.save_button = QPushButton()
self.save_button.setText("Save")
self.save_button.setAutoDefault(True)
self.save_button.clicked.connect(self.hide)
self.save_button.clicked.connect(self.saved.emit)
self.widget.panel_save_button = self.save_button

if done_callback:
self.save_button.clicked.connect(done_callback)
Expand All @@ -93,6 +96,9 @@ class PanelWidget(QWidget):
"""Used for widgets that go in a modal panel, ex. for editing or searching."""

done = Signal()
panel_save_button: QPushButton | None = None
panel_cancel_button: QPushButton | None = None
panel_done_button: QPushButton | None = None

def __init__(self):
super().__init__()
Expand Down
Empty file modified tagstudio/src/qt/widgets/tag_box.py
100644 → 100755
Empty file.