summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
authorsr55 <[email protected]>2019-04-21 16:57:54 +0100
committersr55 <[email protected]>2019-04-21 16:57:54 +0100
commitf91daa70b55b50ad1195ea835509178e35555d11 (patch)
treee30c3394bb4d424a24fcc9d4b09a2b7a5b98ec24 /win/CS/HandBrakeWPF/ViewModels
parent37813cfb2ab9def39064c0d62b239ea8a3cdf668 (diff)
WinGui: Auto-name System will now always generate a unique filename. The Prefix is now a configurable Pre/Postfix in preferences. "(1)" will always be appended with an appropriate number where a collision occurs.
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs61
1 files changed, 60 insertions, 1 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
index f04ecbff9..3090a8144 100644
--- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
@@ -106,6 +106,11 @@ namespace HandBrakeWPF.ViewModels
private bool showAddSelectionToQueue;
private bool showAddAllToQueue;
private int selectedOverwriteBehaviour;
+ private int selectedCollisionBehaviour;
+
+ private string prePostFilenameText;
+
+ private bool showPrePostFilenameBox;
#endregion
@@ -661,6 +666,49 @@ namespace HandBrakeWPF.ViewModels
}
}
+ public BindingList<AutonameFileCollisionBehaviour> AutonameFileCollisionBehaviours { get; set; }
+
+ public int SelectedCollisionBehaviour
+ {
+ get => this.selectedCollisionBehaviour;
+ set
+ {
+ if (value == this.selectedCollisionBehaviour) return;
+ this.selectedCollisionBehaviour = value;
+
+ this.ShowPrePostFilenameBox = this.selectedCollisionBehaviour >= 1;
+
+ this.NotifyOfPropertyChange(() => this.SelectedCollisionBehaviour);
+ }
+ }
+
+ public string PrePostFilenameText
+ {
+ get => this.prePostFilenameText;
+ set
+ {
+ if (value == this.prePostFilenameText) return;
+
+ if (this.IsValidAutonameFormat(value, false))
+ {
+ this.prePostFilenameText = value;
+ }
+
+ this.NotifyOfPropertyChange(() => this.PrePostFilenameText);
+ }
+ }
+
+ public bool ShowPrePostFilenameBox
+ {
+ get => this.showPrePostFilenameBox;
+ set
+ {
+ if (value == this.showPrePostFilenameBox) return;
+ this.showPrePostFilenameBox = value;
+ this.NotifyOfPropertyChange(() => this.ShowPrePostFilenameBox);
+ }
+ }
+
#endregion
#region Preview
@@ -1445,9 +1493,13 @@ namespace HandBrakeWPF.ViewModels
this.FileOverwriteBehaviourList = new BindingList<FileOverwriteBehaviour>();
this.FileOverwriteBehaviourList.Add(FileOverwriteBehaviour.Ask);
this.FileOverwriteBehaviourList.Add(FileOverwriteBehaviour.ForceOverwrite);
- // this.FileOverwriteBehaviourList.Add(FileOverwriteBehaviour.Autoname);
this.SelectedOverwriteBehaviour = this.userSettingService.GetUserSetting<int>(UserSettingConstants.FileOverwriteBehaviour, typeof(int));
+ // Collision behaviour
+ this.AutonameFileCollisionBehaviours = new BindingList<AutonameFileCollisionBehaviour>() { AutonameFileCollisionBehaviour.AppendNumber, AutonameFileCollisionBehaviour.Prefix, AutonameFileCollisionBehaviour.Postfix };
+ this.SelectedCollisionBehaviour = this.userSettingService.GetUserSetting<int>(UserSettingConstants.AutonameFileCollisionBehaviour, typeof(int));
+ this.PrePostFilenameText = this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutonameFilePrePostString);
+
// #############################
// Picture Tab
// #############################
@@ -1598,6 +1650,8 @@ namespace HandBrakeWPF.ViewModels
this.userSettingService.SetUserSetting(UserSettingConstants.AutoNameTitleCase, this.ChangeToTitleCase);
this.userSettingService.SetUserSetting(UserSettingConstants.RemovePunctuation, this.RemovePunctuation);
this.userSettingService.SetUserSetting(UserSettingConstants.FileOverwriteBehaviour, this.SelectedOverwriteBehaviour);
+ this.userSettingService.SetUserSetting(UserSettingConstants.AutonameFileCollisionBehaviour, this.SelectedCollisionBehaviour);
+ this.userSettingService.SetUserSetting(UserSettingConstants.AutonameFilePrePostString, this.PrePostFilenameText);
/* Previews */
this.userSettingService.SetUserSetting(UserSettingConstants.VLCPath, this.VLCPath);
@@ -1712,6 +1766,11 @@ namespace HandBrakeWPF.ViewModels
/// <returns>True if valid</returns>
private bool IsValidAutonameFormat(string input, bool isSilent)
{
+ if (string.IsNullOrEmpty(input))
+ {
+ return true;
+ }
+
char[] invalidchars = Path.GetInvalidFileNameChars();
Array.Sort(invalidchars);
foreach (var characterToTest in input)