@@ -4,25 +4,174 @@ import {
44 Logic ,
55 Util ,
66 Icons ,
7+ VideoEditorSubtitle ,
78} from "../../../def.slint" ;
8- // import {
9- // Divider,
10- // ToolTip,
11- // PopupAction,
12- // PopupActionSetting,
13- // IconBtn,
14- // ToastStatus,
15- // FilePicker,
16- // Banner,
17- // Label,
18- // Link,
19- // TextBtn,
20- // Blanket,
21- // ReplaceDialog,
22- // SimpleAudioControl,
23- // ConfirmDialogSetting,
24- // } from "../../../base/widgets.slint";
9+ import {
10+ Label ,
11+ ClickAndEditLabel ,
12+ IconBtn ,
13+ LineInput ,
14+ TxtEdit ,
15+ ConfirmBtn ,
16+ TextBtnWithoutIcon ,
17+ } from "../../../../base/widgets.slint" ;
18+
19+ component Header inherits Rectangle {
20+ in-out property <int > checked-index ;
21+
22+ background : Theme.thirdly-background;
23+ width : hbox.preferred-width + Theme.padding * 8 ;
24+ height : hbox.preferred-height + Theme.padding * 2 ;
25+ border-radius : self .height / 2 ;
26+ border-width : Theme.default-border-width;
27+ border-color : Theme.base-border-color;
28+
29+ hbox := HorizontalLayout {
30+ x : Theme.padding * 4 ;
31+ y : Theme.padding;
32+ spacing : Theme.spacing * 4 ;
33+
34+ TextBtnWithoutIcon {
35+ text : Logic.tr("New" );
36+ border-radius : self .height / 3 ;
37+ text-color : checked-index == 0 ? Theme.light-text-color : Theme.regular-text-color;
38+ background : checked-index == 0 ? Theme.thirdly-brand-color : transparent;
39+
40+ clicked => {
41+ checked-index = 0 ;
42+ }
43+ }
44+
45+ TextBtnWithoutIcon {
46+ text : Logic.tr("Modify" );
47+ border-radius : self .height / 3 ;
48+ text-color : checked-index == 1 ? Theme.light-text-color : Theme.regular-text-color;
49+ background : checked-index == 1 ? Theme.thirdly-brand-color : transparent;
50+
51+ clicked => {
52+ checked-index = 1 ;
53+ }
54+ }
55+ }
56+ }
57+
58+ component SubtitleBody inherits Flickable {
59+ in-out property <int > checked-index ;
60+ private property edited-subtitle <=> Store.video-editor-current-edited-subtitle;
61+
62+ VerticalLayout {
63+ spacing : Theme.spacing * 2 ;
64+
65+ VerticalLayout {
66+ alignment : start;
67+ padding : Theme.padding * 2 ;
68+ spacing : Theme.spacing * 4 ;
69+
70+ HorizontalLayout {
71+ alignment : space-between;
72+ spacing : Theme.spacing * 2 ;
73+
74+ HorizontalLayout {
75+ spacing : Theme.spacing * 4 ;
76+
77+ Label {
78+ width : self .font-size * 3 ;
79+ text : Logic.tr("Start" ) + ": " ;
80+ }
81+
82+ start-lb := Label {
83+ text : checked-index == 0 ? Logic.ms-to-srt-timestamp-ui(Store.video-editor-timeline-offset) : edited-subtitle.start-timestamp;
84+ }
85+ }
86+
87+ IconBtn {
88+ icon : Icons.locate-to-light;
89+ is-show-tip : true ;
90+ tip : Logic.tr("use timeline timestamp" );
91+
92+ clicked => {
93+ start-lb.text = Logic.ms-to-srt-timestamp-ui (Store.video-editor-timeline-offset);
94+ }
95+ }
96+ }
97+
98+ HorizontalLayout {
99+ alignment : space-between;
100+ spacing : Theme.spacing * 2 ;
101+
102+ HorizontalLayout {
103+ spacing : Theme.spacing * 4 ;
104+
105+ Label {
106+ width : self .font-size * 3 ;
107+ text : Logic.tr("End" ) + ": " ;
108+ }
109+
110+ end-lb := Label {
111+ text : checked-index == 0 ? Logic.ms-to-srt-timestamp-ui(Store.video-editor-timeline-offset) : edited-subtitle.end-timestamp;
112+ }
113+ }
114+
115+ IconBtn {
116+ icon : Icons.locate-to-light;
117+ is-show-tip : true ;
118+ tip : Logic.tr("use timeline timestamp" );
119+
120+ clicked => {
121+ end-lb.text = Logic.ms-to-srt-timestamp-ui (Store.video-editor-timeline-offset);
122+ }
123+ }
124+ }
125+ }
126+
127+ te := TxtEdit {
128+ placeholder : Logic.tr("Input subtitle" );
129+ text : checked-index == 0 ? "" : edited-subtitle.subtitle;
130+ }
131+
132+ HorizontalLayout {
133+ ConfirmBtn {
134+ text : checked-index == 0 ? Logic.tr("Add Subtitle" ) : Logic.tr("Update Subtitle" );
135+ icon : checked-index == 0 ? Icons.add2 -light : Icons.update-light;
136+ bg-color : checked-index == 0 ? Theme.success-color : Theme.thirdly-brand-color;
137+ icon-size : checked-index == 0 ? Theme.icon-size : Theme.icon-size * 0.8 ;
138+
139+ clicked => {
140+ if (checked-index == 0 ) {
141+ Logic.video-editor-add-subtitle ({
142+ start-timestamp: start-lb.text,
143+ end-timestamp: end-lb.text,
144+ subtitle: te.text,
145+ });
146+ } else {
147+ Logic.video-editor-update-subtitle ({
148+ start-timestamp: start-lb.text,
149+ end-timestamp: end-lb.text,
150+ subtitle: te.text,
151+ });
152+ }
153+ }
154+ }
155+ }
156+ }
157+ }
25158
26159export component Subtitle inherits Rectangle {
27- background : red;
160+ in-out property <int > checked-index : 0 ;
161+
162+ VerticalLayout {
163+ spacing : Theme.spacing * 2 ;
164+
165+ HorizontalLayout {
166+ alignment : center;
167+
168+ Header {
169+ checked-index <=> checked-index;
170+ }
171+ }
172+
173+ SubtitleBody {
174+ checked-index <=> checked-index;
175+ }
176+ }
28177}
0 commit comments