Skip to content

Architecture

hannes edited this page Feb 27, 2023 · 4 revisions

Explain the basic architecture for people who want to contribute to the code.

unimenu.dccs._abstract.py

MenuNode class reads data from a config It represents a node in the menu hierarchy.

MenuNodeAbstract inherits from MenuNode, and adds abstract logic to create a menu in an app, from the data loaded in MenuNode

Ideally you only overwrite these methods, and don't change the setup method. in case of very custom stuff, you might want to edit the setup method and ignore these methods.

@property  
def _default_root_parent(self):  
    """get the default parent for the root node, optional method"""  
    return None  
  
@abstractmethod  
def _setup_sub_menu(self, parent_app_node=None):  
    """instantiate & parent a sub menu"""  
    pass  
  
@abstractmethod  
def _setup_menu_item(self, parent_app_node=None):  
    """instantiate & parent a menu item"""  
    pass  
  
@abstractmethod  
def _setup_separator(self, parent_app_node=None):  
    """instantiate & parent a separator"""  
    pass  
  
@abstractmethod  
def teardown(self):  
    """teardown the menu item"""  
    pass

unimenu.dccs

all app implementations go in here, and inherit from MenuNodeAbstract for the ones that are qt compatible, you can inherit from MenuNodeQt, e.g. Krita

use lowercase name, with underscore for app module names in def menu_node_class we convert this name to CamelCase to grab the app node.

every app module should have an app node, named MenuNodeMyApp, e.g. MenuNodeMax the easiest is to have a look at existing apps.

Feel free to make a PR for the wiki too. Not sure yet on the process for this, might need to setup a mirror repo.

Clone this wiki locally