-
Notifications
You must be signed in to change notification settings - Fork 812
/
general.js
284 lines (269 loc) · 7.9 KB
/
general.js
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
import electron from 'electron';
import React from 'react';
import PropTypes from 'prop-types';
import tildify from 'tildify';
import {connect, PreferencesContainer} from '../../../containers';
import Item from '../item';
import Switch from '../item/switch';
import Button from '../item/button';
import Select from '../item/select';
import ShortcutInput from '../shortcut-input';
import Category from './category';
class General extends React.Component {
static defaultProps = {
audioDevices: [],
kapturesDir: '',
category: 'general'
}
state = {}
componentDidMount() {
this.setState({
showCursorSupported: electron.remote.require('./utils/macos-version').isGreaterThanOrEqualTo('10.14')
});
}
openKapturesDir = () => {
electron.shell.openItem(this.props.kapturesDir);
}
render() {
const {
kapturesDir,
openOnStartup,
allowAnalytics,
showCursor,
highlightClicks,
hideDesktopIcons,
doNotDisturb,
record60fps,
recordKeyboardShortcut,
loopExports,
toggleSetting,
audioInputDeviceId,
setAudioInputDeviceId,
audioDevices,
recordAudio,
pickKapturesDir,
setOpenOnStartup,
cropperShortcut,
updateShortcut,
toggleShortcuts,
category
} = this.props;
const {showCursorSupported} = this.state;
const devices = audioDevices.map(device => ({
label: device.name,
value: device.id
}));
const kapturesDirPath = tildify(kapturesDir);
const tabIndex = category === 'general' ? 0 : -1;
const fpsOptions = [{label: '30 FPS', value: false}, {label: '60 FPS', value: true}];
return (
<Category>
{
showCursorSupported &&
<Item
key="showCursor"
parentItem
title="Show cursor"
subtitle="Display the mouse cursor in your Kaptures"
>
<Switch
tabIndex={tabIndex}
checked={showCursor}
onClick={
() => {
if (showCursor) {
toggleSetting('highlightClicks', false);
}
toggleSetting('showCursor');
}
}/>
</Item>
}
{
showCursorSupported &&
<Item key="highlightClicks" subtitle="Highlight clicks">
<Switch
tabIndex={tabIndex}
checked={highlightClicks}
disabled={!showCursor}
onClick={() => toggleSetting('highlightClicks')}
/>
</Item>
}
<Item
key="recordKeyboardShortcut"
parentItem
title="Keyboard shortcuts"
subtitle="Toggle and customise keyboard shortcuts"
>
<Switch tabIndex={tabIndex} checked={recordKeyboardShortcut} onClick={toggleShortcuts}/>
</Item>
{
recordKeyboardShortcut &&
<Item key="cropperShortcut" subtitle="Trigger Kap">
<ShortcutInput
shortcut={cropperShortcut}
tabIndex={tabIndex}
onChange={shortcut => updateShortcut('cropperShortcut', shortcut)}
/>
</Item>
}
<Item
key="hideDesktopIcons"
title="Hide desktop icons"
subtitle="Temporarily hide desktop icons while recording"
>
<Switch tabIndex={tabIndex} checked={hideDesktopIcons} onClick={() => toggleSetting('hideDesktopIcons')}/>
</Item>
<Item
key="doNotDisturb"
title="Silence notifications"
subtitle="Activate “Do Not Disturb” while recording"
>
<Switch tabIndex={tabIndex} checked={doNotDisturb} onClick={() => toggleSetting('doNotDisturb')}/>
</Item>
<Item
key="loopExports"
title="Loop exports"
subtitle="Infinitely loop exports when supported"
>
<Switch tabIndex={tabIndex} checked={loopExports} onClick={() => toggleSetting('loopExports')}/>
</Item>
<Item
key="recordAudio"
parentItem
title="Audio recording"
subtitle="Record audio from input device"
>
<Switch
tabIndex={tabIndex}
checked={recordAudio}
onClick={() => toggleSetting('recordAudio')}/>
</Item>
<Item key="audioInputDeviceId" subtitle="Select input device">
<Select
tabIndex={tabIndex}
options={devices}
selected={audioInputDeviceId}
placeholder="Select Device"
noOptionsMessage="No input devices"
onSelect={setAudioInputDeviceId}/>
</Item>
<Item
key="record60fps"
title="Capture frame rate"
subtitle="Increased FPS impacts performance and file size"
>
<Select
tabIndex={tabIndex}
options={fpsOptions}
selected={record60fps}
onSelect={value => toggleSetting('record60fps', value)}/>
</Item>
<Item
key="allowAnalytics"
title="Allow analytics"
subtitle="Help us improve Kap by sending anonymous usage stats"
>
<Switch tabIndex={tabIndex} checked={allowAnalytics} onClick={() => toggleSetting('allowAnalytics')}/>
</Item>
<Item
key="openOnStartup"
title="Start automatically"
subtitle="Launch Kap on system startup"
>
<Switch tabIndex={tabIndex} checked={openOnStartup} onClick={setOpenOnStartup}/>
</Item>
<Item
key="pickKapturesDir"
title="Save to…"
subtitle={kapturesDirPath}
tooltip={kapturesDir}
onSubtitleClick={this.openKapturesDir}
>
<Button tabIndex={tabIndex} title="Choose" onClick={pickKapturesDir}/>
</Item>
</Category>
);
}
}
General.propTypes = {
showCursor: PropTypes.bool,
highlightClicks: PropTypes.bool,
hideDesktopIcons: PropTypes.bool,
doNotDisturb: PropTypes.bool,
record60fps: PropTypes.bool,
recordKeyboardShortcut: PropTypes.bool,
toggleSetting: PropTypes.elementType.isRequired,
audioInputDeviceId: PropTypes.string,
setAudioInputDeviceId: PropTypes.elementType.isRequired,
audioDevices: PropTypes.array,
recordAudio: PropTypes.bool,
kapturesDir: PropTypes.string,
openOnStartup: PropTypes.bool,
allowAnalytics: PropTypes.bool,
loopExports: PropTypes.bool,
pickKapturesDir: PropTypes.elementType.isRequired,
setOpenOnStartup: PropTypes.elementType.isRequired,
updateShortcut: PropTypes.elementType.isRequired,
toggleShortcuts: PropTypes.elementType.isRequired,
category: PropTypes.string,
cropperShortcut: PropTypes.shape({
metaKey: PropTypes.bool.isRequired,
altKey: PropTypes.bool.isRequired,
ctrlKey: PropTypes.bool.isRequired,
shiftKey: PropTypes.bool.isRequired,
character: PropTypes.string.isRequired
})
};
export default connect(
[PreferencesContainer],
({
showCursor,
highlightClicks,
hideDesktopIcons,
doNotDisturb,
record60fps,
recordAudio,
recordKeyboardShortcut,
audioInputDeviceId,
audioDevices,
kapturesDir,
openOnStartup,
allowAnalytics,
loopExports,
cropperShortcut,
category
}) => ({
showCursor,
highlightClicks,
hideDesktopIcons,
doNotDisturb,
record60fps,
recordAudio,
recordKeyboardShortcut,
audioInputDeviceId,
audioDevices,
kapturesDir,
openOnStartup,
allowAnalytics,
loopExports,
cropperShortcut,
category
}),
({
toggleSetting,
setAudioInputDeviceId,
pickKapturesDir,
setOpenOnStartup,
updateShortcut,
toggleShortcuts
}) => ({
toggleSetting,
setAudioInputDeviceId,
pickKapturesDir,
setOpenOnStartup,
updateShortcut,
toggleShortcuts
})
)(General);