summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF
diff options
context:
space:
mode:
authorsr55 <[email protected]>2013-06-01 21:28:05 +0000
committersr55 <[email protected]>2013-06-01 21:28:05 +0000
commit0c65f4f74c61edb71ef7fbb03be0e0b3c932d810 (patch)
tree0e6b847b6861f0d03a0a63cb93b4f7844c868997 /win/CS/HandBrakeWPF
parent0b38ee2d844b915314b9731fd2b2ea4906e6439b (diff)
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
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r--win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs30
-rw-r--r--win/CS/HandBrakeWPF/UserSettingConstants.cs5
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs23
-rw-r--r--win/CS/HandBrakeWPF/Views/OptionsView.xaml3
-rw-r--r--win/CS/HandBrakeWPF/defaultsettings.xml8
5 files changed, 54 insertions, 15 deletions
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<bool>(UserSettingConstants.AutoNameRemoveUnderscore))
sourceName = sourceName.Replace("_", " ");
+ if (userSettingService.GetUserSetting<bool>(UserSettingConstants.RemovePunctuation))
+ {
+ sourceName = sourceName.Replace("-", string.Empty);
+ sourceName = sourceName.Replace(",", string.Empty);
+ sourceName = sourceName.Replace(".", string.Empty);
+ }
+
// Switch to "Title Case"
if (userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameTitleCase))
sourceName = sourceName.ToTitleCase();
@@ -170,21 +177,16 @@ namespace HandBrakeWPF.Helpers
public static bool IsAutonamingEnabled()
{
IUserSettingService userSettingService = IoC.Get<IUserSettingService>();
- // If there is an auto name path, use it...
- if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}"))
- {
- return true;
- }
- else if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}"))
- {
- return true;
- }
- else
+
+ if (!userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNaming))
{
- return
- Directory.Exists(
- userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim());
+ return false;
}
+
+ // If there is an auto name path, use it...
+ return userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}") ||
+ (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}") ||
+ Directory.Exists(userSettingService.GetUserSetting<string>(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
/// </summary>
public const string PreventSleep = "PreventSleep";
+ /// <summary>
+ /// The remove punctuation.
+ /// </summary>
+ 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
/// </summary>
private bool showAdvancedTab;
+ /// <summary>
+ /// The remove punctuation.
+ /// </summary>
+ private bool removePunctuation;
+
#endregion
#region Constructors and Destructors
@@ -722,6 +727,22 @@ namespace HandBrakeWPF.ViewModels
}
}
+ /// <summary>
+ /// Gets or sets a value indicating whether remove punctuation.
+ /// </summary>
+ 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<bool>(UserSettingConstants.AutoNameTitleCase);
+ this.RemovePunctuation = this.userSettingService.GetUserSetting<bool>(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 @@
<TextBlock Text="Available Options: {source} {title} {chapters} {date}" />
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
- <CheckBox Content="Remove underscores from name" IsChecked="{Binding RemoveUnderscores}"/>
+ <CheckBox Content="Replace underscores with a space" IsChecked="{Binding RemoveUnderscores}"/>
+ <CheckBox Content="Remove common punctuation" ToolTip="Dash (-), Period (.) and Comma (,) " IsChecked="{Binding RemovePunctuation}" Margin="5,0,0,0"/>
<CheckBox Content="Change case to Title Case" IsChecked="{Binding ChangeToTitleCase}" Margin="5,0,0,0" />
</StackPanel>
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 @@
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>
</value>
</item>
+ <item>
+ <key>
+ <string>RemovePunctuation</string>
+ </key>
+ <value>
+ <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>
+ </value>
+ </item>
</dictionary> \ No newline at end of file