Clean up handling of separators in dynamic menu

This commit is contained in:
Keith Edmunds 2025-02-27 08:13:29 +00:00
parent 82e707a6f6
commit 90d72464cb

View File

@ -847,7 +847,7 @@ class Window(QMainWindow):
items = getattr(self, f"get_{key}_items")()
for item in items:
# Check for separator
if "separator" in item and item["separator"] == "separator":
if "separator" in item and item["separator"]:
submenu.addSeparator()
continue
action = QAction(item["text"], self)
@ -865,7 +865,7 @@ class Window(QMainWindow):
def get_new_playlist_dynamic_submenu_items(
self,
) -> list[dict[str, str | tuple[Session, int]]]:
) -> list[dict[str, str | tuple[Session, int] | bool]]:
"""
Return dynamically generated menu items, in this case
templates marked as favourite from which to generate a
@ -876,14 +876,14 @@ class Window(QMainWindow):
"""
with db.Session() as session:
submenu_items: list[dict[str, str | tuple[Session, int]]] = [
submenu_items: list[dict[str, str | tuple[Session, int] | bool]] = [
{
"text": "Show all",
"handler": "create_playlist_from_template",
"args": (session, 0),
},
{
"separator": "separator",
"separator": True,
}
]
templates = Playlists.get_favourite_templates(session)