-
Notifications
You must be signed in to change notification settings - Fork 1
/
OpenAtPlayhead.svelte
109 lines (81 loc) · 3.23 KB
/
OpenAtPlayhead.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<script lang="ts">
import { Resolve, ResolveFunctions } from "../src/Lib/DavinciResolve";
import { ResolveEnums } from "../src/Lib/ResolveEnums";
import { DataStore } from "../src/Stores/DataStore";
import { Settings, GlobalSettings, SettingTypes } from '../src/Lib/Settings';
import { ModuleHandler } from '../src/Lib/ModuleHandler';
import { Common } from '../src/Lib/Common';
import { onMount } from 'svelte';
const componentID: string = "OpenAtPlayhead";
onMount(() => {
ModuleHandler.RegisterModule(componentID, ModuleHandler.ComponentSize.Small,
"Opens the current file at the current playhead position in a new explorer window. ");
if (ShortCut !== "") {
Common.Electron.RegisterShortcut(ShortCut, () => {
OpenFileAtPlayhead();
});
}
});
const _Settings = GlobalSettings.GetInstance(componentID);
const ShortCut = _Settings.RegisterSetting("Hotkey", "A shortcut to open the file at playhead", "", SettingTypes.Type.Keybind, <SettingTypes.Keybind>{
defaultModifierOne: SettingTypes.KeybindModifier.None,
defaultModifierTwo: SettingTypes.KeybindModifier.None
});
const OpenFileAtPlayhead = () => {
const timeline: Timeline = ResolveFunctions.GetCurrentTimeline();
if (!timeline) return;
const currentItem = timeline.GetCurrentVideoItem();
if (!currentItem) return;
let filePath: string = currentItem.GetMediaPoolItem().GetClipProperty("File Path") as string;
if (!filePath) {
const audioItem = ResolveFunctions.GetTimelineItem(ResolveEnums.TrackType.Audio, [1], timeline) as TimelineItem;
if (!audioItem) return;
const audioFilePath: string = audioItem.GetMediaPoolItem().GetClipProperty("File Path") as string;
if (!audioFilePath) return;
filePath = audioFilePath;
}
Common.IO.OpenFolder("", ["/select,", filePath], true);
}
</script>
<main id={componentID}>
<h1 id=title>Open File At</h1>
<h1 id=titleUnder>Playhead</h1>
<button id=openFileButton on:click={OpenFileAtPlayhead}>
<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 96 960 960" width="48" fill="currentColor"><path d="M180 936q-24 0-42-18t-18-42V276q0-24 18-42t42-18h279v60H180v600h600V597h60v279q0 24-18 42t-42 18H180Zm202-219-42-43 398-398H519v-60h321v321h-60V319L382 717Z"/></svg>
</button>
</main>
<style lang="scss">
@use '../src/scss/Colors';
main {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
text-align: center;
}
#title {
opacity: 0.5;
font-size: 0.75rem;
margin: 0.3rem;
margin-bottom: 0;
}
#titleUnder {
@extend #title;
font-size: 1rem;
margin-top: 0.3rem;
margin-bottom: 0.3rem;
}
#openFileButton {
background-color: transparent;
border: none;
outline: none;
cursor: pointer;
padding: 0;
margin: 0;
color: Colors.$TextColor;
&:hover {
color: darken(Colors.$TextColor, 30%);
}
transition: color 0.2s;
}
</style>