66from NodeGraphQt .widgets .stylesheet import STYLE_QMENU
77
88
9- class ContextMenu (object ):
9+ class Menu (object ):
1010 """
11- base class for a context menu item.
11+ base class for a menu item.
1212 """
1313
1414 def __init__ (self , viewer , qmenu ):
@@ -25,7 +25,7 @@ def qmenu(self):
2525
2626 def name (self ):
2727 """
28- Returns the label for the menu.
28+ Returns the name for the menu.
2929
3030 Returns:
3131 str: label name.
@@ -34,38 +34,38 @@ def name(self):
3434
3535 def get_menu (self , name ):
3636 """
37- Returns the child context menu item by name.
37+ Returns the child menu by name.
3838
3939 Args:
4040 name (str): name of the menu.
4141
4242 Returns:
43- NodeGraphQt.ContextMenu : menu item.
43+ NodeGraphQt.Menu : menu item.
4444 """
4545 for action in self .qmenu .actions ():
4646 if action .menu () and action .menu ().title () == name :
47- return ContextMenu (self .__viewer , action .menu ())
47+ return Menu (self .__viewer , action .menu ())
4848
4949 def get_command (self , name ):
5050 """
51- Returns the child menu command item by name.
51+ Returns the child menu command by name.
5252
5353 Args:
5454 name (str): name of the command.
5555
5656 Returns:
57- NodeGraphQt.ContextMenuCommand : context menu command.
57+ NodeGraphQt.MenuCommand : context menu command.
5858 """
5959 for action in self .qmenu .actions ():
6060 if not action .menu () and action .text () == name :
61- return ContextMenuCommand (self .__viewer , action )
61+ return MenuCommand (self .__viewer , action )
6262
6363 def all_commands (self ):
6464 """
6565 Returns all child and sub child commands from the current context menu.
6666
6767 Returns:
68- list[NodeGraphQt.ContextMenuCommand ]: list of commands.
68+ list[NodeGraphQt.MenuCommand ]: list of commands.
6969 """
7070 def get_actions (menu ):
7171 actions = []
@@ -77,7 +77,7 @@ def get_actions(menu):
7777 actions += get_actions (action .menu ())
7878 return actions
7979 child_actions = get_actions (self .qmenu )
80- return [ContextMenuCommand (self .__viewer , a ) for a in child_actions ]
80+ return [MenuCommand (self .__viewer , a ) for a in child_actions ]
8181
8282 def add_menu (self , name ):
8383 """
@@ -87,12 +87,12 @@ def add_menu(self, name):
8787 name (str): menu name.
8888
8989 Returns:
90- NodeGraphQt.ContextMenu : the appended menu.
90+ NodeGraphQt.Menu : the appended menu item .
9191 """
9292 menu = QtWidgets .QMenu (None , title = name )
9393 menu .setStyleSheet (STYLE_QMENU )
9494 self .qmenu .addMenu (menu )
95- return ContextMenu (self .__viewer , menu )
95+ return Menu (self .__viewer , menu )
9696
9797 def add_command (self , name , func = None , shortcut = None ):
9898 """
@@ -101,10 +101,10 @@ def add_command(self, name, func=None, shortcut=None):
101101 Args:
102102 name (str): command name.
103103 func (function): command function.
104- shortcut (str): shotcut key.
104+ shortcut (str): function shotcut key.
105105
106106 Returns:
107- NodeGraphQt.ContextMenuCommand : the appended command.
107+ NodeGraphQt.MenuCommand : the appended command.
108108 """
109109 action = QtWidgets .QAction (name , self .__viewer )
110110 if LooseVersion (QtCore .qVersion ()) >= LooseVersion ('5.10' ):
@@ -114,7 +114,7 @@ def add_command(self, name, func=None, shortcut=None):
114114 if func :
115115 action .triggered .connect (func )
116116 qaction = self .qmenu .addAction (action , shortcut = shortcut )
117- return ContextMenuCommand (self .__viewer , qaction )
117+ return MenuCommand (self .__viewer , qaction )
118118
119119 def add_separator (self ):
120120 """
@@ -123,9 +123,9 @@ def add_separator(self):
123123 self .qmenu .addSeparator ()
124124
125125
126- class ContextMenuCommand (object ):
126+ class MenuCommand (object ):
127127 """
128- base class for a context menu command.
128+ base class for a menu command.
129129 """
130130
131131 def __init__ (self , viewer , qaction ):
@@ -142,7 +142,7 @@ def qaction(self):
142142
143143 def name (self ):
144144 """
145- Returns the label for the menu command.
145+ Returns the name for the menu command.
146146
147147 Returns:
148148 str: label name.
0 commit comments