Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/replace_published_scene_path_deepcopy
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT authored Dec 13, 2024
2 parents c1904df + 2ee0112 commit f6c7ee0
Show file tree
Hide file tree
Showing 27 changed files with 1,063 additions and 994 deletions.
58 changes: 1 addition & 57 deletions client/ayon_core/addon/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,67 +370,11 @@ def _load_ayon_addons(log):
return all_addon_modules


def _load_addons_in_core(log):
# Add current directory at first place
# - has small differences in import logic
addon_modules = []
modules_dir = os.path.join(AYON_CORE_ROOT, "modules")
if not os.path.exists(modules_dir):
log.warning(
f"Could not find path when loading AYON addons \"{modules_dir}\""
)
return addon_modules

ignored_filenames = IGNORED_FILENAMES | IGNORED_DEFAULT_FILENAMES
for filename in os.listdir(modules_dir):
# Ignore filenames
if filename in ignored_filenames:
continue

fullpath = os.path.join(modules_dir, filename)
basename, ext = os.path.splitext(filename)

# Validations
if os.path.isdir(fullpath):
# Check existence of init file
init_path = os.path.join(fullpath, "__init__.py")
if not os.path.exists(init_path):
log.debug((
"Addon directory does not contain __init__.py"
f" file {fullpath}"
))
continue

elif ext != ".py":
continue

# TODO add more logic how to define if folder is addon or not
# - check manifest and content of manifest
try:
# Don't import dynamically current directory modules
import_str = f"ayon_core.modules.{basename}"
default_module = __import__(import_str, fromlist=("", ))
addon_modules.append(default_module)

except Exception:
log.error(
f"Failed to import in-core addon '{basename}'.",
exc_info=True
)
return addon_modules


def _load_addons():
log = Logger.get_logger("AddonsLoader")

addon_modules = _load_ayon_addons(log)
# All addon in 'modules' folder are tray actions and should be moved
# to tray tool.
# TODO remove
addon_modules.extend(_load_addons_in_core(log))

# Store modules to local cache
_LoadCache.addon_modules = addon_modules
_LoadCache.addon_modules = _load_ayon_addons(log)


class AYONAddon(ABC):
Expand Down
40 changes: 23 additions & 17 deletions client/ayon_core/addon/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class ITrayAddon(AYONInterface):

tray_initialized = False
_tray_manager = None
_admin_submenu = None

@abstractmethod
def tray_init(self):
Expand Down Expand Up @@ -198,6 +199,27 @@ def add_doubleclick_callback(self, callback):
if hasattr(self.manager, "add_doubleclick_callback"):
self.manager.add_doubleclick_callback(self, callback)

@staticmethod
def admin_submenu(tray_menu):
if ITrayAddon._admin_submenu is None:
from qtpy import QtWidgets

admin_submenu = QtWidgets.QMenu("Admin", tray_menu)
admin_submenu.menuAction().setVisible(False)
ITrayAddon._admin_submenu = admin_submenu
return ITrayAddon._admin_submenu

@staticmethod
def add_action_to_admin_submenu(label, tray_menu):
from qtpy import QtWidgets

menu = ITrayAddon.admin_submenu(tray_menu)
action = QtWidgets.QAction(label, menu)
menu.addAction(action)
if not menu.menuAction().isVisible():
menu.menuAction().setVisible(True)
return action


class ITrayAction(ITrayAddon):
"""Implementation of Tray action.
Expand All @@ -211,7 +233,6 @@ class ITrayAction(ITrayAddon):
"""

admin_action = False
_admin_submenu = None
_action_item = None

@property
Expand All @@ -229,12 +250,7 @@ def tray_menu(self, tray_menu):
from qtpy import QtWidgets

if self.admin_action:
menu = self.admin_submenu(tray_menu)
action = QtWidgets.QAction(self.label, menu)
menu.addAction(action)
if not menu.menuAction().isVisible():
menu.menuAction().setVisible(True)

action = self.add_action_to_admin_submenu(self.label, tray_menu)
else:
action = QtWidgets.QAction(self.label, tray_menu)
tray_menu.addAction(action)
Expand All @@ -248,16 +264,6 @@ def tray_start(self):
def tray_exit(self):
return

@staticmethod
def admin_submenu(tray_menu):
if ITrayAction._admin_submenu is None:
from qtpy import QtWidgets

admin_submenu = QtWidgets.QMenu("Admin", tray_menu)
admin_submenu.menuAction().setVisible(False)
ITrayAction._admin_submenu = admin_submenu
return ITrayAction._admin_submenu


class ITrayService(ITrayAddon):
# Module's property
Expand Down
Empty file.
60 changes: 0 additions & 60 deletions client/ayon_core/modules/launcher_action.py

This file was deleted.

68 changes: 0 additions & 68 deletions client/ayon_core/modules/loader_action.py

This file was deleted.

This file was deleted.

42 changes: 0 additions & 42 deletions client/ayon_core/modules/python_console_interpreter/addon.py

This file was deleted.

This file was deleted.

Loading

0 comments on commit f6c7ee0

Please sign in to comment.