]> granicus.if.org Git - handbrake/commitdiff
WinGui: Improve Add to queue error Handling. Combine 2 Dialog prompts into one...
authorsr55 <sr55.hb@outlook.com>
Thu, 24 Jan 2019 21:42:14 +0000 (21:42 +0000)
committersr55 <sr55.hb@outlook.com>
Thu, 24 Jan 2019 21:42:34 +0000 (21:42 +0000)
 #1833

win/CS/HandBrakeWPF/HandBrakeWPF.csproj
win/CS/HandBrakeWPF/Model/AddQueueError.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
win/CS/HandBrakeWPF/Properties/Resources.resx
win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs

index de74348b30edb47d3fd2720f2f00bcc54fe1217a..2e4860befff7ba3f1d99c22b4cbbb81455f77cbb 100644 (file)
     <Compile Include="Instance\HandBrakeInstanceManager.cs" />\r
     <Compile Include="Instance\Model\ServerResponse.cs" />\r
     <Compile Include="Instance\RemoteInstance.cs" />\r
+    <Compile Include="Model\AddQueueError.cs" />\r
     <Compile Include="Model\Audio\AudioBehaviourTrack.cs" />\r
     <Compile Include="Model\Audio\AudioTrackDefaultsMode.cs" />\r
     <Compile Include="Model\Audio\AudioBehaviourModes.cs" />\r
diff --git a/win/CS/HandBrakeWPF/Model/AddQueueError.cs b/win/CS/HandBrakeWPF/Model/AddQueueError.cs
new file mode 100644 (file)
index 0000000..f029ce4
--- /dev/null
@@ -0,0 +1,29 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="AutoNameHelper.cs" company="HandBrake Project (http://handbrake.fr)">
+//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Model
+{
+    using System.Windows;
+
+    public class AddQueueError
+    {
+        public string Message { get; }
+
+        public string Header { get; }
+
+        public MessageBoxButton Buttons { get; }
+
+        public MessageBoxImage ErrorType { get; }
+
+        public AddQueueError(string message, string header, MessageBoxButton buttons, MessageBoxImage errorType)
+        {
+            this.Message = message;
+            this.Header = header;
+            this.Buttons = buttons;
+            this.ErrorType = errorType;
+        }
+    }
+}
\ No newline at end of file
index df97f4a66f24d50eaa61ec3c04a9fc07fbb4c9d8..8803d17577f92cb966bd6263d1fbb706d6a28e86 100644 (file)
@@ -1126,7 +1126,7 @@ namespace HandBrakeWPF.Properties {
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Unable to add the last job to the queue. Do you wish to proceed trying to add the rest?.
+        ///   Looks up a localized string similar to Do you wish to proceed trying to add the rest?.
         /// </summary>
         public static string Main_ContinueAddingToQueue {
             get {
index baf8533d928c18fe8c8ffa73cd953cee583296d6..f5e31ea09eb2f74b669f81bcdc6922e7dd2f4406 100644 (file)
@@ -740,7 +740,7 @@ Time Remaining: {5},  Elapsed: {6:d\:hh\:mm\:ss}</value>
     <value>HandBrake requires Windows 7 or later to run. Version 0.9.9 (XP) and 0.10.5 (Vista) was the last version to support these versions.</value>\r
   </data>\r
   <data name="Main_ContinueAddingToQueue" xml:space="preserve">\r
-    <value>Unable to add the last job to the queue. Do you wish to proceed trying to add the rest?</value>\r
+    <value>Do you wish to proceed trying to add the rest?</value>\r
   </data>\r
   <data name="Main_QueueOverwritePrompt" xml:space="preserve">\r
     <value>The file '{0}' already exists!\r
index 3f0c6ae2eea85cd5cd6a84e58e07e0e7ccee83b8..7a6a7b4fadb79bc3af0de4b6d04b8c70c5281730 100644 (file)
@@ -11,6 +11,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces
 {\r
     using System.Windows;\r
 \r
+    using HandBrakeWPF.Model;\r
     using HandBrakeWPF.Services.Queue.Model;\r
 \r
     using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;\r
@@ -49,7 +50,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces
         /// <returns>\r
         /// True if added, false if error\r
         /// </returns>\r
-        bool AddToQueue();\r
+        AddQueueError AddToQueue();\r
         void AddAllToQueue();\r
         void AddSelectionToQueue();\r
 \r
index 857ce9c42910860c9f29cb5f5aa6c6d94a7add92..fbb241ea2d8f87ec126c69fe2125b85ef78ccb14 100644 (file)
@@ -1319,18 +1319,16 @@ namespace HandBrakeWPF.ViewModels
         /// <returns>\r
         /// True if added, false if error.\r
         /// </returns>\r
-        public bool AddToQueue()\r
+        public AddQueueError AddToQueue()\r
         {\r
             if (this.ScannedSource == null || string.IsNullOrEmpty(this.ScannedSource.ScanPath) || this.ScannedSource.Titles.Count == 0)\r
             {\r
-                this.errorService.ShowMessageBox(Resources.Main_ScanSource, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
-                return false;\r
+                return new AddQueueError(Resources.Main_ScanSource, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
             }\r
 \r
             if (string.IsNullOrEmpty(this.CurrentTask.Destination))\r
             {\r
-                this.errorService.ShowMessageBox(Resources.Main_SetDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
-                return false;\r
+                return new AddQueueError(Resources.Main_SetDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
             }\r
 \r
             if (File.Exists(this.CurrentTask.Destination))\r
@@ -1338,44 +1336,38 @@ namespace HandBrakeWPF.ViewModels
                 MessageBoxResult result = this.errorService.ShowMessageBox(string.Format(Resources.Main_QueueOverwritePrompt, Path.GetFileName(this.CurrentTask.Destination)), Resources.Question, MessageBoxButton.YesNo, MessageBoxImage.Question);\r
                 if (result == MessageBoxResult.No)\r
                 {\r
-                    return false;\r
-                }           \r
+                    return null; // Handled by the above action.\r
+                }\r
             }\r
 \r
             if (!DirectoryUtilities.IsWritable(Path.GetDirectoryName(this.CurrentTask.Destination), false, this.errorService))\r
             {\r
-                this.errorService.ShowMessageBox(Resources.Main_NoPermissionsOrMissingDirectory, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
-                return false;\r
+                return new AddQueueError(Resources.Main_NoPermissionsOrMissingDirectory, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
             }\r
 \r
-\r
             if (!DriveUtilities.HasMinimumDiskSpace(\r
                 this.Destination,\r
                 this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseOnLowDiskspaceLevel)))\r
             {\r
-                this.errorService.ShowMessageBox(Resources.Main_LowDiskspace, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
-                return false;\r
+                return new AddQueueError(Resources.Main_LowDiskspace, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
             }\r
 \r
             // Sanity check the filename\r
             if (!string.IsNullOrEmpty(this.Destination) && FileHelper.FilePathHasInvalidChars(this.Destination))\r
             {\r
-                this.errorService.ShowMessageBox(Resources.Main_InvalidDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
                 this.NotifyOfPropertyChange(() => this.Destination);\r
-                return false;\r
+                return new AddQueueError(Resources.Main_InvalidDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
             }\r
 \r
             if (this.Destination == this.ScannedSource.ScanPath)\r
             {\r
-                this.errorService.ShowMessageBox(Resources.Main_SourceDestinationMatchError, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
                 this.Destination = null;\r
-                return false;\r
+                return new AddQueueError(Resources.Main_SourceDestinationMatchError, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
             }\r
 \r
             if (this.scannedSource != null && !string.IsNullOrEmpty(this.scannedSource.ScanPath) && this.Destination.ToLower() == this.scannedSource.ScanPath.ToLower())\r
             {\r
-                this.errorService.ShowMessageBox(Resources.Main_MatchingFileOverwriteWarning, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
-                return false;\r
+                return new AddQueueError(Resources.Main_MatchingFileOverwriteWarning, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
             }\r
 \r
             QueueTask task = new QueueTask(new EncodeTask(this.CurrentTask), HBConfigurationFactory.Create(), this.ScannedSource.ScanPath, this.SelectedPreset);\r
@@ -1386,8 +1378,7 @@ namespace HandBrakeWPF.ViewModels
             }\r
             else\r
             {\r
-                this.errorService.ShowMessageBox(Resources.Main_DuplicateDestinationOnQueue, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Warning);\r
-                return false;\r
+                return new AddQueueError(Resources.Main_DuplicateDestinationOnQueue, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Warning);\r
             }\r
 \r
             if (!this.IsEncoding)\r
@@ -1395,7 +1386,7 @@ namespace HandBrakeWPF.ViewModels
                 this.ProgramStatusLabel = string.Format(Resources.Main_XEncodesPending, this.queueProcessor.Count);\r
             }\r
 \r
-            return true;\r
+            return null;\r
         }\r
 \r
         /// <summary>\r
@@ -1436,9 +1427,10 @@ namespace HandBrakeWPF.ViewModels
             foreach (Title title in this.ScannedSource.Titles)\r
             {\r
                 this.SelectedTitle = title;\r
-                if (!this.AddToQueue())\r
+                var addError = this.AddToQueue();\r
+                if (addError != null)\r
                 {\r
-                   MessageBoxResult result = this.errorService.ShowMessageBox(Resources.Main_ContinueAddingToQueue, Resources.Question, MessageBoxButton.YesNo, MessageBoxImage.Question);\r
+                    MessageBoxResult result = this.errorService.ShowMessageBox(addError.Message + Environment.NewLine + Environment.NewLine + Resources.Main_ContinueAddingToQueue, addError.Header, MessageBoxButton.YesNo, addError.ErrorType);\r
 \r
                     if (result == MessageBoxResult.No)\r
                     {\r
@@ -1473,7 +1465,16 @@ namespace HandBrakeWPF.ViewModels
                 foreach (SelectionTitle title in tasks)\r
                 {\r
                     this.SelectedTitle = title.Title;\r
-                    this.AddToQueue();\r
+                    var addError = this.AddToQueue();\r
+                    if (addError != null)\r
+                    {\r
+                        MessageBoxResult result = this.errorService.ShowMessageBox(addError.Message + Environment.NewLine + Environment.NewLine + Resources.Main_ContinueAddingToQueue, addError.Header, MessageBoxButton.YesNo, addError.ErrorType);\r
+\r
+                        if (result == MessageBoxResult.No)\r
+                        {\r
+                            break;\r
+                        }\r
+                    }\r
                 }\r
             }, this.selectedPreset);\r
 \r
@@ -1564,11 +1565,20 @@ namespace HandBrakeWPF.ViewModels
             }\r
 \r
             // Create the Queue Task and Start Processing\r
-            if (this.AddToQueue())\r
+            var addError = this.AddToQueue();\r
+            if (addError == null)\r
             {\r
                 this.IsEncoding = true;\r
                 this.queueProcessor.Start(this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ClearCompletedFromQueue));               \r
             }\r
+            else\r
+            {\r
+                this.errorService.ShowMessageBox(\r
+                    addError.Message,\r
+                    addError.Header,\r
+                    addError.Buttons,\r
+                    addError.ErrorType);\r
+            }\r
         }\r
 \r
         /// <summary>\r