diff --git a/openpype/modules/base.py b/openpype/modules/base.py index 441a9731b7..21f7a0c76a 100644 --- a/openpype/modules/base.py +++ b/openpype/modules/base.py @@ -172,6 +172,10 @@ class ITrayModule: if self._tray_manager: self._tray_manager.show_tray_message(title, message, icon, msecs) + def add_doubleclick_callback(self, callback): + if hasattr(self.manager, "add_doubleclick_callback"): + self.manager.add_doubleclick_callback(self, callback) + class ITrayAction(ITrayModule): """Implementation of Tray action. @@ -184,6 +188,9 @@ class ITrayAction(ITrayModule): necessary. """ + admin_action = False + _admin_submenu = None + @property @abstractmethod def label(self): @@ -677,7 +684,7 @@ class TrayModulesManager(ModulesManager): ) def __init__(self): - self.log = PypeLogger().get_logger(self.__class__.__name__) + self.log = PypeLogger.get_logger(self.__class__.__name__) self.modules = [] self.modules_by_id = {} @@ -685,6 +692,28 @@ class TrayModulesManager(ModulesManager): self._report = {} self.tray_manager = None + self.doubleclick_callbacks = {} + self.doubleclick_callback = None + + def add_doubleclick_callback(self, module, callback): + """Register doubleclick callbacks on tray icon. + + Currently there is no way how to determine which is launched. Name of + callback can be defined with `doubleclick_callback` attribute. + + Missing feature how to define default callback. + """ + callback_name = "_".join([module.name, callback.__name__]) + if callback_name not in self.doubleclick_callbacks: + self.doubleclick_callbacks[callback_name] = callback + if self.doubleclick_callback is None: + self.doubleclick_callback = callback_name + return + + self.log.warning(( + "Callback with name \"{}\" is already registered." + ).format(callback_name)) + def initialize(self, tray_manager, tray_menu): self.tray_manager = tray_manager self.initialize_modules()