From d77c0e252be994a242d7004b675a8247abfc8326 Mon Sep 17 00:00:00 2001 From: Alexey Bogomolov Date: Fri, 17 Feb 2023 13:49:32 +0300 Subject: [PATCH] move fusion prefs settings to project_settings --- .../hosts/fusion/hooks/pre_fusion_setup.py | 23 +++++++------- .../defaults/project_settings/fusion.json | 5 ++++ .../system_settings/applications.json | 5 ---- .../schema_project_fusion.json | 24 +++++++++++++++ .../host_settings/schema_fusion.json | 30 ------------------- 5 files changed, 39 insertions(+), 48 deletions(-) diff --git a/openpype/hosts/fusion/hooks/pre_fusion_setup.py b/openpype/hosts/fusion/hooks/pre_fusion_setup.py index 9ae57d2a17..ad2ec7eb2d 100644 --- a/openpype/hosts/fusion/hooks/pre_fusion_setup.py +++ b/openpype/hosts/fusion/hooks/pre_fusion_setup.py @@ -4,7 +4,6 @@ import platform from pathlib import Path from openpype.lib import PreLaunchHook, ApplicationLaunchFailed from openpype.hosts.fusion import FUSION_HOST_DIR -from openpype.settings import get_system_settings class FusionPrelaunch(PreLaunchHook): @@ -39,11 +38,10 @@ class FusionPrelaunch(PreLaunchHook): self.log.info(f"Local Fusion prefs environment is set to {fusion_prefs_dir}") fusion_prefs_filepath = fusion_prefs_dir / "Fusion.prefs" return fusion_prefs_filepath - # otherwise get the profile from default prefs location fusion_prefs_path = f"Blackmagic Design/Fusion/Profiles/{fusion_profile}/Fusion.prefs" if platform.system() == "Windows": - prefs_source = Path(os.getenv("AppData")) / fusion_prefs_path + prefs_source = Path(os.getenv("AppData"), fusion_prefs_path) elif platform.system() == "Darwin": prefs_source = Path("~/Library/Application Support/", fusion_prefs_path).expanduser() elif platform.system() == "Linux": @@ -55,8 +53,7 @@ class FusionPrelaunch(PreLaunchHook): """Get copy prefserences options from the global application settings""" copy_fusion_settings = ( self.data - ["system_settings"] - ["applications"] + ["project_settings"] ["fusion"] .get("copy_fusion_settings", {}) ) @@ -73,7 +70,7 @@ class FusionPrelaunch(PreLaunchHook): """On the first Fusion launch copy the Fusion profile to the working directory. If the Openpype profile folder exists, skip copying, unless Force sync is checked. If the prefs were not copied on the first launch, clean Fusion profile - will be created in openpype_fusion_profile_dir. + will be created in fusion_profile_dir. """ if copy_to.exists() and not force_sync: self.log.info("Local Fusion preferences folder exists, skipping profile copy") @@ -127,14 +124,14 @@ class FusionPrelaunch(PreLaunchHook): self.log.info(f"Setting OPENPYPE_FUSION: {FUSION_HOST_DIR}") self.launch_context.env["OPENPYPE_FUSION"] = FUSION_HOST_DIR - copy_status, openpype_fusion_profile_dir, force_sync = self.get_copy_fusion_prefs_settings() + copy_status, fusion_profile_dir, force_sync = self.get_copy_fusion_prefs_settings() if copy_status: prefs_source = self.get_profile_source() - self.copy_existing_prefs(prefs_source, openpype_fusion_profile_dir, force_sync) + self.copy_existing_prefs(prefs_source, fusion_profile_dir, force_sync) fusion_profile_dir_variable = f"FUSION{self.PROFILE_NUMBER}_PROFILE_DIR" master_prefs_variable = f"FUSION{self.PROFILE_NUMBER}_MasterPrefs" - openpype_master_prefs = Path(FUSION_HOST_DIR, "deploy", "fusion_shared.prefs") - self.log.info(f"Setting {fusion_profile_dir_variable}: {openpype_fusion_profile_dir}") - self.launch_context.env[fusion_profile_dir_variable] = str(openpype_fusion_profile_dir) - self.log.info(f"Setting {master_prefs_variable}: {openpype_master_prefs}") - self.launch_context.env[master_prefs_variable] = str(openpype_master_prefs) + master_prefs = Path(FUSION_HOST_DIR, "deploy", "fusion_shared.prefs") + self.log.info(f"Setting {fusion_profile_dir_variable}: {fusion_profile_dir}") + self.launch_context.env[fusion_profile_dir_variable] = str(fusion_profile_dir) + self.log.info(f"Setting {master_prefs_variable}: {master_prefs}") + self.launch_context.env[master_prefs_variable] = str(master_prefs) diff --git a/openpype/settings/defaults/project_settings/fusion.json b/openpype/settings/defaults/project_settings/fusion.json index 720178e17a..74863ece43 100644 --- a/openpype/settings/defaults/project_settings/fusion.json +++ b/openpype/settings/defaults/project_settings/fusion.json @@ -16,5 +16,10 @@ "linux": [] } } + }, + "copy_fusion_settings": { + "copy_status": false, + "copy_path": "~/.openpype/hosts/fusion/prefs", + "force_sync": false } } \ No newline at end of file diff --git a/openpype/settings/defaults/system_settings/applications.json b/openpype/settings/defaults/system_settings/applications.json index 9fb730568e..d498bccda9 100644 --- a/openpype/settings/defaults/system_settings/applications.json +++ b/openpype/settings/defaults/system_settings/applications.json @@ -835,11 +835,6 @@ "linux": "/opt/Python/3.6/bin" } }, - "copy_fusion_settings": { - "copy_prefs": false, - "prefs_path": "~/.openpype/hosts/fusion/prefs", - "force_sync": false - }, "variants": { "18": { "executables": { diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json b/openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json index 8c62d75815..540f840aad 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_fusion.json @@ -45,6 +45,30 @@ ] } ] + }, + { + "type": "dict", + "key": "copy_fusion_settings", + "collapsible": true, + "checkbox_key": "copy_status", + "label": "Copy Fusion settings on launch", + "children": [ + { + "type": "boolean", + "key": "copy_status", + "label": "Enabled" + }, + { + "key": "copy_path", + "type": "path", + "label": "Local prefs directory" + }, + { + "key":"force_sync", + "type": "boolean", + "label": "Force sync preferences" + } + ] } ] } diff --git a/openpype/settings/entities/schemas/system_schema/host_settings/schema_fusion.json b/openpype/settings/entities/schemas/system_schema/host_settings/schema_fusion.json index 48355932ae..5960da7774 100644 --- a/openpype/settings/entities/schemas/system_schema/host_settings/schema_fusion.json +++ b/openpype/settings/entities/schemas/system_schema/host_settings/schema_fusion.json @@ -19,36 +19,6 @@ "label": "Environment", "type": "raw-json" }, - { - "type": "splitter" - }, - { - "type": "dict", - "key": "copy_fusion_settings", - "collapsible": true, - "checkbox_key": "copy_prefs", - "label": "Copy Fusion settings when launched from OpenPype", - "children": [ - { - "type": "boolean", - "key": "copy_prefs", - "label": "Enabled" - }, - { - "key": "prefs_path", - "type": "path", - "label": "Local prefs directory" - }, - { - "key":"force_sync", - "type": "boolean", - "label": "Always sync preferences on launch" - } - ] - }, - { - "type": "splitter" - }, { "type": "dict-modifiable", "key": "variants",