Skip to content

Commit

Permalink
优化同步文件修改时间功能为任务级别参数
Browse files Browse the repository at this point in the history
  • Loading branch information
autodotua committed Jun 23, 2023
1 parent 8f0f26e commit 24e2a5d
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 224 deletions.
6 changes: 0 additions & 6 deletions SimpleFFmpegGUI.Core/Manager/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace SimpleFFmpegGUI.Manager
public static class ConfigManager
{
public const string DefaultProcessPriorityKey = "DefaultProcessPriority";
public const string SyncModifiedTimeKey = "SyncModifiedTime";
private static readonly Dictionary<string, object> cache = new Dictionary<string, object>();

public static int DefaultProcessPriority
Expand All @@ -20,11 +19,6 @@ public static int DefaultProcessPriority
set => SetConfig(DefaultProcessPriorityKey, value);
}

public static bool SyncModifiedTime
{
get => GetConfig(SyncModifiedTimeKey, true);
set => SetConfig(SyncModifiedTimeKey, value);
}
public static T GetConfig<T>(string key, T defaultValue)
{
if (cache.ContainsKey(key))
Expand Down
6 changes: 3 additions & 3 deletions SimpleFFmpegGUI.Core/Manager/FFmpegManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ public async Task RunAsync()
});


if (task.RealOutput!=null && File.Exists(task.RealOutput) && ConfigManager.SyncModifiedTime)
if (task.RealOutput != null && File.Exists(task.RealOutput) && task.Arguments.SyncModifiedTime)
{
try
{
File.SetLastWriteTime(task.RealOutput, File.GetLastWriteTime(task.Inputs[^1].FilePath));
}
catch(Exception ex)
catch (Exception ex)
{
logger.Error(task, "修改输出文件的修改时间失败:"+ex.Message);
logger.Error(task, "修改输出文件的修改时间失败:" + ex.Message);
}
}

Expand Down
5 changes: 5 additions & 0 deletions SimpleFFmpegGUI.Core/Model/OutputArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,10 @@ public VideoCodeArguments Video
get => video;
set => this.SetValueAndNotify(ref video, value, nameof(Video));
}

/// <summary>
/// 将输出文件的修改时间设置为最后一个输入文件的修改时间
/// </summary>
public bool SyncModifiedTime { get; set; }
}
}
1 change: 0 additions & 1 deletion SimpleFFmpegGUI.WPF/Model/UITaskInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ private async void StartTimer()
Stopwatch sw = Stopwatch.StartNew();
await UpdateSnapshotAsync();
sw.Stop();
Debug.WriteLine(sw.ElapsedMilliseconds);
}
}

Expand Down
22 changes: 15 additions & 7 deletions SimpleFFmpegGUI.WPF/Panels/CodeArgumentsPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,21 @@
IsChecked="{Binding Combine.Shortest}" />
</GroupBox>
<!-- 额外参数 -->
<GroupBox Header="额外参数">
<TextBox
ui:ControlHelper.PlaceholderText="请输入ffmpeg参数"
MaxLines="3"
MinLines="3"
Text="{Binding Extra, UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap" />
<GroupBox Header="其他">
<ui:SimpleStackPanel
Orientation="Vertical"
Spacing="8">
<TextBox
ui:ControlHelper.PlaceholderText="额外ffmpeg输出参数"
MaxLines="3"
MinLines="3"
Text="{Binding Extra, UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap" />
<CheckBox
Content="同步文件修改时间"
IsChecked="{Binding SyncModifiedTime}"
ToolTip="将输出文件的修改时间设置为最后一个输入文件的修改时间" />
</ui:SimpleStackPanel>
</GroupBox>
</ui:SimpleStackPanel>
</ScrollViewer>
Expand Down
Loading

0 comments on commit 24e2a5d

Please sign in to comment.