diff options
author | sr55 <[email protected]> | 2020-02-23 13:59:30 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2020-02-23 13:59:30 +0000 |
commit | d051fe3375ef5cd60f808604a4d9c49c5722808f (patch) | |
tree | 29f8b588b52f225672255457ca7afd5c91e8923c | |
parent | b203d0dee2677ee9e1a5f8ba5308d5c9543e2c35 (diff) |
WinGui: Improve Handling of Low Disk Space Alerts
- Preferences UI updated to make it clearer difference between Alert Level and Pause When Low options.
- Main Window UI around adding to Queue will now prompt and allow to Confirm / Deny adding to queue when disk space is low.
- Alerts are less agressive when bulk adding to the queue.
Fixes #2648
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.Designer.cs | 8 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.resx | 8 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/SystemService.cs | 4 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/UserSettingService.cs | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/UserSettingConstants.cs | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 44 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 7 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/OptionsView.xaml | 6 |
9 files changed, 56 insertions, 25 deletions
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index cb317cf64..3fd1b31ea 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -1333,7 +1333,11 @@ namespace HandBrakeWPF.Properties { } /// <summary> - /// Looks up a localized string similar to Your destination directory is low on diskspace. Please free up some disk space on your destination drive. Alternatively you can change the level at which this alert triggers in Options. . + /// Looks up a localized string similar to Your destination directory is low on diskspace. + /// + ///You can configure the level at which this alert appears in preferences. + /// + ///Do you wish to continue? . /// </summary> public static string Main_LowDiskspace { get { @@ -2984,7 +2988,7 @@ namespace HandBrakeWPF.Properties { } /// <summary> - /// Looks up a localized string similar to Pause queue if disk space is lower than:. + /// Looks up a localized string similar to Pause queue if disk space is low. /// </summary> public static string Options_LowDiskspaceSize { get { diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index e2638cae8..c8f75faca 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -697,7 +697,11 @@ Remaining Time: {4}</value> <value>Queue Paused</value>
</data>
<data name="Main_LowDiskspace" xml:space="preserve">
- <value>Your destination directory is low on diskspace. Please free up some disk space on your destination drive. Alternatively you can change the level at which this alert triggers in Options. </value>
+ <value>Your destination directory is low on diskspace.
+
+You can configure the level at which this alert appears in preferences.
+
+Do you wish to continue? </value>
</data>
<data name="Queue_UnableToResetJob" xml:space="preserve">
<value>Unable to reset job status as it is not in an Error or Completed state</value>
@@ -1237,7 +1241,7 @@ Would you like to overwrite it?</value> <value>Log Path:</value>
</data>
<data name="Options_LowDiskspaceSize" xml:space="preserve">
- <value>Pause queue if disk space is lower than:</value>
+ <value>Pause queue if disk space is low</value>
</data>
<data name="Options_MinimiseTray" xml:space="preserve">
<value>Minimize to system tray (Requires Restart)</value>
diff --git a/win/CS/HandBrakeWPF/Services/SystemService.cs b/win/CS/HandBrakeWPF/Services/SystemService.cs index a2073cc98..d9fa46716 100644 --- a/win/CS/HandBrakeWPF/Services/SystemService.cs +++ b/win/CS/HandBrakeWPF/Services/SystemService.cs @@ -65,9 +65,9 @@ namespace HandBrakeWPF.Services private void StorageCheck() { string directory = this.encodeService.GetActiveJob()?.Destination; - if (!string.IsNullOrEmpty(directory) && this.encodeService.IsEncoding) + if (!string.IsNullOrEmpty(directory) && this.encodeService.IsEncoding) { - long lowLevel = this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseEncodeOnLowDiskspaceLevel); + long lowLevel = this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseQueueOnLowDiskspaceLevel); if (!this.storageLowPause && this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PauseOnLowDiskspace) && !DriveUtilities.HasMinimumDiskSpace(directory, lowLevel)) { this.log.LogMessage( diff --git a/win/CS/HandBrakeWPF/Services/UserSettingService.cs b/win/CS/HandBrakeWPF/Services/UserSettingService.cs index 4e8a6267f..fb7c6185c 100644 --- a/win/CS/HandBrakeWPF/Services/UserSettingService.cs +++ b/win/CS/HandBrakeWPF/Services/UserSettingService.cs @@ -289,7 +289,6 @@ namespace HandBrakeWPF.Services defaults.Add(UserSettingConstants.DisableLibDvdNav, false);
defaults.Add(UserSettingConstants.PauseOnLowDiskspace, true);
defaults.Add(UserSettingConstants.PauseQueueOnLowDiskspaceLevel, 2000000000L);
- defaults.Add(UserSettingConstants.PauseEncodeOnLowDiskspaceLevel, 2000000000L);
defaults.Add(UserSettingConstants.PreviewScanCount, 10);
defaults.Add(UserSettingConstants.MinScanDuration, 10);
defaults.Add(UserSettingConstants.ProcessPriorityInt, 3);
diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index e5e7dfdce..e0133c457 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -37,7 +37,6 @@ namespace HandBrakeWPF public const string PreventSleep = "PreventSleep";
public const string PauseOnLowDiskspace = "PauseOnLowDiskspace";
public const string PauseQueueOnLowDiskspaceLevel = "LowDiskSpaceWarningLevelInBytes";
- public const string PauseEncodeOnLowDiskspaceLevel = "LowDiskSpaceEncodePauseLevelInBytes";
public const string RemovePunctuation = "RemovePunctuation";
public const string ShowPresetPanel = "ShowPresetPanelOption";
public const string ResetWhenDoneAction = "ResetWhenDoneAction";
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs index 398d3b154..e2e4fd1aa 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IMainViewModel.cs @@ -50,7 +50,7 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// <returns>
/// True if added, false if error
/// </returns>
- AddQueueError AddToQueue();
+ AddQueueError AddToQueue(bool batch = false);
void AddToQueueWithErrorHandling();
void AddAllToQueue();
void AddSelectionToQueue();
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index f4d8cdcf0..989ddd7b6 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1341,13 +1341,7 @@ namespace HandBrakeWPF.ViewModels command.Execute(OptionsTab.Updates);
}
- /// <summary>
- /// Add the current task to the queue.
- /// </summary>
- /// <returns>
- /// True if added, false if error.
- /// </returns>
- public AddQueueError AddToQueue()
+ public AddQueueError AddToQueue(bool batch)
{
if (this.ScannedSource == null || string.IsNullOrEmpty(this.ScannedSource.ScanPath) || this.ScannedSource.Titles.Count == 0)
{
@@ -1369,7 +1363,7 @@ namespace HandBrakeWPF.ViewModels FileOverwriteBehaviour behaviour = (FileOverwriteBehaviour)this.userSettingService.GetUserSetting<int>(UserSettingConstants.FileOverwriteBehaviour);
if (behaviour == FileOverwriteBehaviour.Ask)
{
- MessageBoxResult result = this.errorService.ShowMessageBox(string.Format(Resources.Main_QueueOverwritePrompt, Path.GetFileName(this.CurrentTask.Destination)), Resources.Question, MessageBoxButton.YesNo, MessageBoxImage.Question);
+ MessageBoxResult result = this.errorService.ShowMessageBox(string.Format(Resources.Main_QueueOverwritePrompt, Path.GetFileName(this.CurrentTask.Destination)), Resources.Question, MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.No)
{
return null; // Handled by the above action.
@@ -1382,11 +1376,15 @@ namespace HandBrakeWPF.ViewModels return new AddQueueError(Resources.Main_NoPermissionsOrMissingDirectory, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
}
- if (!DriveUtilities.HasMinimumDiskSpace(
+ if (!batch && !DriveUtilities.HasMinimumDiskSpace(
this.Destination,
this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseQueueOnLowDiskspaceLevel)))
{
- return new AddQueueError(Resources.Main_LowDiskspace, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
+ MessageBoxResult result = this.errorService.ShowMessageBox(Resources.Main_LowDiskspace, Resources.Warning, MessageBoxButton.YesNo, MessageBoxImage.Question);
+ if (result == MessageBoxResult.No)
+ {
+ return null; // Handled by the above action.
+ }
}
// Sanity check the filename
@@ -1423,7 +1421,7 @@ namespace HandBrakeWPF.ViewModels public void AddToQueueWithErrorHandling()
{
- var addError = this.AddToQueue();
+ var addError = this.AddToQueue(false);
if (addError != null)
{
this.errorService.ShowMessageBox(addError.Message, addError.Header, addError.Buttons, addError.ErrorType);
@@ -1447,6 +1445,15 @@ namespace HandBrakeWPF.ViewModels return;
}
+ if (!DriveUtilities.HasMinimumDiskSpace(this.Destination, this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseQueueOnLowDiskspaceLevel)))
+ {
+ MessageBoxResult result = this.errorService.ShowMessageBox(Resources.Main_LowDiskspace, Resources.Warning, MessageBoxButton.YesNo, MessageBoxImage.Question);
+ if (result == MessageBoxResult.No)
+ {
+ return; // Handled by the above action.
+ }
+ }
+
if (this.CurrentTask != null && this.CurrentTask.SubtitleTracks != null && this.CurrentTask.SubtitleTracks.Count > 0)
{
if ((this.SubtitleViewModel.SubtitleBehaviours == null || this.SubtitleViewModel.SubtitleBehaviours.SelectedBehaviour == SubtitleBehaviourModes.None)
@@ -1468,7 +1475,7 @@ namespace HandBrakeWPF.ViewModels foreach (Title title in this.ScannedSource.Titles)
{
this.SelectedTitle = title;
- var addError = this.AddToQueue();
+ var addError = this.AddToQueue(true);
if (addError != null)
{
MessageBoxResult result = this.errorService.ShowMessageBox(addError.Message + Environment.NewLine + Environment.NewLine + Resources.Main_ContinueAddingToQueue, addError.Header, MessageBoxButton.YesNo, addError.ErrorType);
@@ -1498,6 +1505,15 @@ namespace HandBrakeWPF.ViewModels return;
}
+ if (!DriveUtilities.HasMinimumDiskSpace(this.Destination, this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseQueueOnLowDiskspaceLevel)))
+ {
+ MessageBoxResult result = this.errorService.ShowMessageBox(Resources.Main_LowDiskspace, Resources.Warning, MessageBoxButton.YesNo, MessageBoxImage.Question);
+ if (result == MessageBoxResult.No)
+ {
+ return; // Handled by the above action.
+ }
+ }
+
Window window = Application.Current.Windows.Cast<Window>().FirstOrDefault(x => x.GetType() == typeof(QueueSelectionViewModel));
IQueueSelectionViewModel viewModel = IoC.Get<IQueueSelectionViewModel>();
@@ -1506,7 +1522,7 @@ namespace HandBrakeWPF.ViewModels foreach (SelectionTitle title in tasks)
{
this.SelectedTitle = title.Title;
- var addError = this.AddToQueue();
+ var addError = this.AddToQueue(true);
if (addError != null)
{
MessageBoxResult result = this.errorService.ShowMessageBox(addError.Message + Environment.NewLine + Environment.NewLine + Resources.Main_ContinueAddingToQueue, addError.Header, MessageBoxButton.YesNo, addError.ErrorType);
@@ -1606,7 +1622,7 @@ namespace HandBrakeWPF.ViewModels }
// Create the Queue Task and Start Processing
- var addError = this.AddToQueue();
+ var addError = this.AddToQueue(false);
if (addError == null)
{
this.IsEncoding = true;
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index 6db94474b..342a17ca4 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -480,8 +480,11 @@ namespace HandBrakeWPF.ViewModels if (firstOrDefault != null && !DriveUtilities.HasMinimumDiskSpace(firstOrDefault.Task.Destination,
this.userSettingService.GetUserSetting<long>(UserSettingConstants.PauseQueueOnLowDiskspaceLevel)))
{
- this.errorService.ShowMessageBox(Resources.Main_LowDiskspace, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
- return;
+ MessageBoxResult result = this.errorService.ShowMessageBox(Resources.Main_LowDiskspace, Resources.Warning, MessageBoxButton.YesNo, MessageBoxImage.Warning);
+ if (result == MessageBoxResult.No)
+ {
+ return;
+ }
}
this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml index 249fb1f7c..9dc45ff90 100644 --- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml +++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml @@ -365,9 +365,15 @@ <CheckBox Content="{x:Static Properties:Resources.Options_DvdRead}" IsChecked="{Binding DisableLibdvdNav}" Margin="0,8,0,0" />
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<CheckBox Content="{x:Static Properties:Resources.Options_LowDiskspaceSize}" IsChecked="{Binding PauseOnLowDiskspace}" Width="255" />
+ </StackPanel>
+
+ <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
+ <TextBlock Text="Level at which low disk space alerts show: " Width="250" />
+
<TextBox x:Name="PauseOnLowDiskspaceLevel" Text="{Binding PauseOnLowDiskspaceLevel, Converter={StaticResource fileSizeConverter}, UpdateSourceTrigger=PropertyChanged}" Width="120"/>
<TextBlock Text="{x:Static Properties:Resources.Options_LowDiskspaceSizeGB}" VerticalAlignment="Center" Margin="5,0,0,0" />
</StackPanel>
+
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock Text="{x:Static Properties:Resources.Options_PreviewScanCount}" VerticalAlignment="Center" Width="250" />
<ComboBox Name="numberOfPreviews" ItemsSource="{Binding PreviewPicturesToScan}" SelectedItem="{Binding SelectedPreviewCount}" Width="120" />
|