diff options
author | sr55 <[email protected]> | 2014-03-01 16:44:34 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2014-03-01 16:44:34 +0000 |
commit | 319379665d1c25ae634055076658710a44c6eb9f (patch) | |
tree | 21ee3a63abaccfc5f1a1644a2b8f9fba8c77b712 /win | |
parent | 41ccf17f3ce06e9811e4714d300b9d5f8daab71e (diff) |
WinGui: Add a new command line argument to the HandBrake GUI executable (--reset). This deletes all preset, user preset and settings file which should result in a full reset to defaults.
Also fixed a small bug on the Add to queue button. Don't actually add an item without a destination.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6091 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrakeWPF/App.xaml.cs | 10 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs | 63 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 4 |
4 files changed, 75 insertions, 3 deletions
diff --git a/win/CS/HandBrakeWPF/App.xaml.cs b/win/CS/HandBrakeWPF/App.xaml.cs index 8d76a8dd2..b8ddfaff1 100644 --- a/win/CS/HandBrakeWPF/App.xaml.cs +++ b/win/CS/HandBrakeWPF/App.xaml.cs @@ -18,6 +18,7 @@ namespace HandBrakeWPF using HandBrake.ApplicationServices.Exceptions;
+ using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels;
using HandBrakeWPF.ViewModels.Interfaces;
@@ -45,7 +46,7 @@ namespace HandBrakeWPF protected override void OnStartup(StartupEventArgs e)
{
OperatingSystem OS = Environment.OSVersion;
- if ((OS.Platform == PlatformID.Win32NT) && (OS.Version.Major == 5 && OS.Version.Minor == 1 ))
+ if ((OS.Platform == PlatformID.Win32NT) && (OS.Version.Major == 5 && OS.Version.Minor == 1))
{
MessageBox.Show("Windows XP support is currently broken. It is not known if or when it will be fixed.", "Notice", MessageBoxButton.OK, MessageBoxImage.Warning);
Application.Current.Shutdown();
@@ -58,6 +59,13 @@ namespace HandBrakeWPF MessageBox.Show("Instant HandBrake is just a prototype for toying with ideas. It may or may not work, or even be included in future builds.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
}
+ if (e.Args.Any(f => f.Equals("--reset")))
+ {
+ HandBrakeApp.ResetToDefaults();
+ Application.Current.Shutdown();
+ return;
+ }
+
base.OnStartup(e);
// If we have a file dropped on the icon, try scanning it.
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 8e92b7115..865b75462 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -138,6 +138,7 @@ <Compile Include="Services\Interfaces\IUserSettingService.cs" />
<Compile Include="Services\UserSettingService.cs" />
<Compile Include="Utilities\DelayedActionProcessor.cs" />
+ <Compile Include="Utilities\HandBrakeApp.cs" />
<Compile Include="ViewModels\CountdownAlertViewModel.cs" />
<Compile Include="ViewModels\Interfaces\ICountdownAlertViewModel.cs" />
<Compile Include="Controls\SourceSelection.xaml.cs">
diff --git a/win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs b/win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs new file mode 100644 index 000000000..bcdbfb430 --- /dev/null +++ b/win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs @@ -0,0 +1,63 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="HandBrakeApp.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>
+// <summary>
+// A general Helper class for HandBrake GUI
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Utilities
+{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+
+ /// <summary>
+ /// A general Helper class for HandBrake GUI
+ /// </summary>
+ public class HandBrakeApp
+ {
+ /// <summary>
+ /// The reset to defaults.
+ /// </summary>
+ public static void ResetToDefaults()
+ {
+ DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\presets.xml");
+ DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\user_presets.xml");
+ DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\settings.xml");
+
+ string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");
+ DirectoryInfo info = new DirectoryInfo(tempPath);
+ IEnumerable<FileInfo> logFiles = info.GetFiles("*.xml").Where(f => f.Name.StartsWith("hb_queue_recovery"));
+ foreach (FileInfo file in logFiles)
+ {
+ DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\" + file.Name);
+ }
+ }
+
+ /// <summary>
+ /// The delete file.
+ /// </summary>
+ /// <param name="file">
+ /// The file.
+ /// </param>
+ private static void DeleteFile(string file)
+ {
+ try
+ {
+ Console.WriteLine("Trying to deleting File: {0}", file);
+ if (File.Exists(file))
+ {
+ File.Delete(file);
+ Console.WriteLine("File was deleted successfully");
+ }
+ }
+ catch (Exception exc)
+ {
+ Console.WriteLine("Unable to Delete File: {0} {1} {2}", file, Environment.NewLine, exc);
+ }
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index fb657e686..a2ae6708b 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1140,11 +1140,11 @@ namespace HandBrakeWPF.ViewModels if (string.IsNullOrEmpty(this.CurrentTask.Destination))
{
this.errorService.ShowMessageBox(Resources.Main_SetDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
}
QueueTask task = new QueueTask(new EncodeTask(this.CurrentTask), HBConfigurationFactory.Create());
-
-
+
if (!this.queueProcessor.CheckForDestinationPathDuplicates(task.Task.Destination))
{
this.queueProcessor.Add(task);
|