Skip to content

Commit

Permalink
feat: add file conflict filter option
Browse files Browse the repository at this point in the history
- Introduced FileConflictFilter property in Config.cs
- Updated ImportService to conditionally solve subtitle conflicts
- Added FileConflictFilter binding in SettingsViewModel
- Ensured new setting is saved and retrieved correctly
  • Loading branch information
qwqcode committed Sep 24, 2024
1 parent 8512a2e commit 8f3485f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
1 change: 1 addition & 0 deletions SubRenamer/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public partial class Config
public bool UpdateCheck { get; set; } = true;
public bool KeepLangExt { get; set; } = false;
public string CustomLangExt { get; set; } = "";
public bool FileConflictFilter { get; set; } = true;
public string VideoExtAppend { get; set; } = "";
public string SubtitleExtAppend { get; set; } = "";

Expand Down
5 changes: 3 additions & 2 deletions SubRenamer/Services/ImportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public async Task ImportMultipleFiles(
var (videos, subtitles) = FilesGroupByType(files);

// Solve subtitle conflict
subtitles = await SolveSubtitleConflict(subtitles, onOpenSolveConflictDialog);

if (Config.Get().FileConflictFilter)
subtitles = await SolveSubtitleConflict(subtitles, onOpenSolveConflictDialog);

// Import to list
dataSource.Clear();
videos.ForEach(x => dataSource.Add(new MatchItem("", x, "", "")));
Expand Down
12 changes: 12 additions & 0 deletions SubRenamer/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public partial class SettingsViewModel : ViewModelBase
private bool _updateCheckEnabled = Config.Get().UpdateCheck;
private bool _keepLangExt = Config.Get().KeepLangExt;
private bool _customLangExtEnabled = !string.IsNullOrEmpty(Config.Get().CustomLangExt);
private bool _fileConflictFilterEnabled = Config.Get().FileConflictFilter;
private string _customLangExt = Config.Get().CustomLangExt;
private string _videoExtAppend = Config.Get().VideoExtAppend;
private string _subtitleExtAppend = Config.Get().SubtitleExtAppend;
Expand Down Expand Up @@ -78,6 +79,17 @@ public string CustomLangExt
SetProperty(ref _customLangExt, value);
}
}

public bool FileConflictFilter
{
get => _fileConflictFilterEnabled;
set
{
Config.Get().FileConflictFilter = value;
SetProperty(ref _fileConflictFilterEnabled, value);
}
}

public string VideoExtAppend
{
get => _videoExtAppend;
Expand Down
19 changes: 10 additions & 9 deletions SubRenamer/Views/SettingsWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,30 @@

<StackPanel Margin="20">
<CheckBox IsChecked="{Binding BackupEnabled}">备份原始字幕</CheckBox>
<Label Foreground="Gray" Margin="30 0 30 10" FontSize="13" Padding="0">程序会复制字幕到视频目录,若目录相同则备份到 SubBackup</Label>
<Label Foreground="Gray" Margin="30 0 30 10" FontSize="13" Padding="0">若字幕和视频文件处于相同目录内,则备份到 SubBackup</Label>
<!-- <CheckBox>确认删除对话框</CheckBox> -->
<!-- <CheckBox>显示文件完整路径</CheckBox> -->
<CheckBox IsChecked="{Binding KeepLangExt}" IsEnabled="{Binding !CustomLangExtEnabled}">保留语言后缀</CheckBox>
<Label Foreground="Gray" Margin="30 0 30 10" FontSize="13" Padding="0">例如 "subtitle.sc.srt" 保留语言后缀 ".sc"</Label>
<CheckBox IsChecked="{Binding FileConflictFilter}">语言筛选对话框</CheckBox>
<Label Foreground="Gray" FontSize="13" Padding="0" Margin="30 0 30 10">检测到导入的字幕文件包含多种语言时,弹出语言筛选对话框</Label>
<CheckBox IsChecked="{Binding KeepLangExt}" IsEnabled="{Binding !CustomLangExtEnabled}">保留字幕语言后缀</CheckBox>
<Label Foreground="Gray" Margin="30 0 30 10" FontSize="13" Padding="0">例如 "subtitle.sc.srt" 保留字幕语言后缀 ".sc"</Label>
<CheckBox IsChecked="{Binding CustomLangExtEnabled}">追加字幕后缀</CheckBox>
<StackPanel Margin="30 0 0 0">
<Label Foreground="Gray" FontSize="13" Padding="0" Margin="0 0 0 10">在字幕文件扩展名前添加自定义后缀</Label>
<TextBox IsEnabled="{Binding CustomLangExtEnabled}" Watermark="输入后缀,例如:zh-Hans" Text="{Binding CustomLangExt}" />
</StackPanel>
<Border Height="15" />
<CheckBox IsChecked="{Binding FileClsExtAppendEnabled}">文件识别格式扩充</CheckBox>
<Label Foreground="Gray" Margin="30 0 30 8" FontSize="13" Padding="0">扩充用于识别视频和字幕文件格式的后缀名</Label>
<Label Foreground="Gray" Margin="30 0 30 8" FontSize="13" Padding="0">扩充用于识别字幕和视频文件格式的后缀名(以英文逗号分隔)</Label>
<Grid IsEnabled="{Binding FileClsExtAppendEnabled}" Margin="30 0 0 0" HorizontalAlignment="Stretch" ColumnDefinitions="*,10,*">
<StackPanel Grid.Column="0">
<TextBlock Margin="0 5 0 10" FontSize="13">视频格式扩充</TextBlock>
<TextBox Watermark="以逗号分隔" Text="{Binding VideoExtAppend}" />
<TextBlock Margin="0 5 0 10" FontSize="13">字幕格式扩充</TextBlock>
<TextBox Watermark="例如:srt" Text="{Binding SubtitleExtAppend}" />
</StackPanel>
<StackPanel Grid.Column="2">
<TextBlock Margin="0 5 0 10" FontSize="13">字幕格式扩充</TextBlock>
<TextBox Watermark="以逗号分隔" Text="{Binding SubtitleExtAppend}" />
<TextBlock Margin="0 5 0 10" FontSize="13">视频格式扩充</TextBlock>
<TextBox Watermark="例如:mkv" Text="{Binding VideoExtAppend}" />
</StackPanel>

</Grid>
<Border Height="15" />
<CheckBox IsChecked="{Binding UpdateCheckEnabled}">程序升级检查</CheckBox>
Expand Down

0 comments on commit 8f3485f

Please sign in to comment.