Skip to content

Commit 3948f17

Browse files
feat: browse files to select txt files needed in some settings
current command is now scrollable vertically
1 parent 669ebfd commit 3948f17

File tree

7 files changed

+213
-24
lines changed

7 files changed

+213
-24
lines changed

lib/models/settings_model.dart

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// TODO:
2-
/// profanity and cap files browse mode
32
/// quant , oem, dvb/mkv/ocrlang, teletextstuff in UI this is also in hardsubx
43
/// hardsubx settings
54
@@ -61,7 +60,9 @@ class SettingsModel {
6160
bool trim;
6261
String defaultcolor;
6362
bool sentencecap;
63+
String capFile;
6464
bool kf;
65+
String profanityFile;
6566
bool splitbysentence;
6667
bool datets;
6768
bool sects;
@@ -156,7 +157,9 @@ class SettingsModel {
156157
this.trim = false,
157158
this.defaultcolor = '',
158159
this.sentencecap = false,
160+
this.capFile = '',
159161
this.kf = false,
162+
this.profanityFile = '',
160163
this.splitbysentence = false,
161164
this.datets = false,
162165
this.sects = false,
@@ -243,7 +246,9 @@ class SettingsModel {
243246
bool? trim,
244247
String? defaultcolor,
245248
bool? sentencecap,
249+
String? capFile,
246250
bool? kf,
251+
String? profanityFile,
247252
bool? splitbysentence,
248253
bool? datets,
249254
bool? sects,
@@ -329,7 +334,9 @@ class SettingsModel {
329334
trim: trim ?? this.trim,
330335
defaultcolor: defaultcolor ?? this.defaultcolor,
331336
sentencecap: sentencecap ?? this.sentencecap,
337+
capFile: capFile ?? this.capFile,
332338
kf: kf ?? this.kf,
339+
profanityFile: profanityFile ?? this.profanityFile,
333340
splitbysentence: splitbysentence ?? this.splitbysentence,
334341
datets: datets ?? this.datets,
335342
sects: sects ?? this.sects,
@@ -420,7 +427,9 @@ class SettingsModel {
420427
'trim': '-trim',
421428
'defaultcolor': '--defaultcolor',
422429
'sentencecap': '--sentencecap',
430+
'capFile': '--capfile',
423431
'kf': '--kf',
432+
'profanityFile': '--profanity-file',
424433
'splitbysentence': '--splitbysentence',
425434
'datets': '-datets',
426435
'sects': '-sects',
@@ -534,7 +543,9 @@ class SettingsModel {
534543
'trim': trim,
535544
'defaultcolor': defaultcolor,
536545
'sentencecap': sentencecap,
546+
'capFile': capFile,
537547
'kf': kf,
548+
'profanityFile': profanityFile,
538549
'splitbysentence': splitbysentence,
539550
'datets': datets,
540551
'sects': sects,
@@ -623,7 +634,9 @@ class SettingsModel {
623634
trim: map['trim'],
624635
defaultcolor: map['defaultcolor'],
625636
sentencecap: map['sentencecap'],
637+
capFile: map['capFile'],
626638
kf: map['kf'],
639+
profanityFile: map['profanityFile'],
627640
splitbysentence: map['splitbysentence'],
628641
datets: map['datets'],
629642
sects: map['sects'],
@@ -670,7 +683,7 @@ class SettingsModel {
670683

671684
@override
672685
String toString() {
673-
return 'SettingsModel(out: $out, inp: $inp, outputfilename: $outputfilename, fixptsjumps: $fixptsjumps, append: $append, outInterval: $outInterval, segmentonkeyonly: $segmentonkeyonly, goptime: $goptime, nogoptime: $nogoptime, fixpadding: $fixpadding, freqEs15: $freqEs15, stream: $stream, videoedited: $videoedited, usepicorder: $usepicorder, myth: $myth, nomyth: $nomyth, wtvconvertfix: $wtvconvertfix, wtvmpeg2: $wtvmpeg2, program_number: $program_number, autoprogram: $autoprogram, multiprogram: $multiprogram, streamtype: $streamtype, hauppauge: $hauppauge, mp4vidtrack: $mp4vidtrack, noautotimeref: $noautotimeref, noscte20: $noscte20, webvttcss: $webvttcss, analyzevideo: $analyzevideo, notimestamp: $notimestamp, nolevdist: $nolevdist, minlevdist: $minlevdist, maxlevdist: $maxlevdist, chapters: $chapters, bom: $bom, nobom: $nobom, encoder: $encoder, nofontcolor: $nofontcolor, nohtmlescape: $nohtmlescape, notypesetting: $notypesetting, trim: $trim, defaultcolor: $defaultcolor, sentencecap: $sentencecap, kf: $kf, splitbysentence: $splitbysentence, datets: $datets, sects: $sects, latrusmap: $latrusmap, xds: $xds, lf: $lf, df: $df, autodash: $autodash, xmltv: $xmltv, xmltvliveinterval: $xmltvliveinterval, xmltvoutputinterval: $xmltvoutputinterval, xmltvonlycurrent: $xmltvonlycurrent, sem: $sem, dvblang: $dvblang, mkvlang: $mkvlang, ocrlang: $ocrlang, quant: $quant, oem: $oem, bufferinput: $bufferinput, nobufferinput: $nobufferinput, buffersize: $buffersize, koc: $koc, dru: $dru, norollup: $norollup, rollUp: $rollUp, delay: $delay, startat: $startat, endat: $endat, codec: $codec, nocodec: $nocodec, startcreditstext: $startcreditstext, startcreditsnotbefore: $startcreditsnotbefore, startcreditsnotafter: $startcreditsnotafter, startcreditsforatleast: $startcreditsforatleast, startcreditsforatmost: $startcreditsforatmost, endcreditstext: $endcreditstext, endcreditsforatleast: $endcreditsforatleast, endcreditsforatmost: $endcreditsforatmost, tpage: $tpage, teletext: $teletext, noteletext: $noteletext)';
686+
return 'SettingsModel(out: $out, inp: $inp, outputfilename: $outputfilename, fixptsjumps: $fixptsjumps, append: $append, outInterval: $outInterval, segmentonkeyonly: $segmentonkeyonly, goptime: $goptime, nogoptime: $nogoptime, fixpadding: $fixpadding, freqEs15: $freqEs15, stream: $stream, videoedited: $videoedited, usepicorder: $usepicorder, myth: $myth, nomyth: $nomyth, wtvconvertfix: $wtvconvertfix, wtvmpeg2: $wtvmpeg2, program_number: $program_number, autoprogram: $autoprogram, multiprogram: $multiprogram, streamtype: $streamtype, hauppauge: $hauppauge, mp4vidtrack: $mp4vidtrack, noautotimeref: $noautotimeref, noscte20: $noscte20, webvttcss: $webvttcss, analyzevideo: $analyzevideo, notimestamp: $notimestamp, nolevdist: $nolevdist, minlevdist: $minlevdist, maxlevdist: $maxlevdist, chapters: $chapters, bom: $bom, nobom: $nobom, encoder: $encoder, nofontcolor: $nofontcolor, nohtmlescape: $nohtmlescape, notypesetting: $notypesetting, trim: $trim, defaultcolor: $defaultcolor, sentencecap: $sentencecap, capFile: $capFile, kf: $kf, profanityFile: $profanityFile, splitbysentence: $splitbysentence, datets: $datets, sects: $sects, latrusmap: $latrusmap, xds: $xds, lf: $lf, df: $df, autodash: $autodash, xmltv: $xmltv, xmltvliveinterval: $xmltvliveinterval, xmltvoutputinterval: $xmltvoutputinterval, xmltvonlycurrent: $xmltvonlycurrent, sem: $sem, dvblang: $dvblang, mkvlang: $mkvlang, ocrlang: $ocrlang, quant: $quant, oem: $oem, bufferinput: $bufferinput, nobufferinput: $nobufferinput, buffersize: $buffersize, koc: $koc, dru: $dru, norollup: $norollup, rollUp: $rollUp, delay: $delay, startat: $startat, endat: $endat, codec: $codec, nocodec: $nocodec, startcreditstext: $startcreditstext, startcreditsnotbefore: $startcreditsnotbefore, startcreditsnotafter: $startcreditsnotafter, startcreditsforatleast: $startcreditsforatleast, startcreditsforatmost: $startcreditsforatmost, endcreditstext: $endcreditstext, endcreditsforatleast: $endcreditsforatleast, endcreditsforatmost: $endcreditsforatmost, tpage: $tpage, teletext: $teletext, noteletext: $noteletext)';
674687
}
675688

676689
@override
@@ -720,7 +733,9 @@ class SettingsModel {
720733
other.trim == trim &&
721734
other.defaultcolor == defaultcolor &&
722735
other.sentencecap == sentencecap &&
736+
other.capFile == capFile &&
723737
other.kf == kf &&
738+
other.profanityFile == profanityFile &&
724739
other.splitbysentence == splitbysentence &&
725740
other.datets == datets &&
726741
other.sects == sects &&
@@ -808,7 +823,9 @@ class SettingsModel {
808823
trim.hashCode ^
809824
defaultcolor.hashCode ^
810825
sentencecap.hashCode ^
826+
capFile.hashCode ^
811827
kf.hashCode ^
828+
profanityFile.hashCode ^
812829
splitbysentence.hashCode ^
813830
datets.hashCode ^
814831
sects.hashCode ^

lib/screens/settings/basic_settings.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ class BasicSettingsScreen extends StatelessWidget {
5454
text: state.settingsModel.endcreditsforatmost);
5555
return Scaffold(
5656
appBar: AppBar(
57-
title: CurrentCommandContainer(),
57+
flexibleSpace: FlexibleSpaceBar(
58+
title: CurrentCommandContainer(),
59+
titlePadding:
60+
const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
61+
),
5862
elevation: 0,
59-
toolbarHeight: 100,
63+
toolbarHeight: 120,
6064
backgroundColor: Colors.transparent,
6165
),
6266
body: Padding(

lib/screens/settings/components/current_command.dart

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class CurrentCommandContainer extends StatelessWidget {
2222
List<String> paramsList = settingsRepository.getParamsList(settings);
2323
return Column(
2424
mainAxisSize: MainAxisSize.max,
25+
mainAxisAlignment: MainAxisAlignment.center,
2526
crossAxisAlignment: CrossAxisAlignment.start,
2627
children: [
2728
Row(
@@ -58,20 +59,24 @@ class CurrentCommandContainer extends StatelessWidget {
5859
],
5960
),
6061
SizedBox(height: 12),
61-
Container(
62-
width: Responsive.isDesktop(context)
63-
? MediaQuery.of(context).size.width - 270
64-
: MediaQuery.of(context).size.width -
65-
56, // remove drawer width
66-
decoration: BoxDecoration(
67-
color: kBgLightColor,
68-
),
69-
child: Padding(
70-
padding: const EdgeInsets.all(8.0),
71-
child: SelectableText(
72-
'ccextractor --gui_mode_reports ${paramsList.reduce((value, element) => value + ' ' + element)} +[input files]',
73-
style: TextStyle(
74-
fontSize: 15,
62+
SingleChildScrollView(
63+
scrollDirection: Axis.vertical,
64+
child: Container(
65+
width: Responsive.isDesktop(context)
66+
? MediaQuery.of(context).size.width - 270
67+
: MediaQuery.of(context).size.width -
68+
56, // remove drawer width
69+
decoration: BoxDecoration(
70+
color: kBgLightColor,
71+
),
72+
child: Padding(
73+
padding: const EdgeInsets.all(8.0),
74+
child: SelectableText(
75+
'ccextractor --gui_mode_reports ${paramsList.reduce((value, element) => value + ' ' + element)} +[input files]',
76+
maxLines: 2,
77+
style: TextStyle(
78+
fontSize: 15,
79+
),
7580
),
7681
),
7782
),
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import 'package:flutter/material.dart';
2+
3+
import 'package:file_selector/file_selector.dart';
4+
import 'package:file_selector_platform_interface/file_selector_platform_interface.dart';
5+
6+
import 'package:ccxgui/utils/constants.dart';
7+
import 'package:ccxgui/utils/responsive.dart';
8+
9+
class CustomGetFilePathButton extends StatefulWidget {
10+
final String title;
11+
final String subtitle;
12+
final String currentPath;
13+
final Function(String path) saveToConfig;
14+
final VoidCallback clearField;
15+
const CustomGetFilePathButton({
16+
Key? key,
17+
required this.title,
18+
required this.subtitle,
19+
required this.saveToConfig,
20+
required this.currentPath,
21+
required this.clearField,
22+
}) : super(key: key);
23+
24+
@override
25+
_CustomGetFilePathButtonState createState() =>
26+
_CustomGetFilePathButtonState();
27+
}
28+
29+
class _CustomGetFilePathButtonState extends State<CustomGetFilePathButton> {
30+
String path = '';
31+
32+
void _getFilePath(BuildContext context) async {
33+
final XFile? file = await FileSelectorPlatform.instance.openFile();
34+
if (file == null) {
35+
// Operation was canceled by the user.
36+
return;
37+
}
38+
widget.saveToConfig(file.path);
39+
40+
setState(() {
41+
path = file.path;
42+
});
43+
}
44+
45+
final ScrollController _scrollController = ScrollController();
46+
@override
47+
Widget build(BuildContext context) {
48+
_scrollController.hasClients
49+
? _scrollController.animateTo(
50+
0.0,
51+
curve: Curves.easeOut,
52+
duration: const Duration(milliseconds: 300),
53+
)
54+
: null;
55+
path = widget.currentPath;
56+
if (path.isEmpty) path = 'Browse';
57+
return ListTile(
58+
title: Text(widget.title),
59+
subtitle: Text(widget.subtitle),
60+
trailing: MouseRegion(
61+
cursor: SystemMouseCursors.click,
62+
child: Container(
63+
width: Responsive.isDesktop(context) ? 300 : 100,
64+
child: Row(
65+
children: [
66+
Tooltip(
67+
message: 'Clear field',
68+
child: IconButton(
69+
padding: EdgeInsets.zero,
70+
onPressed: widget.clearField,
71+
icon: Icon(Icons.delete_outline),
72+
color: Colors.red,
73+
)),
74+
SizedBox(
75+
width: 10,
76+
),
77+
Container(
78+
width: Responsive.isDesktop(context) ? 250 : 50,
79+
height: 46,
80+
color: kBgLightColor,
81+
child: MaterialButton(
82+
onPressed: () async {
83+
_getFilePath(context);
84+
},
85+
child: SingleChildScrollView(
86+
reverse: true,
87+
controller: _scrollController,
88+
scrollDirection: Axis.horizontal,
89+
child: Text(
90+
path,
91+
maxLines: 3,
92+
),
93+
),
94+
),
95+
),
96+
],
97+
),
98+
),
99+
),
100+
);
101+
}
102+
}

lib/screens/settings/input_settings.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ class InputSettingsScreen extends StatelessWidget {
3737
TextEditingController(text: state.settingsModel.maxlevdist);
3838
return Scaffold(
3939
appBar: AppBar(
40-
title: CurrentCommandContainer(),
40+
flexibleSpace: FlexibleSpaceBar(
41+
title: CurrentCommandContainer(),
42+
titlePadding:
43+
const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
44+
),
4145
elevation: 0,
42-
toolbarHeight: 100,
46+
toolbarHeight: 150,
4347
backgroundColor: Colors.transparent,
4448
),
4549
body: Padding(

lib/screens/settings/obscure_settings.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ class ObscureSettingsScreen extends StatelessWidget {
2929
TextEditingController(text: state.settingsModel.program_number);
3030
return Scaffold(
3131
appBar: AppBar(
32-
title: CurrentCommandContainer(),
32+
flexibleSpace: FlexibleSpaceBar(
33+
title: CurrentCommandContainer(),
34+
titlePadding:
35+
const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
36+
),
3337
elevation: 0,
34-
toolbarHeight: 100,
38+
toolbarHeight: 150,
3539
backgroundColor: Colors.transparent,
3640
),
3741
body: Padding(

lib/screens/settings/output_settings.dart

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:ccxgui/screens/settings/components/current_command.dart';
99
import 'package:ccxgui/utils/constants.dart';
1010
import 'components/custom_divider.dart';
1111
import 'components/custom_dropdown.dart';
12+
import 'components/custom_path_button.dart';
1213
import 'components/custom_swtich_listTile.dart';
1314
import 'components/custom_textfield.dart';
1415

@@ -38,9 +39,13 @@ class OutputSettingsScreen extends StatelessWidget {
3839
TextEditingController(text: state.settingsModel.buffersize);
3940
return Scaffold(
4041
appBar: AppBar(
41-
title: CurrentCommandContainer(),
42+
flexibleSpace: FlexibleSpaceBar(
43+
title: CurrentCommandContainer(),
44+
titlePadding:
45+
const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
46+
),
4247
elevation: 0,
43-
toolbarHeight: 100,
48+
toolbarHeight: 150,
4449
backgroundColor: Colors.transparent,
4550
),
4651
body: Padding(
@@ -231,6 +236,30 @@ class OutputSettingsScreen extends StatelessWidget {
231236
);
232237
},
233238
),
239+
CustomGetFilePathButton(
240+
title: 'Profanity file',
241+
subtitle:
242+
"Add the contents of 'file' to the list of words, that must be censored",
243+
currentPath: state.settingsModel.profanityFile,
244+
clearField: () {
245+
context.read<SettingsBloc>().add(
246+
SettingsUpdatedEvent(
247+
state.settingsModel.copyWith(
248+
profanityFile: '',
249+
),
250+
),
251+
);
252+
},
253+
saveToConfig: (String filePath) {
254+
context.read<SettingsBloc>().add(
255+
SettingsUpdatedEvent(
256+
state.settingsModel.copyWith(
257+
profanityFile: filePath,
258+
),
259+
),
260+
);
261+
},
262+
),
234263
CustomSwitchListTile(
235264
title: 'Split by sentence',
236265
subtitle:
@@ -246,6 +275,30 @@ class OutputSettingsScreen extends StatelessWidget {
246275
);
247276
},
248277
),
278+
CustomGetFilePathButton(
279+
title: 'Sentence cap file',
280+
subtitle:
281+
"Add the contents of 'file' to the list of words, that must be capitalized.",
282+
currentPath: state.settingsModel.capFile,
283+
clearField: () {
284+
context.read<SettingsBloc>().add(
285+
SettingsUpdatedEvent(
286+
state.settingsModel.copyWith(
287+
capFile: '',
288+
),
289+
),
290+
);
291+
},
292+
saveToConfig: (String filePath) {
293+
context.read<SettingsBloc>().add(
294+
SettingsUpdatedEvent(
295+
state.settingsModel.copyWith(
296+
capFile: filePath,
297+
),
298+
),
299+
);
300+
},
301+
),
249302
CustomSwitchListTile(
250303
title: 'Transcript dates.',
251304
subtitle:

0 commit comments

Comments
 (0)