Doc for menus
This commit is contained in:
parent
6dab9ffd5a
commit
be2e994513
|
@ -2168,6 +2168,35 @@ class LOShortCuts(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class MenuDebug():
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_info(cls, menu):
|
||||||
|
line = menu.get('CommandURL', '----------')
|
||||||
|
submenu = menu.get('ItemDescriptorContainer', None)
|
||||||
|
if not submenu is None:
|
||||||
|
line += cls._get_submenus(submenu)
|
||||||
|
return line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_submenus(cls, menu, level=1):
|
||||||
|
line = ''
|
||||||
|
for i, v in enumerate(menu):
|
||||||
|
data = data_to_dict(v)
|
||||||
|
cmd = data.get('CommandURL', '----------')
|
||||||
|
line += f'\n{" " * level}├─ ({i}) {cmd}'
|
||||||
|
submenu = data.get('ItemDescriptorContainer', None)
|
||||||
|
if not submenu is None:
|
||||||
|
line += cls._get_submenus(submenu, level + 1)
|
||||||
|
return line
|
||||||
|
|
||||||
|
def __call__(cls, menu):
|
||||||
|
for m in menu:
|
||||||
|
data = data_to_dict(m)
|
||||||
|
print(cls._get_info(data))
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class LOMenu(object):
|
class LOMenu(object):
|
||||||
|
|
||||||
def __init__(self, app, menu, config):
|
def __init__(self, app, menu, config):
|
||||||
|
@ -2175,6 +2204,10 @@ class LOMenu(object):
|
||||||
self._menu = menu
|
self._menu = menu
|
||||||
self._config = config
|
self._config = config
|
||||||
|
|
||||||
|
def debug(self):
|
||||||
|
MenuDebug()(self._menu)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class LOMenuApp(object):
|
class LOMenuApp(object):
|
||||||
NODE = 'private:resource/menubar/menubar'
|
NODE = 'private:resource/menubar/menubar'
|
||||||
|
@ -2212,26 +2245,8 @@ class LOMenuApp(object):
|
||||||
config = manager.getUIConfigurationManager(type_app)
|
config = manager.getUIConfigurationManager(type_app)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
def _get_info(self, menu):
|
|
||||||
line = menu.get('CommandURL', '')
|
|
||||||
line += self._get_submenus(menu['ItemDescriptorContainer'])
|
|
||||||
return line
|
|
||||||
|
|
||||||
def _get_submenus(self, menu, level=1):
|
|
||||||
line = ''
|
|
||||||
for i, v in enumerate(menu):
|
|
||||||
data = data_to_dict(v)
|
|
||||||
cmd = data.get('CommandURL', '----------')
|
|
||||||
line += f'\n{" " * level}├─ ({i}) {cmd}'
|
|
||||||
submenu = data.get('ItemDescriptorContainer', None)
|
|
||||||
if not submenu is None:
|
|
||||||
line += self._get_submenus(submenu, level + 1)
|
|
||||||
return line
|
|
||||||
|
|
||||||
def debug(self):
|
def debug(self):
|
||||||
for m in self._menus:
|
MenuDebug()(self._menus)
|
||||||
menu = data_to_dict(m)
|
|
||||||
print(self._get_info(menu))
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def __contains__(self, name):
|
def __contains__(self, name):
|
||||||
|
@ -2246,14 +2261,15 @@ class LOMenuApp(object):
|
||||||
|
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
if isinstance(index, int):
|
if isinstance(index, int):
|
||||||
menu = self._menus[index]
|
menu = data_to_dict(self._menus[index])
|
||||||
else:
|
else:
|
||||||
for m in self._menus:
|
for m in self._menus:
|
||||||
menu = data_to_dict(m)
|
menu = data_to_dict(m)
|
||||||
cmd = menu.get('CommandURL', '')
|
cmd = menu.get('CommandURL', '')
|
||||||
if self.MENUS[index.lower()] == cmd:
|
if self.MENUS[index.lower()] == cmd:
|
||||||
break
|
break
|
||||||
return LOMenu(self._app, m, self._config)
|
obj = LOMenu(self._app, menu['ItemDescriptorContainer'], self._config)
|
||||||
|
return obj
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def count(self):
|
def count(self):
|
||||||
|
|
Loading…
Reference in New Issue