Fixed submenu context menu color theming being inconsistent.
This commit is contained in:
parent
75f19d685c
commit
c7cbd1ae0d
Binary file not shown.
56
borealis.py
56
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user