]> granicus.if.org Git - handbrake/commitdiff
WinGui: Added option to AutoName functionality to remove common punctuation from...
authorsr55 <sr55.hb@outlook.com>
Sat, 1 Jun 2013 21:28:05 +0000 (21:28 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 1 Jun 2013 21:28:05 +0000 (21:28 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5542 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
win/CS/HandBrakeWPF/UserSettingConstants.cs
win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
win/CS/HandBrakeWPF/Views/OptionsView.xaml
win/CS/HandBrakeWPF/defaultsettings.xml

index 2298eb4aba307119399023b9208967febb238fcf..4077480273a3a38b7feeffc21d68962424eef2df 100644 (file)
@@ -47,7 +47,7 @@ namespace HandBrakeWPF.Helpers
             }\r
 \r
             string autoNamePath = string.Empty;\r
-            if (task.Title != 0) // TODO check.\r
+            if (task.Title != 0)\r
             {\r
                 // Get the Source Name and remove any invalid characters\r
                 string sourceName = Path.GetInvalidFileNameChars().Aggregate(sourceOrLabelName, (current, character) => current.Replace(character.ToString(), string.Empty));\r
@@ -56,6 +56,13 @@ namespace HandBrakeWPF.Helpers
                 if (userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameRemoveUnderscore))\r
                     sourceName = sourceName.Replace("_", " ");\r
 \r
+                if (userSettingService.GetUserSetting<bool>(UserSettingConstants.RemovePunctuation))\r
+                {\r
+                    sourceName = sourceName.Replace("-", string.Empty);\r
+                    sourceName = sourceName.Replace(",", string.Empty);\r
+                    sourceName = sourceName.Replace(".", string.Empty); \r
+                }\r
+                  \r
                 // Switch to "Title Case"\r
                 if (userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameTitleCase))\r
                     sourceName = sourceName.ToTitleCase();\r
@@ -170,21 +177,16 @@ namespace HandBrakeWPF.Helpers
         public static bool IsAutonamingEnabled()\r
         {\r
             IUserSettingService userSettingService = IoC.Get<IUserSettingService>();\r
-            // If there is an auto name path, use it...\r
-            if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}"))\r
-            {\r
-                return true;\r
-            }\r
-            else if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}"))\r
-            {\r
-                return true;\r
-            }\r
-            else\r
+\r
+            if (!userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNaming))\r
             {\r
-                return\r
-                    Directory.Exists(\r
-                        userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim());\r
+                return false;\r
             }\r
+\r
+            // If there is an auto name path, use it...\r
+            return userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}") ||\r
+                (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}") ||\r
+                 Directory.Exists(userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim()));\r
         }\r
     }\r
 }\r
index b70d8865485e3cfa440b9e9921853085fc08ab5f..4ab98cdfde18eb0f21bceb1050ff7994dca17bfd 100644 (file)
@@ -226,6 +226,11 @@ namespace HandBrakeWPF
         /// </summary>\r
         public const string PreventSleep = "PreventSleep";\r
 \r
+        /// <summary>\r
+        /// The remove punctuation.\r
+        /// </summary>\r
+        public const string RemovePunctuation = "RemovePunctuation";\r
+\r
         #endregion\r
     }\r
 }
\ No newline at end of file
index ad012db4fe6b6e7d1ffe848c1e5342ae525b3505..dc9f6806b9e47e7ae93c406b4d6ccab6598e03a5 100644 (file)
@@ -353,6 +353,11 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         private bool showAdvancedTab;\r
 \r
+        /// <summary>\r
+        /// The remove punctuation.\r
+        /// </summary>\r
+        private bool removePunctuation;\r
+\r
         #endregion\r
 \r
         #region Constructors and Destructors\r
@@ -722,6 +727,22 @@ namespace HandBrakeWPF.ViewModels
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Gets or sets a value indicating whether remove punctuation.\r
+        /// </summary>\r
+        public bool RemovePunctuation\r
+        {\r
+            get\r
+            {\r
+                return this.removePunctuation;\r
+            }\r
+            set\r
+            {\r
+                this.removePunctuation = value;\r
+                this.NotifyOfPropertyChange(() => RemovePunctuation);\r
+            }\r
+        }\r
+\r
         #endregion\r
 \r
         #region Preview\r
@@ -1521,6 +1542,7 @@ namespace HandBrakeWPF.ViewModels
 \r
             // Title case\r
             this.ChangeToTitleCase = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameTitleCase);\r
+            this.RemovePunctuation = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.RemovePunctuation);\r
 \r
             // #############################\r
             // Picture Tab\r
@@ -1836,6 +1858,7 @@ namespace HandBrakeWPF.ViewModels
             this.userSettingService.SetUserSetting(UserSettingConstants.UseM4v, this.SelectedMp4Extension);\r
             this.userSettingService.SetUserSetting(UserSettingConstants.AutoNameRemoveUnderscore, this.RemoveUnderscores);\r
             this.userSettingService.SetUserSetting(UserSettingConstants.AutoNameTitleCase, this.ChangeToTitleCase);\r
+            this.userSettingService.SetUserSetting(UserSettingConstants.RemovePunctuation, this.RemovePunctuation);\r
 \r
             /* Previews */\r
             this.userSettingService.SetUserSetting(UserSettingConstants.VLC_Path, this.VLCPath);\r
index 31fa1e8fdbc90849fd2412d318977af4594d7761..dcf9994c8b8f497f4a10c0209f964a6b1c16e0ee 100644 (file)
                             <TextBlock Text="Available Options: {source} {title} {chapters} {date}" />\r
 \r
                             <StackPanel Orientation="Horizontal" Margin="0,15,0,0">\r
-                                <CheckBox Content="Remove underscores from name" IsChecked="{Binding RemoveUnderscores}"/>\r
+                                <CheckBox Content="Replace underscores with a space" IsChecked="{Binding RemoveUnderscores}"/>\r
+                                <CheckBox Content="Remove common punctuation" ToolTip="Dash (-), Period (.) and Comma (,) " IsChecked="{Binding RemovePunctuation}"  Margin="5,0,0,0"/>\r
                                 <CheckBox Content="Change case to Title Case" IsChecked="{Binding ChangeToTitleCase}" Margin="5,0,0,0" />\r
                             </StackPanel>\r
 \r
index 10480d486ebd2a65e28e2cabc223544b3f554f7d..f7c04f4fb90ef12526586224f7ea374c4ad20b55 100644 (file)
       <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>\r
     </value>\r
   </item>\r
+  <item>\r
+    <key>\r
+      <string>RemovePunctuation</string>\r
+    </key>\r
+    <value>\r
+      <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>\r
+    </value>\r
+  </item>\r
 </dictionary>
\ No newline at end of file