31 from python_qt_binding.QtCore
import QObject, QSignalMapper, Signal, Slot
32 from python_qt_binding.QtWidgets
import QAction, QMenu
40 """Menu of available plugins to load and running plugin instances to unload."""
42 load_plugin_signal = Signal(str)
43 unload_plugin_signal = Signal(str)
47 self.setObjectName(
'PluginMenu')
49 plugin_menu = menu_bar.addMenu(menu_bar.tr(
'&Plugins'))
50 running_menu = menu_bar.addMenu(menu_bar.tr(
'&Running'))
57 action.setVisible(
False)
65 base_path = plugin_descriptor.attributes().get(
'plugin_path')
69 for group
in plugin_descriptor.groups():
70 label = group[
'label']
71 if menu_manager.contains_menu(label):
72 submenu = menu_manager.get_menu(label)
74 submenu = QMenu(label, menu_manager.menu)
75 menu_action = submenu.menuAction()
77 menu_manager.add_item(submenu)
80 action_attributes = plugin_descriptor.action_attributes()
81 action = QAction(action_attributes[
'label'], menu_manager.menu)
84 self.
_plugin_mapper.setMapping(action, plugin_descriptor.plugin_id())
87 not_available = plugin_descriptor.attributes().get(
'not_available')
89 action.setEnabled(
False)
90 action.setStatusTip(self.tr(
'Plugin is not available: %s') % not_available)
93 menu_manager.add_item(action)
96 action_attributes = plugin_descriptor.action_attributes()
99 self.
_plugin_mapper.setMapping(action, plugin_descriptor.plugin_id())
104 action_attributes = plugin_descriptor.action_attributes()
107 base_path = plugin_descriptor.attributes().get(
'plugin_path')
128 return self.tr(
'Close:') +
' ' + label
131 if 'icon' in action_attributes
and action_attributes[
'icon']
is not None:
133 action_attributes[
'icon'], action_attributes.get(
'icontype',
None), base_path)
136 if 'statustip' in action_attributes:
137 action.setStatusTip(action_attributes[
'statustip'])