diff --git a/operators/operators.py b/operators/operators.py index 6290086..a5dbef6 100644 --- a/operators/operators.py +++ b/operators/operators.py @@ -631,7 +631,11 @@ class VSETB_OT_load_projects(Operator): metadata_type = project.metadata_types.add() metadata_type.name = metadata_data['name'] metadata_type.field_name = metadata_data['field_name'] - metadata_type['choices'] = metadata_data['choices'] + #metadata_type['choices'] = metadata_data['choices'] + for choice in metadata_data['choices']: + choice_item = metadata_type.choices.add() + choice_item.name = choice + metadata_type['entity_type'] = metadata_data['entity_type'].upper() for status_data in tracker.get_task_statuses(project_data): diff --git a/panels.py b/panels.py index 1f9f30c..45d02f0 100644 --- a/panels.py +++ b/panels.py @@ -274,8 +274,24 @@ class VSETB_PT_metadata(VSETB_main, Panel): layout.prop(strip_settings, 'description', text='DESCRIPTION') #col = layout.column() - for key in strip_settings.metadata.__annotations__.keys(): - layout.prop(strip_settings.metadata, key, text=key.upper()) + for metadata_type in project.metadata_types: + if metadata_type.entity_type == 'SHOT': + row = layout.row(align=True) + metadata_key = metadata_type.field_name + if metadata_type.choices: + metadata_value = getattr(strip_settings.metadata, metadata_key) + icon = 'LAYER_USED' + if metadata_value: + if metadata_value in metadata_type.choices: + icon = 'DOT' + else: + icon = 'ADD' + + row.prop_search(strip_settings.metadata, metadata_key, metadata_type, 'choices', + results_are_suggestions=True, icon=icon) + + else: + row.prop(strip_settings.metadata, metadata_key, text=metadata_key.upper()) classes = ( VSETB_PT_main, diff --git a/properties.py b/properties.py index 9eb456b..beb3cea 100644 --- a/properties.py +++ b/properties.py @@ -86,6 +86,7 @@ def get_preview_items(self, context): return [] + class Asset(PropertyGroup): name : StringProperty(default='') id : StringProperty(default='') @@ -97,7 +98,7 @@ class Asset(PropertyGroup): @property def label(self): - return f"{self.asset_type} / {self.norm_name}" + return f"{self.asset_type} / {self.tracker_name}" @property def icon_id(self): @@ -129,8 +130,8 @@ class AssetType(PropertyGroup): class MetadataType(PropertyGroup): - choices = [] - choice : EnumProperty(items=lambda s, c: [(c, c.replace(' ', '_').upper(), '') for c in s['choices']]) + #choices = [] + choices : CollectionProperty(type=PropertyGroup)#EnumProperty(items=lambda s, c: [(c, c.replace(' ', '_').upper(), '') for c in s['choices']]) field_name : StringProperty() entity_type : StringProperty() @@ -255,10 +256,11 @@ class Project(PropertyGroup): field_name = metadata_type.field_name name = metadata_type.name - if metadata_type.get('choices'): - prop = bpy.props.EnumProperty(items=[(c, c, '') for c in ['/'] + metadata_type['choices']], name=name) - else: - prop = bpy.props.StringProperty(name=name) + #if metadata_type.get('choices'): + # prop = #bpy.props.EnumProperty(items=[(c, c, '') for c in ['/'] + metadata_type['choices']], name=name) + #else: + # prop = #bpy.props.StringProperty(name=name) + prop = bpy.props.StringProperty(name=name) Metadata.__annotations__[field_name] = prop setattr(Metadata, field_name, prop) @@ -436,17 +438,13 @@ def load_handler(dummy): #settings.active_project.set_spreadsheet() os.environ['TRACKER_PROJECT_ID'] = settings.active_project.id - for asset in project.assets: preview_id = asset.preview preview_path = Path(PREVIEWS_DIR / project.id / preview_id).with_suffix('.png') - if preview_path.exists() and preview_id not in ASSET_PREVIEWS: ASSET_PREVIEWS.load(preview_id, preview_path.as_posix(), 'IMAGE', True) - print(preview_path) - - print(ASSET_PREVIEWS) + def register(): for cls in classes: