mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
pype tray modified to use settings
This commit is contained in:
parent
7889b2a360
commit
cdf7b820e9
1 changed files with 14 additions and 24 deletions
|
|
@ -3,7 +3,8 @@ import sys
|
|||
import platform
|
||||
from avalon import style
|
||||
from Qt import QtCore, QtGui, QtWidgets, QtSvg
|
||||
from pype.api import config, Logger, resources
|
||||
from pype.api import Logger, resources
|
||||
from pype.settings.lib import get_system_settings, load_json_file
|
||||
import pype.version
|
||||
try:
|
||||
import configparser
|
||||
|
|
@ -31,18 +32,11 @@ class TrayManager:
|
|||
self.errors = []
|
||||
|
||||
CURRENT_DIR = os.path.dirname(__file__)
|
||||
self.modules_imports = config.load_json(
|
||||
self.modules_imports = load_json_file(
|
||||
os.path.join(CURRENT_DIR, "modules_imports.json")
|
||||
)
|
||||
presets = config.get_presets(first_run=True)
|
||||
menu_items = presets["tray"]["menu_items"]
|
||||
try:
|
||||
self.modules_usage = menu_items["item_usage"]
|
||||
except Exception:
|
||||
self.modules_usage = {}
|
||||
self.log.critical("Couldn't find modules usage data.")
|
||||
|
||||
self.module_attributes = menu_items.get("attributes") or {}
|
||||
module_settings = get_system_settings()["modules"]
|
||||
self.module_settings = module_settings
|
||||
|
||||
self.icon_run = QtGui.QIcon(
|
||||
resources.get_resource("icons", "circle_green.png")
|
||||
|
|
@ -75,23 +69,19 @@ class TrayManager:
|
|||
import_path = item.get("import_path")
|
||||
title = item.get("title")
|
||||
|
||||
item_usage = self.modules_usage.get(title)
|
||||
if item_usage is None:
|
||||
item_usage = self.modules_usage.get(import_path, True)
|
||||
|
||||
if not item_usage:
|
||||
module_data = self.module_settings.get(title)
|
||||
if not module_data:
|
||||
if not title:
|
||||
title = import_path
|
||||
self.log.info("{} - Module ignored".format(title))
|
||||
self.log.warning("{} - Module data not found".format(title))
|
||||
continue
|
||||
|
||||
_attributes = self.module_attributes.get(title)
|
||||
if _attributes is None:
|
||||
_attributes = self.module_attributes.get(import_path)
|
||||
|
||||
if _attributes:
|
||||
item["attributes"] = _attributes
|
||||
enabled = module_data.pop("enabled", True)
|
||||
if not enabled:
|
||||
self.log.debug("{} - Module is disabled".format(title))
|
||||
continue
|
||||
|
||||
item["attributes"] = module_data
|
||||
items.append(item)
|
||||
|
||||
if items:
|
||||
|
|
@ -207,7 +197,7 @@ class TrayManager:
|
|||
)
|
||||
klass = getattr(module, "CLASS_DEFINIION", None)
|
||||
if not klass and attributes:
|
||||
self.log.error((
|
||||
self.log.debug((
|
||||
"There are defined attributes for module \"{}\" but"
|
||||
"module does not have defined \"CLASS_DEFINIION\"."
|
||||
).format(import_path))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue