From c7cbd1ae0db7a069b60941203d607ae3da9c80ad Mon Sep 17 00:00:00 2001 From: Nicole Rappe Date: Tue, 25 Feb 2025 23:56:29 -0700 Subject: [PATCH] Fixed submenu context menu color theming being inconsistent. --- .../flyff_EXP_current.cpython-312.pyc | Bin 2984 -> 2984 bytes borealis.py | 58 +++++++++++------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/Nodes/Flyff/__pycache__/flyff_EXP_current.cpython-312.pyc b/Nodes/Flyff/__pycache__/flyff_EXP_current.cpython-312.pyc index a8eac9513d0edf2471d599c7ea455692df9eb0cc..118f525cf6b84c302ddd769896c73056f6fcfa0d 100644 GIT binary patch delta 19 ZcmZ1>zCxVqG%qg~0}!xp-^ewO8vrm01eyQ< delta 19 ZcmZ1>zCxVqG%qg~0}#Yd+{iVL8vrp}1k3;c diff --git a/borealis.py b/borealis.py index 505d286..32d1d6d 100644 --- a/borealis.py +++ b/borealis.py @@ -234,17 +234,51 @@ if __name__ == "__main__": for node_class in node_classes: graph.register_node(node_class) + # Recursively apply the stylesheet to all submenus + def apply_styles_to_submenus(menu): + """ Recursively applies the stylesheet to all submenus in the menu. """ + menu.setStyleSheet(menu_stylesheet) + for action in menu.actions(): + if action.menu(): # Check if action has a submenu + apply_styles_to_submenus(action.menu()) + + # Override the Color of the Context Menu to Blue + menu_stylesheet = """ + QMenu { + background-color: rgb(30, 30, 30); + border: 1px solid rgba(200, 200, 200, 60); + } + QMenu::item { + padding: 5px 18px 2px; + background-color: transparent; + } + QMenu::item:selected { + color: rgb(255, 255, 255); + background-color: rgba(60, 120, 180, 150); + } + QMenu::separator { + height: 1px; + background: rgba(255, 255, 255, 50); + margin: 4px 8px; + } + """ + # Create categorized context menu graph_context_menu = graph.get_context_menu("graph") add_node_menu = graph_context_menu.add_menu("Add Node") - + for category, node_classes in custom_nodes_by_category.items(): - category_menu = add_node_menu.add_menu(category) + category_menu = add_node_menu.add_menu(category) # Create submenu + category_menu.qmenu.setStyleSheet(menu_stylesheet) # Apply to submenu + for node_class in node_classes: node_type = f"{node_class.__identifier__}.{node_class.__name__}" node_name = node_class.NODE_NAME category_menu.add_command(f"{node_name}", make_node_command(graph, node_type)) + # Ensure styles are propagated across all dynamically created submenus + apply_styles_to_submenus(graph_context_menu.qmenu) + # Add a "Remove Selected Node" command graph_context_menu.add_command( "Remove Selected Node", @@ -388,26 +422,6 @@ if __name__ == "__main__": graph.widget.resize(1600, 900) graph.widget.show() - # Override the Color of the Context Menu to Blue - menu_stylesheet = """ - QMenu { - background-color: rgb(30, 30, 30); - border: 1px solid rgba(200, 200, 200, 60); - } - QMenu::item { - padding: 5px 18px 2px; - background-color: transparent; - } - QMenu::item:selected { - color: rgb(255, 255, 255); - background-color: rgba(60, 120, 180, 150); - } - QMenu::separator { - height: 1px; - background: rgba(255, 255, 255, 50); - margin: 4px 8px; - } - """ graph_context_menu.qmenu.setStyleSheet(menu_stylesheet) # Global update function