37 @signal pluginAboutToBeDeactivated(modulName, pluginObject) emitted just before a |
37 @signal pluginAboutToBeDeactivated(modulName, pluginObject) emitted just before a |
38 plugin is deactivated |
38 plugin is deactivated |
39 @signal pluginDeactivated(modulName, pluginObject) emitted just after a plugin |
39 @signal pluginDeactivated(modulName, pluginObject) emitted just after a plugin |
40 was deactivated |
40 was deactivated |
41 """ |
41 """ |
|
42 shutdown = pyqtSignal() |
|
43 pluginAboutToBeActivated = pyqtSignal(str, QObject) |
|
44 pluginActivated = pyqtSignal(str, QObject) |
|
45 allPlugginsActivated = pyqtSignal() |
|
46 pluginAboutToBeDeactivated = pyqtSignal(str, QObject) |
|
47 pluginDeactivated = pyqtSignal(str, QObject) |
|
48 |
42 def __init__(self, parent = None, doLoadPlugins = True, develPlugin = None): |
49 def __init__(self, parent = None, doLoadPlugins = True, develPlugin = None): |
43 """ |
50 """ |
44 Constructor |
51 Constructor |
45 |
52 |
46 The Plugin Manager deals with three different plugin directories. |
53 The Plugin Manager deals with three different plugin directories. |
428 savedInactiveList.remove(self.__develPluginName) |
435 savedInactiveList.remove(self.__develPluginName) |
429 names = sorted(self.__inactiveModules.keys()) |
436 names = sorted(self.__inactiveModules.keys()) |
430 for name in names: |
437 for name in names: |
431 if savedInactiveList is None or name not in savedInactiveList: |
438 if savedInactiveList is None or name not in savedInactiveList: |
432 self.activatePlugin(name) |
439 self.activatePlugin(name) |
433 self.emit(SIGNAL("allPlugginsActivated()")) |
440 self.allPlugginsActivated.emit() |
434 |
441 |
435 def activatePlugin(self, name, onDemand = False): |
442 def activatePlugin(self, name, onDemand = False): |
436 """ |
443 """ |
437 Public method to activate a plugin. |
444 Public method to activate a plugin. |
438 |
445 |
460 pluginObject = self.__onDemandInactivePlugins[name] |
467 pluginObject = self.__onDemandInactivePlugins[name] |
461 elif not onDemand and name in self.__inactivePlugins: |
468 elif not onDemand and name in self.__inactivePlugins: |
462 pluginObject = self.__inactivePlugins[name] |
469 pluginObject = self.__inactivePlugins[name] |
463 else: |
470 else: |
464 pluginObject = pluginClass(self.__ui) |
471 pluginObject = pluginClass(self.__ui) |
465 self.emit(SIGNAL("pluginAboutToBeActivated"), name, pluginObject) |
472 self.pluginAboutToBeActivated.emit(name, pluginObject) |
466 try: |
473 try: |
467 obj, ok = pluginObject.activate() |
474 obj, ok = pluginObject.activate() |
468 except TypeError: |
475 except TypeError: |
469 module.error = self.trUtf8("Incompatible plugin activation method.") |
476 module.error = self.trUtf8("Incompatible plugin activation method.") |
470 obj = None |
477 obj = None |
474 obj = None |
481 obj = None |
475 ok = False |
482 ok = False |
476 if not ok: |
483 if not ok: |
477 return None |
484 return None |
478 |
485 |
479 self.emit(SIGNAL("pluginActivated"), name, pluginObject) |
486 self.pluginActivated.emit(name, pluginObject) |
480 pluginObject.eric5PluginModule = module |
487 pluginObject.eric5PluginModule = module |
481 pluginObject.eric5PluginName = className |
488 pluginObject.eric5PluginName = className |
482 pluginObject.eric5PluginVersion = version |
489 pluginObject.eric5PluginVersion = version |
483 |
490 |
484 if onDemand: |
491 if onDemand: |
556 if onDemand and name in self.__onDemandActivePlugins: |
563 if onDemand and name in self.__onDemandActivePlugins: |
557 pluginObject = self.__onDemandActivePlugins[name] |
564 pluginObject = self.__onDemandActivePlugins[name] |
558 elif not onDemand and name in self.__activePlugins: |
565 elif not onDemand and name in self.__activePlugins: |
559 pluginObject = self.__activePlugins[name] |
566 pluginObject = self.__activePlugins[name] |
560 if pluginObject: |
567 if pluginObject: |
561 self.emit(SIGNAL("pluginAboutToBeDeactivated"), name, pluginObject) |
568 self.pluginAboutToBeDeactivated.emit(name, pluginObject) |
562 pluginObject.deactivate() |
569 pluginObject.deactivate() |
563 self.emit(SIGNAL("pluginDeactivated"), name, pluginObject) |
570 self.pluginDeactivated.emit(name, pluginObject) |
564 |
571 |
565 if onDemand: |
572 if onDemand: |
566 self.__onDemandActiveModules.pop(name) |
573 self.__onDemandActiveModules.pop(name) |
567 self.__onDemandActivePlugins.pop(name) |
574 self.__onDemandActivePlugins.pop(name) |
568 self.__onDemandInactivePlugins[name] = pluginObject |
575 self.__onDemandInactivePlugins[name] = pluginObject |
708 names = [] |
715 names = [] |
709 for name in list(self.__inactiveModules.keys()): |
716 for name in list(self.__inactiveModules.keys()): |
710 names.append(name) |
717 names.append(name) |
711 Preferences.Prefs.settings.setValue(self.__inactivePluginsKey, names) |
718 Preferences.Prefs.settings.setValue(self.__inactivePluginsKey, names) |
712 |
719 |
713 self.emit(SIGNAL("shutdown()")) |
720 self.shutdown.emit() |
714 |
721 |
715 def getPluginDisplayStrings(self, type_): |
722 def getPluginDisplayStrings(self, type_): |
716 """ |
723 """ |
717 Public method to get the display strings of all plugins of a specific type. |
724 Public method to get the display strings of all plugins of a specific type. |
718 |
725 |