Categorized blacklist tag submenu in right-click context

Blacklist Tag submenu now shows Artist/Character/Copyright/General/Meta
categories for Danbooru/e621. Falls back to flat list for other sites.
This commit is contained in:
pax 2026-04-04 21:39:20 -05:00
parent 8f2fc14b43
commit 6554344523

View File

@ -1027,7 +1027,13 @@ class BooruApp(QMainWindow):
fav_action = menu.addAction("Unfavorite" if self._is_current_favorited(index) else "Favorite") fav_action = menu.addAction("Unfavorite" if self._is_current_favorited(index) else "Favorite")
menu.addSeparator() menu.addSeparator()
bl_menu = menu.addMenu("Blacklist Tag") bl_menu = menu.addMenu("Blacklist Tag")
for tag in post.tag_list[:20]: if post.tag_categories:
for category, tags in post.tag_categories.items():
cat_menu = bl_menu.addMenu(category)
for tag in tags[:30]:
cat_menu.addAction(tag)
else:
for tag in post.tag_list[:30]:
bl_menu.addAction(tag) bl_menu.addAction(tag)
action = menu.exec(pos) action = menu.exec(pos)
@ -1074,13 +1080,22 @@ class BooruApp(QMainWindow):
self._status.showMessage("Tags copied") self._status.showMessage("Tags copied")
elif action == fav_action: elif action == fav_action:
self._toggle_favorite(index) self._toggle_favorite(index)
elif action.parent() == bl_menu: elif self._is_child_of_menu(action, bl_menu):
tag = action.text() tag = action.text()
self._db.add_blacklisted_tag(tag) self._db.add_blacklisted_tag(tag)
self._db.set_setting("blacklist_enabled", "1") self._db.set_setting("blacklist_enabled", "1")
self._status.showMessage(f"Blacklisted: {tag}") self._status.showMessage(f"Blacklisted: {tag}")
self._do_search() self._do_search()
@staticmethod
def _is_child_of_menu(action, menu) -> bool:
parent = action.parent()
while parent:
if parent == menu:
return True
parent = getattr(parent, 'parent', lambda: None)()
return False
def _on_multi_context_menu(self, indices: list, pos) -> None: def _on_multi_context_menu(self, indices: list, pos) -> None:
"""Context menu for multi-selected posts.""" """Context menu for multi-selected posts."""
posts = [self._posts[i] for i in indices if 0 <= i < len(self._posts)] posts = [self._posts[i] for i in indices if 0 <= i < len(self._posts)]