Skip to content

Commit 8d96aa2

Browse files
committed
[*] refactor: video-editor
1 parent 8026acc commit 8d96aa2

File tree

18 files changed

+423
-51
lines changed

18 files changed

+423
-51
lines changed

wayshot/ui/base/icon.slint

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ export global Icons {
320320
out property <image> fast-forward-fill: @image-url("../images/icons/fast-forward-fill.svg");
321321
out property <image> rewind-fill: @image-url("../images/icons/rewind-fill.svg");
322322
out property <image> start-light: @image-url("../images/icons/start-light.svg");
323+
out property <image> project-light: @image-url("../images/icons/project-light.svg");
323324

324325
out property <image> landing-account: @image-url("../images/landing/landing-account.svg");
325326
out property <image> landing-language-switch: @image-url("../images/landing/landing-language-switch.svg");
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { Theme, Icons } from "theme.slint";
2+
import { SettingDetailInner } from "setting-detail.slint";
3+
import { DialogStatusBar } from "status-bar.slint";
4+
5+
export component MovingDialog inherits Rectangle {
6+
private property <bool> show-body: true;
7+
in-out property title <=> sb.title;
8+
in-out property header-width <=> sb.width;
9+
in-out property icon <=> sb.icon;
10+
callback close <=> sb.close;
11+
12+
sb := DialogStatusBar {
13+
x: (root.width - self.width) / 2;
14+
y: (root.height - self.height - body.height) / 2;
15+
width: Theme.default-font-size * 13;
16+
container-width: root.width;
17+
container-height: root.height;
18+
hide-maximal-ctrl-btns: root.show-body;
19+
hide-minimal-ctrl-btns: !root.show-body;
20+
21+
maximal => {
22+
root.show-body = !root.show-body;
23+
}
24+
25+
minimal => {
26+
root.show-body = !root.show-body;
27+
}
28+
}
29+
30+
body := SettingDetailInner {
31+
visible: root.show-body;
32+
x: sb.x;
33+
y: sb.y + sb.height;
34+
width: sb.width;
35+
height: self.width / Theme.golden-ratio - sb.height;
36+
vbox-padding: 0px;
37+
interactive: false;
38+
39+
Rectangle {
40+
width: parent.width;
41+
background: Theme.base-background;
42+
border-width: 1px;
43+
border-color: Theme.base-border-color;
44+
height: vbox.preferred-height;
45+
46+
vbox := VerticalLayout {
47+
@children
48+
}
49+
}
50+
}
51+
}

wayshot/ui/base/widgets.slint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { NoDataImg } from "no-data.slint";
2323
import { Divider } from "divider.slint";
2424
import { Link } from "link.slint";
2525
import { Dialog } from "dialog.slint";
26+
import { MovingDialog } from "moving-dialog.slint";
2627
import { ConfirmDialog, ConfirmDialogSetting } from "confirm-dialog.slint";
2728
import { MessageDialog, MessageDialogSetting } from "message-dialog.slint";
2829
import { Blanket } from "blanket.slint";
@@ -169,6 +170,7 @@ export {
169170
Divider,
170171
Link,
171172
Dialog,
173+
MovingDialog,
172174
ConfirmDialog,
173175
ConfirmDialogSetting,
174176
MessageDialog,

wayshot/ui/desktop-window.slint

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import {
1919
import { DesktopPanel } from "panel/desktop/desktop.slint";
2020

2121
export component AppWindow inherits Window {
22-
// width: Theme.default-width;
23-
// height: Theme.default-height;
24-
preferred-width: Theme.default-width;
25-
preferred-height: Theme.default-height;
22+
width: Theme.default-width;
23+
height: Theme.default-height;
24+
// preferred-width: Theme.default-width;
25+
// preferred-height: Theme.default-height;
2626
default-font-size: Theme.default-font-size;
2727
default-font-weight: Theme.normal-font-weight;
2828
default-font-family: Theme.default-font-family;
Lines changed: 1 addition & 0 deletions
Loading

wayshot/ui/logic.slint

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import {
3333
VideoEditorSubtitle,
3434
AudioChannels,
3535
AudioSampleRate,
36+
AudioFormat,
37+
VideoEditorNewProjectConfig,
3638
} from "store.slint";
3739

3840
import { Theme } from "base/theme.slint";
@@ -252,7 +254,10 @@ export global Logic {
252254
callback transcribe-sound-wave-end-position-changed(index: int, pos: float);
253255

254256
callback video-editor-update-ui-state();
255-
callback video-editor-new-project();
257+
callback video-editor-show-new-project-dialog();
258+
callback video-editor-new-project(config: VideoEditorNewProjectConfig);
259+
callback video-editor-show-recent-dialog();
260+
callback video-editor-open-recent-project(index: int);
256261
callback video-editor-open-project();
257262
callback video-editor-open-file();
258263
callback video-editor-save-project();
@@ -387,6 +392,34 @@ export global Logic {
387392
}
388393
}
389394

395+
pure public function audio-format-to-str(format: AudioFormat) -> string {
396+
if (format == AudioFormat.Aac) {
397+
return "Aac";
398+
} else if (format == AudioFormat.Ogg) {
399+
return "Ogg";
400+
} else if (format == AudioFormat.Wav) {
401+
return "Wav";
402+
} else if (format == AudioFormat.Flac) {
403+
return "Flac";
404+
} else {
405+
return "Mp3";
406+
}
407+
}
408+
409+
pure public function audio-format-from-str(format: string) -> AudioFormat {
410+
if (format.to-lowercase() == "aac") {
411+
return AudioFormat.Aac;
412+
} else if (format.to-lowercase() == "ogg") {
413+
return AudioFormat.Ogg;
414+
} else if (format.to-lowercase() == "wav") {
415+
return AudioFormat.Wav;
416+
} else if (format.to-lowercase() == "flac") {
417+
return AudioFormat.Flac;
418+
} else {
419+
return AudioFormat.Mp3;
420+
}
421+
}
422+
390423
pure public function audio-channels-to-int(channels: AudioChannels) -> int {
391424
if (channels == AudioChannels.Mono) {
392425
return 1;
@@ -419,7 +452,7 @@ export global Logic {
419452
} else if (rate == AudioSampleRate.Hz192000) {
420453
return 192000;
421454
} else {
422-
return 441000;
455+
return 44100;
423456
}
424457
}
425458

wayshot/ui/panel/def.slint

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
VideoEditorExportVideoConfig,
4848
VideoEditorExportAudioConfig,
4949
VideoEditorSubtitle,
50+
VideoEditorNewProjectConfig,
5051
} from "../store.slint";
5152

52-
export { Theme, Logic, Store, Util, Icons, TabIndex, PopupIndex, SettingPreference, SettingBackup, SettingDetailIndex, MobileSettingDetailIndex, DeviceType, MobileTabIndex, SettingRecorder, SettingCursorTracker, TransitionType, SettingPlayer, FeatureType, SettingShareScreen, SettingShareScreenClient, ConnectionStatus, SettingPushStream, SettingCamera, MixPositionWithPadding, MixPositionWithPaddingTag, RealtimeImageEffect, BackgroundRemoverModel, Downloader, DownloaderState, Transcribe, TranscribeProgressType, FileType, Subtitle, SettingTranscribe, SettingAiModel, VideoEditorTrackType, VideoEditorFilter, VideoEditorTrackSegment, VideoEditorTrack, VideoEditorTracksManager, SelectedTrackIndex, SelectedSegmentIndex, VideoEditorPlaylistItem, MediaType, VideoEditorExportQueueItem, VideoEditorExportVideoConfig, VideoEditorExportAudioConfig, SubtitleType, VideoEditorSubtitle, }
53+
export { Theme, Logic, Store, Util, Icons, TabIndex, PopupIndex, SettingPreference, SettingBackup, SettingDetailIndex, MobileSettingDetailIndex, DeviceType, MobileTabIndex, SettingRecorder, SettingCursorTracker, TransitionType, SettingPlayer, FeatureType, SettingShareScreen, SettingShareScreenClient, ConnectionStatus, SettingPushStream, SettingCamera, MixPositionWithPadding, MixPositionWithPaddingTag, RealtimeImageEffect, BackgroundRemoverModel, Downloader, DownloaderState, Transcribe, TranscribeProgressType, FileType, Subtitle, SettingTranscribe, SettingAiModel, VideoEditorTrackType, VideoEditorFilter, VideoEditorTrackSegment, VideoEditorTrack, VideoEditorTracksManager, SelectedTrackIndex, SelectedSegmentIndex, VideoEditorPlaylistItem, MediaType, VideoEditorExportQueueItem, VideoEditorExportVideoConfig, VideoEditorExportAudioConfig, SubtitleType, VideoEditorSubtitle, VideoEditorNewProjectConfig }

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ export component Header inherits Rectangle {
4040
shotcut: "Ctrl+Shift+O",
4141
action: "video-editor-open-project",
4242
},
43+
{
44+
icon: Icons.recent-light,
45+
text: Logic.tr("Recent"),
46+
shotcut: "Ctrl+Shift+R",
47+
action: "video-editor-show-recent-dialog",
48+
},
4349
{
4450
icon: Icons.open-file-light,
4551
text: Logic.tr("Open File"),
@@ -134,10 +140,10 @@ export component Header inherits Rectangle {
134140

135141
private property <[PopupActionEntry]> view-action-entries: [
136142
{
137-
icon: Icons.recent-light,
138-
text: Logic.tr("Recent"),
139-
shotcut: "Ctrl+Shift+R",
140-
action: "video-editor-recent",
143+
icon: Icons.project-light,
144+
text: Logic.tr("Project"),
145+
shotcut: "Ctrl+Shift+P",
146+
action: "video-editor-show-new-project-dialog",
141147
},
142148
{
143149
icon: Icons.metadata-light,

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,18 @@ component ExportDetailAudio inherits SettingDetail {
269269
is-show-header: false;
270270

271271
SettingDetailInner {
272+
SettingDetailInnerVbox {
273+
SettingDetailLabel {
274+
text: Logic.tr("Format");
275+
}
276+
277+
format-select := Select {
278+
border-width: 0;
279+
values: ["Aac", "Flac", "Mp3", "Ogg", "Wav"];
280+
current-value: Logic.audio-format-to-str(cache-config.format);
281+
}
282+
}
283+
272284
SettingDetailInnerVbox {
273285
SettingDetailLabel {
274286
text: Logic.tr("channels");
@@ -304,6 +316,7 @@ component ExportDetailAudio inherits SettingDetail {
304316
text: Logic.tr("Export");
305317

306318
clicked => {
319+
cache-config.format = Logic.audio-format-from-str(format-select.current-value);
307320
cache-config.channels = Logic.audio-channels-from-int(channels-select.current-value.to-float());
308321
cache-config.sample-rate = Logic.audio-sample-rate-from-int( audio-sample-select.current-value.to-float());
309322
Logic.video-editor-export-audio(cache-config);
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import {
2+
Theme,
3+
Store,
4+
Logic,
5+
Util,
6+
Icons,
7+
VideoEditorNewProjectConfig,
8+
} from "../../def.slint";
9+
import {
10+
IconBtn,
11+
Label,
12+
LineInput,
13+
Dialog,
14+
Select,
15+
SettingDetailInner,
16+
SettingDetail,
17+
SettingDetailInnerVbox,
18+
SettingDetailLabel,
19+
SettingDetailSwitch,
20+
} from "../../../base/widgets.slint";
21+
22+
component SettingPanle inherits SettingDetail {
23+
private property <VideoEditorNewProjectConfig> cache-config: Store.video-editor-new-project-config;
24+
25+
is-show-header: false;
26+
27+
public function get() -> VideoEditorNewProjectConfig {
28+
return {
29+
name: name-li.text,
30+
preview-config: {
31+
fps : Logic.fps-from-int(fps-select.current-value.to-float()),
32+
resolution : Logic.resolution-from-string(resolution-select.current-value),
33+
channels : Logic.audio-channels-from-int(channels-select.current-value.to-float()),
34+
sample-rate: Logic.audio-sample-rate-from-int( audio-sample-select.current-value.to-float()),
35+
}
36+
};
37+
}
38+
39+
SettingDetailInner {
40+
SettingDetailInnerVbox {
41+
SettingDetailLabel {
42+
text: Logic.tr("Name");
43+
}
44+
45+
name-li := LineInput {
46+
text: cache-config.name;
47+
placeholder-text: "name";
48+
}
49+
}
50+
51+
SettingDetailInnerVbox {
52+
pc-switch := SettingDetailSwitch {
53+
icon: Icons.frameless-window-light;
54+
text: Logic.tr("Preview config");
55+
}
56+
}
57+
58+
VerticalLayout {
59+
visible: pc-switch.checked;
60+
spacing: Theme.spacing * 4;
61+
height: self.visible ? self.preferred-height : 0;
62+
63+
SettingDetailInnerVbox {
64+
SettingDetailLabel {
65+
text: Logic.tr("Resolution");
66+
}
67+
68+
resolution-select := Select {
69+
border-width: 0;
70+
values: ["Original", "480P", "720P", "1080P", "2K", "4K"];
71+
current-value: Logic.resolution-to-string(cache-config.preview-config.resolution);
72+
}
73+
}
74+
75+
SettingDetailInnerVbox {
76+
SettingDetailLabel {
77+
text: Logic.tr("FPS");
78+
}
79+
80+
fps-select := Select {
81+
border-width: 0;
82+
values: [24, 25, 30, 60];
83+
current-value: Logic.fps-to-int(cache-config.preview-config.fps);
84+
}
85+
}
86+
87+
SettingDetailInnerVbox {
88+
SettingDetailLabel {
89+
text: Logic.tr("Audio channels");
90+
}
91+
92+
channels-select := Select {
93+
border-width: 0;
94+
values: [1, 2];
95+
current-value: Logic.audio-channels-to-int(cache-config.preview-config.channels);
96+
}
97+
}
98+
99+
SettingDetailInnerVbox {
100+
SettingDetailLabel {
101+
text: Logic.tr("Audio sample rate");
102+
}
103+
104+
audio-sample-select := Select {
105+
border-width: 0;
106+
values: [8000, 16000, 24000, 32000, 44100, 48000, 96000, 192000];
107+
current-value: Logic.audio-sample-rate-to-int(cache-config.preview-config.sample-rate);
108+
}
109+
}
110+
}
111+
}
112+
}
113+
114+
export component NewProject inherits Dialog {
115+
title: Logic.tr("New Project");
116+
is-prevent-event-forward: true;
117+
118+
in-out property <length> inner-height: Theme.dialog-inner-height;
119+
120+
setting := SettingPanle {
121+
max-height: inner-height;
122+
}
123+
124+
cancel-clicked => {
125+
self.escape();
126+
}
127+
128+
ok-clicked => {
129+
Logic.video-editor-new-project(setting.get());
130+
self.escape();
131+
}
132+
}

0 commit comments

Comments
 (0)