Skip to content

Commit dbd08c8

Browse files
committed
[*] refactor: video-editor
1 parent 0078d01 commit dbd08c8

File tree

17 files changed

+452
-122
lines changed

17 files changed

+452
-122
lines changed

wayshot/ui/base/icon.slint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ export global Icons {
317317
out property <image> preset-light: @image-url("../images/icons/preset-light.svg");
318318
out property <image> locate-light: @image-url("../images/icons/locate-light.svg");
319319
out property <image> update-light: @image-url("../images/icons/update-light.svg");
320+
out property <image> fast-forward-fill: @image-url("../images/icons/fast-forward-fill.svg");
321+
out property <image> rewind-fill: @image-url("../images/icons/rewind-fill.svg");
322+
out property <image> start-light: @image-url("../images/icons/start-light.svg");
320323

321324
out property <image> landing-account: @image-url("../images/landing/landing-account.svg");
322325
out property <image> landing-language-switch: @image-url("../images/landing/landing-language-switch.svg");
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

wayshot/ui/logic.slint

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import {
3131
VideoEditorExportAudioConfig,
3232
VideoEditorTrackSegment,
3333
VideoEditorSubtitle,
34+
AudioChannels,
35+
AudioSampleRate,
3436
} from "store.slint";
3537

3638
import { Theme } from "base/theme.slint";
@@ -277,6 +279,9 @@ export global Logic {
277279
callback video-editor-insert-audio-track(index: int);
278280
callback video-editor-insert-subtitle-track(index: int);
279281
callback video-editor-insert-overlay-track(index: int);
282+
callback video-editor-paste-filter-to-track(index: int);
283+
callback video-editor-remove-all-filters-from-track(index: int);
284+
280285
callback video-editor-toggle-locked-track(index: int);
281286
callback video-editor-toggle-hiding-track(index: int);
282287
callback video-editor-toggle-muted-track(index: int);
@@ -322,6 +327,13 @@ export global Logic {
322327
callback video-editor-add-subtitle(subtitle: VideoEditorSubtitle);
323328
callback video-editor-update-subtitle(subtitle: VideoEditorSubtitle);
324329

330+
callback video-editor-preview-jump-previous-segment();
331+
callback video-editor-preview-jump-next-segment();
332+
callback video-editor-preview-rewind();
333+
callback video-editor-preview-fast-forward();
334+
callback video-editor-preview-toggle();
335+
callback video-editor-preview-change-volume(value: float);
336+
325337
pure callback video-editor-selected-segment() -> VideoEditorTrackSegment;
326338
video-editor-selected-segment => {
327339
return Store.video-editor-tracks-manager.tracks[0].segments[0];
@@ -375,6 +387,62 @@ export global Logic {
375387
}
376388
}
377389

390+
pure public function audio-channels-to-int(channels: AudioChannels) -> int {
391+
if (channels == AudioChannels.Mono) {
392+
return 1;
393+
} else {
394+
return 2;
395+
}
396+
}
397+
398+
pure public function audio-channels-from-int(channels: int) -> AudioChannels {
399+
if (channels == 1) {
400+
return AudioChannels.Mono;
401+
} else {
402+
return AudioChannels.Stereo;
403+
}
404+
}
405+
406+
pure public function audio-sample-rate-to-int(rate: AudioSampleRate) -> int {
407+
if (rate == AudioSampleRate.Hz8000) {
408+
return 8000;
409+
} else if (rate == AudioSampleRate.Hz16000) {
410+
return 16000;
411+
} else if (rate == AudioSampleRate.Hz24000) {
412+
return 24000;
413+
} else if (rate == AudioSampleRate.Hz32000) {
414+
return 32000;
415+
} else if (rate == AudioSampleRate.Hz48000) {
416+
return 48000;
417+
} else if (rate == AudioSampleRate.Hz96000) {
418+
return 96000;
419+
} else if (rate == AudioSampleRate.Hz192000) {
420+
return 192000;
421+
} else {
422+
return 441000;
423+
}
424+
}
425+
426+
pure public function audio-sample-rate-from-int(rate: int) -> AudioSampleRate {
427+
if (rate == 8000) {
428+
return AudioSampleRate.Hz8000;
429+
} else if (rate == 16000) {
430+
return AudioSampleRate.Hz16000;
431+
} else if (rate == 24000) {
432+
return AudioSampleRate.Hz24000;
433+
} else if (rate == 32000) {
434+
return AudioSampleRate.Hz32000;
435+
} else if (rate == 48000) {
436+
return AudioSampleRate.Hz48000;
437+
} else if (rate == 96000) {
438+
return AudioSampleRate.Hz96000;
439+
} else if (rate == 192000) {
440+
return AudioSampleRate.Hz192000;
441+
} else {
442+
return AudioSampleRate.Hz44100;
443+
}
444+
}
445+
378446
pure public function resolution-to-string(res: Resolution) -> string {
379447
if (res == Resolution.Original) {
380448
return "Original";

wayshot/ui/panel/desktop/video-editor/filter.slint

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ export global VEFilter {
3131
in-out property <[PresetFilter]> overlay-preset-filters: [];
3232
in-out property <[PresetFilter]> subtitle-preset-filters: [];
3333

34+
// 复制滤镜是缓存的滤镜,用于后续粘贴
35+
in-out property <SegmentFilter> cache-copy-filter;
36+
3437
// 用于创建预设滤镜时,临时存储选中的滤镜
3538
in-out property <[PresetFilter]> cache-preset-filters: [];
3639

3740
callback up-filter(index: int);
3841
callback down-filter(index: int);
3942
callback remove-filter(index: int);
4043
callback toggle-filter(index: int);
44+
callback copy-filter(index: int);
4145
callback add-filter(filter-name: string);
4246

4347
callback create-preset-filter(name: string);

wayshot/ui/panel/desktop/video-editor/left-panel/export-queue.slint renamed to wayshot/ui/panel/desktop/video-editor/left-panel/export.slint

Lines changed: 33 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import {
2727
LineInput,
2828
ConfirmBtn,
2929
RadioBtn,
30+
Select,
31+
GainFocus,
3032
} from "../../../../base/widgets.slint";
3133

3234
component TaskItem inherits Rectangle {
@@ -196,26 +198,10 @@ component ExportDetailVideo inherits SettingDetail {
196198
text: Logic.tr("Resolution");
197199
}
198200

199-
HorizontalLayout {
200-
spacing: Theme.spacing * 2;
201-
202-
width-lineedit := LineInput {
203-
horizontal-stretch: 1;
204-
input-type: number;
205-
placeholder-text: Logic.tr("width");
206-
text: cache-config.width;
207-
}
208-
209-
Label {
210-
text: "X";
211-
}
212-
213-
height-lineedit := LineInput {
214-
horizontal-stretch: 1;
215-
input-type: number;
216-
placeholder-text: Logic.tr("height");
217-
text: cache-config.height;
218-
}
201+
resolution-select := Select {
202+
border-width: 0;
203+
values: ["Original", "480P", "720P", "1080P", "2K", "4K"];
204+
current-value: Logic.resolution-to-string(cache-config.resolution);
219205
}
220206
}
221207

@@ -224,10 +210,10 @@ component ExportDetailVideo inherits SettingDetail {
224210
text: Logic.tr("FPS");
225211
}
226212

227-
fps-lineedit := LineInput {
228-
input-type: number;
229-
placeholder-text: 25;
230-
text: cache-config.fps;
213+
fps-select := Select {
214+
border-width: 0;
215+
values: [24, 25, 30, 60];
216+
current-value: Logic.fps-to-int(cache-config.fps);
231217
}
232218
}
233219

@@ -236,10 +222,10 @@ component ExportDetailVideo inherits SettingDetail {
236222
text: Logic.tr("Audio channels");
237223
}
238224

239-
channels-lineedit := LineInput {
240-
input-type: number;
241-
placeholder-text: 2;
242-
text: cache-config.channels;
225+
channels-select := Select {
226+
border-width: 0;
227+
values: [1, 2];
228+
current-value: Logic.audio-channels-to-int(cache-config.channels);
243229
}
244230
}
245231

@@ -248,10 +234,10 @@ component ExportDetailVideo inherits SettingDetail {
248234
text: Logic.tr("Audio sample rate");
249235
}
250236

251-
sample-rate-lineedit := LineInput {
252-
input-type: number;
253-
placeholder-text: 44100;
254-
text: cache-config.sample-rate;
237+
audio-sample-select := Select {
238+
border-width: 0;
239+
values: [8000, 16000, 24000, 32000, 44100, 48000, 96000, 192000];
240+
current-value: Logic.audio-sample-rate-to-int(cache-config.sample-rate);
255241
}
256242
}
257243

@@ -266,11 +252,10 @@ component ExportDetailVideo inherits SettingDetail {
266252
text: Logic.tr("Export");
267253

268254
clicked => {
269-
cache-config.width = width-lineedit.text.to-float();
270-
cache-config.height = height-lineedit.text.to-float();
271-
cache-config.fps = fps-lineedit.text.to-float();
272-
cache-config.channels = channels-lineedit.text.to-float();
273-
cache-config.sample-rate = sample-rate-lineedit.text.to-float();
255+
cache-config.resolution = Logic.resolution-from-string(resolution-select.current-value);
256+
cache-config.fps = Logic.fps-from-int(fps-select.current-value.to-float());
257+
cache-config.channels = Logic.audio-channels-from-int(channels-select.current-value.to-float());
258+
cache-config.sample-rate = Logic.audio-sample-rate-from-int( audio-sample-select.current-value.to-float());
274259
Logic.video-editor-export-video(cache-config);
275260
}
276261
}
@@ -286,13 +271,13 @@ component ExportDetailAudio inherits SettingDetail {
286271
SettingDetailInner {
287272
SettingDetailInnerVbox {
288273
SettingDetailLabel {
289-
text: Logic.tr("Channels");
274+
text: Logic.tr("channels");
290275
}
291276

292-
channels-lineedit := LineInput {
293-
input-type: number;
294-
placeholder-text: 2;
295-
text: cache-config.channels;
277+
channels-select := Select {
278+
border-width: 0;
279+
values: [1, 2];
280+
current-value: Logic.audio-channels-to-int(cache-config.channels);
296281
}
297282
}
298283

@@ -301,10 +286,10 @@ component ExportDetailAudio inherits SettingDetail {
301286
text: Logic.tr("Sample rate");
302287
}
303288

304-
sample-rate-lineedit := LineInput {
305-
input-type: number;
306-
placeholder-text: 44100;
307-
text: cache-config.sample-rate;
289+
audio-sample-select := Select {
290+
border-width: 0;
291+
values: [8000, 16000, 24000, 32000, 44100, 48000, 96000, 192000];
292+
current-value: Logic.audio-sample-rate-to-int(cache-config.sample-rate);
308293
}
309294
}
310295

@@ -319,8 +304,8 @@ component ExportDetailAudio inherits SettingDetail {
319304
text: Logic.tr("Export");
320305

321306
clicked => {
322-
cache-config.channels = channels-lineedit.text.to-float();
323-
cache-config.sample-rate = sample-rate-lineedit.text.to-float();
307+
cache-config.channels = Logic.audio-channels-from-int(channels-select.current-value.to-float());
308+
cache-config.sample-rate = Logic.audio-sample-rate-from-int( audio-sample-select.current-value.to-float());
324309
Logic.video-editor-export-audio(cache-config);
325310
}
326311
}

wayshot/ui/panel/desktop/video-editor/left-panel/left-panel.slint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
import {
99
TabBtns,
1010
} from "../../../../base/widgets.slint";
11+
import { Export } from "export.slint";
1112
import { Playlist } from "playlist.slint";
12-
import { Export } from "export-queue.slint";
1313
import { MediaLibrary } from "media-library.slint";
1414

1515
export component LeftPanel inherits Rectangle {

0 commit comments

Comments
 (0)