From 0fcfde7c0527da57a7c4c9112038edbadb0b8014 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Thu, 3 Dec 2020 17:51:53 +0100 Subject: [PATCH] last workfile on statup from settings --- pype/hooks/global/pre_global_host_data.py | 19 ++--- .../schemas/schema_global_tools.json | 70 +++++++++---------- 2 files changed, 37 insertions(+), 52 deletions(-) diff --git a/pype/hooks/global/pre_global_host_data.py b/pype/hooks/global/pre_global_host_data.py index 3f403b43f5..09fc707e4e 100644 --- a/pype/hooks/global/pre_global_host_data.py +++ b/pype/hooks/global/pre_global_host_data.py @@ -6,7 +6,7 @@ import copy from pype.api import ( Anatomy, - config + get_project_settings ) from pype.lib import ( env_value_to_bool, @@ -284,20 +284,9 @@ class GlobalHostDataHook(PreLaunchHook): bool: True if host should start workfile. """ - default_output = env_value_to_bool( - "AVALON_OPEN_LAST_WORKFILE", default=False - ) - # TODO convert to settings - try: - startup_presets = ( - config.get_presets(project_name) - .get("tools", {}) - .get("workfiles", {}) - .get("last_workfile_on_startup") - ) - except Exception: - startup_presets = None - self.log.warning("Couldn't load pype's presets", exc_info=True) + + project_settings = get_project_settings(project_name)['global']['tools'] + startup_presets = project_settings['Workfiles']['last_workfile_on_startup'] if not startup_presets: return default_output diff --git a/pype/tools/settings/settings/gui_schemas/projects_schema/schemas/schema_global_tools.json b/pype/tools/settings/settings/gui_schemas/projects_schema/schemas/schema_global_tools.json index 5a19e4827d..529794fd28 100644 --- a/pype/tools/settings/settings/gui_schemas/projects_schema/schemas/schema_global_tools.json +++ b/pype/tools/settings/settings/gui_schemas/projects_schema/schemas/schema_global_tools.json @@ -28,45 +28,41 @@ "label": "Workfiles", "children": [ { - "type": "dict", - "collapsable": true, - "key": "last_workfile_on_startup", + "type": "collapsible-wrap", "label": "Open last workfiles on launch", - "checkbox_key": "enabled", - "is_group": true, "children": [ - { - "type": "list", - "key": "profiles", - "label": "Profiles", - "object_type": - { - "type": "dict", - "children": [ - { - "key": "hosts", - "label": "Hosts", - "type": "list", - "object_type": "text" - }, - { - "key": "tasks", - "label": "Tasks", - "type": "list", - "object_type": "text" - }, - { - "type": "splitter" - }, - { - "type": "boolean", - "key": "enabled", - "label": "Enabled" - } - ] - } - } - ] + { + "type": "list", + "key": "last_workfile_on_startup", + "label": "", + "is_group": true, + "object_type": + { + "type": "dict", + "children": [ + { + "key": "hosts", + "label": "Hosts", + "type": "list", + "object_type": "text" + }, + { + "key": "tasks", + "label": "Tasks", + "type": "list", + "object_type": "text" + }, + { + "type": "splitter" + }, + { + "type": "boolean", + "key": "enabled", + "label": "Enabled" + } + ] + } + }] }, { "type": "dict-modifiable",