33 from python_qt_binding.QtCore
import qCritical, QEvent, QObject, qWarning, Slot
40 """Handler for directly passing invocations between the framework and one `Plugin` instance.""" 42 def __init__(self, parent, main_window, instance_id,
43 application_context, container_manager, argv):
44 super(PluginHandlerDirect, self).
__init__(
45 parent, main_window, instance_id, application_context, container_manager, argv)
46 self.setObjectName(
'PluginHandlerDirect')
50 def load(self, plugin_provider, callback=None):
52 super(PluginHandlerDirect, self).
load(plugin_provider, callback)
55 self.
_plugin = self._plugin_provider.load(self._instance_id.plugin_id, self.
_context)
56 if hasattr(self.
_plugin,
'has_configuration'):
64 if exception
is None and hasattr(self.
_plugin,
'installEventFilter'):
66 self._plugin.installEventFilter(self)
70 if event.type() == QEvent.DeferredDelete:
75 return QObject.eventFilter(self, watched, event)
78 if hasattr(self.
_plugin,
'removeEventFilter'):
79 self._plugin.removeEventFilter(self)
81 if hasattr(self.
_plugin,
'deleteLater'):
82 self._plugin.deleteLater()
85 if hasattr(self.
_plugin,
'shutdown_plugin'):
87 self._plugin.shutdown_plugin()
90 'PluginHandlerDirect._shutdown_plugin() plugin "%s" raised an ' 91 'exception:\n%s' % (str(self.
_instance_id), traceback.format_exc()))
100 self._plugin_provider.unload(self.
_plugin)
105 if hasattr(self.
_plugin,
'save_settings'):
106 plugin_settings_plugin = plugin_settings.get_settings(
'plugin')
107 instance_settings_plugin = instance_settings.get_settings(
'plugin')
109 self._plugin.save_settings(plugin_settings_plugin, instance_settings_plugin)
112 'PluginHandlerDirect._save_settings() plugin "%s" raised an exception:\n%s' %
117 if hasattr(self.
_plugin,
'restore_settings'):
118 plugin_settings_plugin = plugin_settings.get_settings(
'plugin')
119 instance_settings_plugin = instance_settings.get_settings(
'plugin')
121 self._plugin.restore_settings(plugin_settings_plugin, instance_settings_plugin)
124 'PluginHandlerDirect._restore_settings() plugin "%s" raised an exception:\n%s' %
132 qWarning(
'PluginHandlerDirect.add_widget() widget "%s" already added' %
142 qWarning(
'PluginHandlerDirect.add_toolbar() toolbar "%s" already added' %
143 toolbar.objectName())
150 if self._application_context.options.standalone_plugin
is None:
def add_toolbar(self, toolbar)
def eventFilter(self, watched, event)
def _emit_close_plugin(self)
def _restore_settings(self, plugin_settings, instance_settings)
def _add_toolbar(self, toolbar)
def emit_shutdown_plugin_completed(self)
_plugin_has_configuration
def _delete_widget(self, widget)
def __init__(self, parent, main_window, instance_id, application_context, container_manager, argv)
def shutdown_plugin(self, callback)
def _emit_load_completed(self, exception=None)
def _save_settings(self, plugin_settings, instance_settings)
def emit_restore_settings_completed(self)
def _shutdown_plugin(self)
def _emit_unload_completed(self)
def _update_title_bars(self)
def _emit_load_completed(self, exception=None)
def load(self, plugin_provider, callback=None)
def _emit_reload_signal(self)
def _create_dock_widget(self)
def emit_save_settings_completed(self)
def add_widget(self, widget)
def _add_dock_widget(self, dock_widget, widget)