]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Sat, 30 Apr 2011 21:25:53 +0000 (21:25 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 30 Apr 2011 21:25:53 +0000 (21:25 +0000)
- Fix to the Audio Panel Track Display which was intermittently not showing a track.
- Fixed a number of bugs in the plist parser which was prevent imports.
- Fixed a number of Issues with the Preset Import/Export.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3972 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs
win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
win/CS/frmMain.cs

index 6a06586b2a1fdf168ac2c048c71458fc36c10c7a..bdc7805061be32dfb9ed801debe0f4f1a6e2321c 100644 (file)
@@ -73,6 +73,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding
             {\r
                 this.scannedTrack = value;\r
                 this.OnPropertyChanged("ScannedTrack");\r
+                this.OnPropertyChanged("TrackDisplay");\r
             }\r
         }\r
 \r
index 86cae01b5ce4bbdd2fe9ecea0cba4d50a33e18ac..7e17614f2a9dd0b269563a60cc24c350e9965b28 100644 (file)
@@ -1,4 +1,4 @@
-/*  PlistPresetHandler.cs $\r
+/*  PlistUtility.cs $\r
     This file is part of the HandBrake source code.\r
     Homepage: <http://handbrake.fr/>.\r
     It may be used under the terms of the GNU General Public License. */\r
@@ -65,7 +65,7 @@ namespace HandBrake.ApplicationServices.Utilities
                             track.MixDown = Converters.GetAudioMixDown(value.Trim());\r
                             break;\r
                         case "AudioSamplerate":\r
-                            track.SampleRate = double.Parse(value);\r
+                            track.SampleRate = value == "Auto" ? 0 : double.Parse(value);\r
                             break;\r
                         case "AudioTrack":\r
                            //track.SourceTrack = value;\r
@@ -92,7 +92,7 @@ namespace HandBrake.ApplicationServices.Utilities
 \r
                 switch (key)\r
                 {\r
-                    // Output Settings\r
+                        // Output Settings\r
                     case "FileFormat":\r
                         parsed.OutputFormat = Converters.GetFileFormat(value);\r
                         break;\r
@@ -106,7 +106,7 @@ namespace HandBrake.ApplicationServices.Utilities
                         parsed.IPod5GSupport = value == "1";\r
                         break;\r
 \r
-                    // Picture Settings\r
+                        // Picture Settings\r
                     case "PictureAutoCrop":\r
                         // Not used\r
                         break;\r
@@ -134,35 +134,38 @@ namespace HandBrake.ApplicationServices.Utilities
                     case "PicturePAR":\r
                         switch (value)\r
                         {\r
-                                \r
                             case "0":\r
                                 parsed.Anamorphic = Anamorphic.None;\r
                                 break;\r
                             default:\r
                                 parsed.Anamorphic = Anamorphic.Strict;\r
                                 break;\r
-                                case "2":\r
+                            case "2":\r
                                 parsed.Anamorphic = Anamorphic.Loose;\r
                                 break;\r
-                                case "3":\r
+                            case "3":\r
                                 parsed.Anamorphic = Anamorphic.Custom;\r
                                 break;\r
-\r
                         }\r
                         break;\r
 \r
-                    // Filters\r
+                        // Filters\r
                     case "PictureDeblock":\r
                         parsed.Deblock = int.Parse(value);\r
                         break;\r
                     case "PictureDecomb":\r
                         parsed.Decomb = Decomb.Off;\r
                         // Don't place custom here as it's handled in the filter panel\r
-                        if (value == "2") parsed.Decomb = Decomb.Default;\r
+                        if (value == "2")\r
+                        {\r
+                            parsed.Decomb = Decomb.Default;\r
+                        }\r
                         break;\r
                     case "PictureDecombCustom":\r
                         if (value != string.Empty)\r
+                        {\r
                             parsed.CustomDecomb = value;\r
+                        }\r
                         break;\r
                     case "PictureDecombDeinterlace":\r
                         // Not Used\r
@@ -173,7 +176,7 @@ namespace HandBrake.ApplicationServices.Utilities
                             case "0":\r
                                 parsed.Deinterlace = Deinterlace.Off;\r
                                 break;\r
-                            // Don't place custom here as it's handled in the filter panel\r
+                                // Don't place custom here as it's handled in the filter panel\r
                             case "2":\r
                                 parsed.Deinterlace = Deinterlace.Fast;\r
                                 break;\r
@@ -187,7 +190,9 @@ namespace HandBrake.ApplicationServices.Utilities
                         break;\r
                     case "PictureDeinterlaceCustom":\r
                         if (value != string.Empty)\r
+                        {\r
                             parsed.CustomDeinterlace = value;\r
+                        }\r
                         break;\r
                     case "PictureDenoise":\r
                         switch (value)\r
@@ -195,7 +200,7 @@ namespace HandBrake.ApplicationServices.Utilities
                             case "0":\r
                                 parsed.Denoise = Denoise.Off;\r
                                 break;\r
-                            // Don't place custom here as it's handled in the filter panel\r
+                                // Don't place custom here as it's handled in the filter panel\r
                             case "2":\r
                                 parsed.Denoise = Denoise.Weak;\r
                                 break;\r
@@ -210,26 +215,44 @@ namespace HandBrake.ApplicationServices.Utilities
                         break;\r
                     case "PictureDenoiseCustom":\r
                         if (value != string.Empty)\r
+                        {\r
                             parsed.CustomDenoise = value;\r
+                        }\r
                         break;\r
                     case "PictureDetelecine":\r
                         parsed.Detelecine = Detelecine.Off;\r
-                        if (value == "1") parsed.Detelecine = Detelecine.Default;\r
+                        if (value == "1")\r
+                        {\r
+                            parsed.Detelecine = Detelecine.Default;\r
+                        }\r
                         break;\r
                     case "PictureDetelecineCustom":\r
                         if (value != string.Empty)\r
+                        {\r
                             parsed.CustomDetelecine = value;\r
+                        }\r
                         break;\r
 \r
-                    // Video Tab\r
+                        // Video Tab\r
                     case "VideoAvgBitrate":\r
-                        parsed.VideoBitrate = int.Parse(value);\r
+                        if (!string.IsNullOrEmpty(value))\r
+                        {\r
+                            parsed.VideoBitrate = int.Parse(value);\r
+                        }\r
                         break;\r
                     case "VideoEncoder":\r
                         parsed.VideoEncoder = Converters.GetVideoEncoder(value);\r
                         break;\r
                     case "VideoFramerate":\r
-                        parsed.Framerate = int.Parse(value);\r
+\r
+                        if (value == "Same as source")\r
+                        {\r
+                            parsed.Framerate = null;\r
+                        }\r
+                        else if (!string.IsNullOrEmpty(value))\r
+                        {\r
+                            parsed.Framerate = int.Parse(value);\r
+                        }\r
                         break;\r
                     case "VideoGrayScale":\r
                         parsed.Grayscale = value == "1";\r
@@ -247,17 +270,17 @@ namespace HandBrake.ApplicationServices.Utilities
                         parsed.TwoPass = value == "1";\r
                         break;\r
 \r
-                    // Chapter Markers Tab\r
+                        // Chapter Markers Tab\r
                     case "ChapterMarkers":\r
                         parsed.IncludeChapterMarkers = value == "1";\r
                         break;\r
 \r
-                    // Advanced x264 tab\r
+                        // Advanced x264 tab\r
                     case "x264Option":\r
                         parsed.AdvancedEncoderOptions = value;\r
                         break;\r
 \r
-                    // Preset Information\r
+                        // Preset Information\r
                     case "PresetBuildNumber":\r
                         parsed.PresetBuildNumber = int.Parse(value);\r
                         break;\r
index 10cd69952f4a1a623d7703c298aa72460c2b89a8..1b053150c44265f8e05cfa67dc249d6bf23c53f4 100644 (file)
@@ -589,7 +589,7 @@ namespace Handbrake
 \r
             // Now enable the save menu if the selected preset is a user preset\r
             if (treeView_presets.SelectedNode != null)\r
-                    pmnu_saveChanges.Enabled = presetHandler.CanUpdatePreset(treeView_presets.SelectedNode.Text);\r
+                pmnu_saveChanges.Enabled = presetHandler.CanUpdatePreset(treeView_presets.SelectedNode.Text);\r
 \r
             treeView_presets.Select();\r
         }\r
@@ -634,7 +634,6 @@ namespace Handbrake
             treeView_presets.Select();\r
         }\r
 \r
-\r
         private void MnuSetDefaultPreset_Click(object sender, EventArgs e)\r
         {\r
             if (treeView_presets.SelectedNode != null)\r
@@ -648,7 +647,7 @@ namespace Handbrake
         }\r
 \r
         private void MnuImportPreset_Click(object sender, EventArgs e)\r
-        {\r
+        {         \r
             this.ImportPreset();\r
         }\r
 \r
@@ -800,22 +799,43 @@ namespace Handbrake
         /// </summary>\r
         private void ImportPreset()\r
         {\r
+            if (this.selectedTitle == null)\r
+            {\r
+                MessageBox.Show(\r
+                            "Please scan a source before trying to import a preset.",\r
+                            "Error",\r
+                            MessageBoxButtons.OK,\r
+                            MessageBoxIcon.Error);\r
+                return;\r
+            }\r
+\r
             if (openPreset.ShowDialog() == DialogResult.OK)\r
             {\r
                 EncodeTask parsed = PlistPresetHandler.Import(openPreset.FileName);\r
-                if (presetHandler.CheckIfPresetExists(parsed.PresetName + " (Imported)"))\r
+                if (presetHandler.CheckIfPresetExists(parsed.PresetName))\r
                 {\r
+                    if (!presetHandler.CanUpdatePreset(parsed.PresetName))\r
+                    {\r
+                        MessageBox.Show(\r
+                            "You can not import a preset with the same name as a built-in preset.",\r
+                            "Error",\r
+                            MessageBoxButtons.OK,\r
+                            MessageBoxIcon.Error);\r
+                        return;\r
+                    }\r
+\r
                     DialogResult result =\r
                         MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?",\r
                                         "Overwrite preset?",\r
                                         MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
                     if (result == DialogResult.Yes)\r
                     {\r
+\r
                         PresetLoader.LoadPreset(this, parsed, parsed.PresetName);\r
 \r
                         Preset preset = new Preset\r
                             {\r
-                                Name = parsed.PresetName + " (Imported)",\r
+                                Name = parsed.PresetName,\r
                                 Query = QueryGenerator.GenerateFullQuery(this),\r
                                 CropSettings = parsed.UsesPictureSettings\r
                             };\r
@@ -829,16 +849,17 @@ namespace Handbrake
 \r
                     Preset preset = new Preset\r
                     {\r
-                        Name = parsed.PresetName + " (Imported)",\r
+                        Name = parsed.PresetName,\r
                         Query = QueryGenerator.GenerateFullQuery(this),\r
-                        CropSettings = parsed.UsesPictureSettings\r
+                        CropSettings = parsed.UsesPictureSettings,\r
                     };\r
 \r
                     if (presetHandler.Add(preset))\r
                     {\r
-                        TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)")\r
+                        TreeNode preset_treeview = new TreeNode(parsed.PresetName)\r
                                                        {\r
-                                                           ForeColor = Color.Black\r
+                                                           ForeColor = Color.Black,\r
+                                                           Tag = preset,\r
                                                        };\r
                         treeView_presets.Nodes.Add(preset_treeview);\r
                     }\r
@@ -851,6 +872,16 @@ namespace Handbrake
         /// </summary>\r
         private void ExportPreset()\r
         {\r
+            if (this.selectedTitle == null)\r
+            {\r
+                MessageBox.Show(\r
+                            "Please scan a source before trying to export a preset.",\r
+                            "Error",\r
+                            MessageBoxButtons.OK,\r
+                            MessageBoxIcon.Error);\r
+                return;\r
+            }\r
+\r
             SaveFileDialog savefiledialog = new SaveFileDialog { Filter = "plist|*.plist" };\r
 \r
             if (treeView_presets.SelectedNode != null)\r