diff --git a/operators/sequencer.py b/operators/sequencer.py index 9049848..6f4f90d 100644 --- a/operators/sequencer.py +++ b/operators/sequencer.py @@ -296,39 +296,54 @@ class VSETB_OT_next_shot(Operator): return {"FINISHED"} -class VSETB_OT_open_shot_folder(Operator): - bl_idname = "vse_toolbox.open_shot_folder" - bl_label = "Open Shot Folder" - bl_description = "Open Shot Folder" +class VSETB_OT_open_strip_folder(Operator): + bl_idname = "vse_toolbox.open_strip_folder" + bl_label = "Open Strip Folder" + bl_description = "Open selected strip folder" bl_options = {"REGISTER", "UNDO"} @classmethod def poll(cls, context): - settings = get_scene_settings() - project = settings.active_project - if not project.templates.get('shot_dir'): - cls.poll_message_set('No shot_dir template setted') + strip = context.active_sequence_strip + if not strip: + cls.poll_message_set('No active') return - strip = context.active_sequence_strip - if not strip or get_channel_name(strip) != 'Shots': - cls.poll_message_set('No shot strip active') + if not any(p in get_channel_name(strip) for p in ('Shots', 'Sequences', 'Movie', 'Video', 'Audio', 'Sound')): + cls.poll_message_set('Only for Shots, Sequences, Movie and Audio strips') return return True def execute(self, context): + + tpl_by_channel = { + 'Shots': 'shot_dir', + 'Sequences': 'sequence_dir' + } + strip = context.active_sequence_strip settings = get_scene_settings() project = settings.active_project strip_settings = get_strip_settings() - format_data = {**settings.format_data, **project.format_data, **strip_settings.format_data} + channel_name = get_channel_name(strip) - shot_folder_template = expandvars(project.templates['shot_dir'].value) - shot_folder_path = shot_folder_template.format(**format_data) - bpy.ops.wm.path_open(filepath=shot_folder_path) + if strip.type in ('MOVIE', 'IMAGE'): + path = Path(strip.filepath) + + elif strip.type in ('SOUND'): + path = Path(strip.sound.filepath) + + else: + folder_template = expandvars(project.templates[tpl_by_channel[channel_name]].value) + path = Path(folder_template.format(**format_data)) + + if not path.is_dir(): + path = path.parent + + bpy.ops.wm.path_open(filepath=str(path)) return {"FINISHED"} @@ -513,7 +528,7 @@ classes = ( VSETB_OT_show_waveform, VSETB_OT_previous_shot, VSETB_OT_next_shot, - VSETB_OT_open_shot_folder, + VSETB_OT_open_strip_folder, VSETB_OT_collect_files, WM_OT_split_view ) diff --git a/ui/panels.py b/ui/panels.py index 8924fef..db66a65 100644 --- a/ui/panels.py +++ b/ui/panels.py @@ -446,7 +446,7 @@ class VSETB_MT_main_menu(Menu): op.filepath = str(REVIEW_TEMPLATE_BLEND) layout.operator("wm.split_view", icon="ARROW_LEFTRIGHT") - layout.operator('vse_toolbox.open_shot_folder', text='Open Shot Folder', icon='FILE_FOLDER') + layout.operator('vse_toolbox.open_strip_folder', text='Open Strip Folder', icon='FILE_FOLDER') layout.operator('vse_toolbox.open_shot_on_tracker', text='Open Shot on Tracker', icon='URL') def draw_vse_toolbox_menu(self, context):