From 0c65f4f74c61edb71ef7fbb03be0e0b3c932d810 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 1 Jun 2013 21:28:05 +0000 Subject: WinGui: Added option to AutoName functionality to remove common punctuation from filenames (Comma, Period and Dash) git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5542 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs | 30 ++++++++++++---------- win/CS/HandBrakeWPF/UserSettingConstants.cs | 5 ++++ win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 23 +++++++++++++++++ win/CS/HandBrakeWPF/Views/OptionsView.xaml | 3 ++- win/CS/HandBrakeWPF/defaultsettings.xml | 8 ++++++ 5 files changed, 54 insertions(+), 15 deletions(-) (limited to 'win/CS/HandBrakeWPF') diff --git a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs index 2298eb4ab..407748027 100644 --- a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs +++ b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs @@ -47,7 +47,7 @@ namespace HandBrakeWPF.Helpers } string autoNamePath = string.Empty; - if (task.Title != 0) // TODO check. + if (task.Title != 0) { // Get the Source Name and remove any invalid characters string sourceName = Path.GetInvalidFileNameChars().Aggregate(sourceOrLabelName, (current, character) => current.Replace(character.ToString(), string.Empty)); @@ -56,6 +56,13 @@ namespace HandBrakeWPF.Helpers if (userSettingService.GetUserSetting(UserSettingConstants.AutoNameRemoveUnderscore)) sourceName = sourceName.Replace("_", " "); + if (userSettingService.GetUserSetting(UserSettingConstants.RemovePunctuation)) + { + sourceName = sourceName.Replace("-", string.Empty); + sourceName = sourceName.Replace(",", string.Empty); + sourceName = sourceName.Replace(".", string.Empty); + } + // Switch to "Title Case" if (userSettingService.GetUserSetting(UserSettingConstants.AutoNameTitleCase)) sourceName = sourceName.ToTitleCase(); @@ -170,21 +177,16 @@ namespace HandBrakeWPF.Helpers public static bool IsAutonamingEnabled() { IUserSettingService userSettingService = IoC.Get(); - // If there is an auto name path, use it... - if (userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}")) - { - return true; - } - else if (userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}")) - { - return true; - } - else + + if (!userSettingService.GetUserSetting(UserSettingConstants.AutoNaming)) { - return - Directory.Exists( - userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Trim()); + return false; } + + // If there is an auto name path, use it... + return userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}") || + (userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}") || + Directory.Exists(userSettingService.GetUserSetting(UserSettingConstants.AutoNamePath).Trim())); } } } diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index b70d88654..4ab98cdfd 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -226,6 +226,11 @@ namespace HandBrakeWPF /// public const string PreventSleep = "PreventSleep"; + /// + /// The remove punctuation. + /// + public const string RemovePunctuation = "RemovePunctuation"; + #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index ad012db4f..dc9f6806b 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -353,6 +353,11 @@ namespace HandBrakeWPF.ViewModels /// private bool showAdvancedTab; + /// + /// The remove punctuation. + /// + private bool removePunctuation; + #endregion #region Constructors and Destructors @@ -722,6 +727,22 @@ namespace HandBrakeWPF.ViewModels } } + /// + /// Gets or sets a value indicating whether remove punctuation. + /// + public bool RemovePunctuation + { + get + { + return this.removePunctuation; + } + set + { + this.removePunctuation = value; + this.NotifyOfPropertyChange(() => RemovePunctuation); + } + } + #endregion #region Preview @@ -1521,6 +1542,7 @@ namespace HandBrakeWPF.ViewModels // Title case this.ChangeToTitleCase = this.userSettingService.GetUserSetting(UserSettingConstants.AutoNameTitleCase); + this.RemovePunctuation = this.userSettingService.GetUserSetting(UserSettingConstants.RemovePunctuation); // ############################# // Picture Tab @@ -1836,6 +1858,7 @@ namespace HandBrakeWPF.ViewModels this.userSettingService.SetUserSetting(UserSettingConstants.UseM4v, this.SelectedMp4Extension); this.userSettingService.SetUserSetting(UserSettingConstants.AutoNameRemoveUnderscore, this.RemoveUnderscores); this.userSettingService.SetUserSetting(UserSettingConstants.AutoNameTitleCase, this.ChangeToTitleCase); + this.userSettingService.SetUserSetting(UserSettingConstants.RemovePunctuation, this.RemovePunctuation); /* Previews */ this.userSettingService.SetUserSetting(UserSettingConstants.VLC_Path, this.VLCPath); diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml index 31fa1e8fd..dcf9994c8 100644 --- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml +++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml @@ -163,7 +163,8 @@ - + + diff --git a/win/CS/HandBrakeWPF/defaultsettings.xml b/win/CS/HandBrakeWPF/defaultsettings.xml index 10480d486..f7c04f4fb 100644 --- a/win/CS/HandBrakeWPF/defaultsettings.xml +++ b/win/CS/HandBrakeWPF/defaultsettings.xml @@ -448,4 +448,12 @@ false + + + RemovePunctuation + + + false + + \ No newline at end of file -- cgit v1.2.3