diff options
author | sr55 <[email protected]> | 2020-07-24 22:02:50 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2020-07-24 22:02:50 +0100 |
commit | 2974cc767def7a4651fcd1b5922730c02af0d1bb (patch) | |
tree | 507248a20c63980c96d6c9e895924617fc769553 /win | |
parent | 88a5af3e108e1839ec86c7a08d77f13a9e45f6ed (diff) |
WinGui: Add back lost functionality on the new queue design. There is now a Stop button that allows for existing jobs to be completed before stopping the queue. When done action will also be honoured. #2974
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.Designer.cs | 11 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.resx | 5 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueService.cs | 12 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Queue/QueueService.cs | 39 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/SystemService.cs | 4 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 6 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 43 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs | 3 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/QueueView.xaml | 24 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/QueueView.xaml.cs | 18 |
10 files changed, 123 insertions, 42 deletions
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 0ac3d8eb3..857526ccd 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -4942,7 +4942,7 @@ namespace HandBrakeWPF.Properties { } /// <summary> - /// Looks up a localized string similar to Pause Queue. + /// Looks up a localized string similar to Pause. /// </summary> public static string QueueView_Pause { get { @@ -5059,6 +5059,15 @@ namespace HandBrakeWPF.Properties { } /// <summary> + /// Looks up a localized string similar to Stop. + /// </summary> + public static string QueueView_Stop { + get { + return ResourceManager.GetString("QueueView_Stop", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Subtitles:. /// </summary> public static string QueueView_Subtitles { diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 40d36fe87..dc34ba9a8 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -1452,7 +1452,7 @@ Would you like to overwrite it?</value> <value>Options</value>
</data>
<data name="QueueView_Pause" xml:space="preserve">
- <value>Pause Queue</value>
+ <value>Pause</value>
</data>
<data name="QueueView_PausedDuration" xml:space="preserve">
<value>Paused Duration:</value>
@@ -2340,4 +2340,7 @@ Please choose a different preset.</value> <data name="OptionsView_NotSupported" xml:space="preserve">
<value>(Not supported on this system)</value>
</data>
+ <data name="QueueView_Stop" xml:space="preserve">
+ <value>Stop</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueService.cs b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueService.cs index 761737434..2cbca0439 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueService.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueService.cs @@ -211,13 +211,19 @@ namespace HandBrakeWPF.Services.Queue.Interfaces /// <summary> /// Stop the current encode and pause the queue. /// </summary> - void Stop(); + /// <param name="stopExistingJobs"> + /// Set to false to allow existing jobs to complete. + /// </param> + void Stop(bool stopExistingJobs); /// <summary> /// Pause the queue but allow the current encode to complete. /// </summary> - void Pause(); - + /// <param name="pauseJobs"> + /// Also pause the active jobs + /// </param> + void Pause(bool pauseJobs); + /// <summary> /// Get the status of all running queue jobs. /// </summary> diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs index c656fb90f..666a3b15e 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/QueueService.cs @@ -233,7 +233,7 @@ namespace HandBrakeWPF.Services.Queue if (result == MessageBoxResult.Yes) { - this.Stop(); + this.Stop(true); foreach (QueueTask task in duplicates) { @@ -455,13 +455,16 @@ namespace HandBrakeWPF.Services.Queue } } - public void Pause() + public void Pause(bool pauseJobs) { - foreach (ActiveJob job in this.activeJobs) + if (pauseJobs) { - if (job.IsEncoding && !job.IsPaused) + foreach (ActiveJob job in this.activeJobs) { - job.Pause(); + if (job.IsEncoding && !job.IsPaused) + { + job.Pause(); + } } } @@ -493,20 +496,27 @@ namespace HandBrakeWPF.Services.Queue this.IsProcessing = true; } - public void Stop() + public void Stop(bool stopExistingJobs) { - foreach (ActiveJob job in this.activeJobs) + if (stopExistingJobs) { - if (job.IsEncoding || job.IsPaused) + foreach (ActiveJob job in this.activeJobs) { - job.Stop(); + if (job.IsEncoding || job.IsPaused) + { + job.Stop(); + } } } this.IsProcessing = false; this.IsPaused = false; - this.InvokeQueueChanged(EventArgs.Empty); - this.InvokeQueueCompleted(new QueueCompletedEventArgs(true)); + + if (stopExistingJobs || this.activeJobs.Count == 0) + { + this.InvokeQueueChanged(EventArgs.Empty); + this.InvokeQueueCompleted(new QueueCompletedEventArgs(true)); + } } public List<QueueProgressStatus> GetQueueProgressStatus() @@ -630,6 +640,11 @@ namespace HandBrakeWPF.Services.Queue { this.ProcessNextJob(); } + else + { + this.InvokeQueueChanged(EventArgs.Empty); + this.InvokeQueueCompleted(new QueueCompletedEventArgs(true)); + } } private void InvokeQueueCompleted(QueueCompletedEventArgs e) @@ -686,7 +701,7 @@ namespace HandBrakeWPF.Services.Queue { this.logService.LogMessage(Resources.PauseOnLowDiskspace); job.Status = QueueItemStatus.Waiting; - this.Pause(); + this.Pause(true); this.BackupQueue(string.Empty); return true; // Don't start the next job. } diff --git a/win/CS/HandBrakeWPF/Services/SystemService.cs b/win/CS/HandBrakeWPF/Services/SystemService.cs index dafd605b3..14c434775 100644 --- a/win/CS/HandBrakeWPF/Services/SystemService.cs +++ b/win/CS/HandBrakeWPF/Services/SystemService.cs @@ -77,7 +77,7 @@ namespace HandBrakeWPF.Services string.Format( Resources.SystemService_LowDiskSpaceLog, lowLevel / 1000 / 1000 / 1000)); - this.queueService.Pause(); + this.queueService.Pause(true); this.storageLowPause = true; } } @@ -104,7 +104,7 @@ namespace HandBrakeWPF.Services if (this.queueService.IsEncoding && !this.queueService.IsPaused) { this.lowPowerPause = true; - this.queueService.Pause(); + this.queueService.Pause(true); } Win32.AllowSleep(); diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 1d013bd26..c93f0005e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -978,7 +978,7 @@ namespace HandBrakeWPF.ViewModels public void Shutdown()
{
// Shutdown Service
- this.queueProcessor.Stop();
+ this.queueProcessor.Stop(true);
this.presetService.SaveCategoryStates();
// Unsubscribe from Events.
@@ -1388,7 +1388,7 @@ namespace HandBrakeWPF.ViewModels public void PauseEncode()
{
- this.queueProcessor.Pause();
+ this.queueProcessor.Pause(true);
this.NotifyOfPropertyChange(() => this.IsEncoding);
}
@@ -1402,7 +1402,7 @@ namespace HandBrakeWPF.ViewModels if (result == MessageBoxResult.Yes)
{
- this.queueProcessor.Stop();
+ this.queueProcessor.Stop(true);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index 67e0c3804..ccb79faad 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -227,17 +227,57 @@ namespace HandBrakeWPF.ViewModels public void PauseQueue()
{
- this.queueProcessor.Pause();
+ this.queueProcessor.Pause(true);
this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
this.IsQueueRunning = false;
}
+ public void PauseJob(QueueTask task)
+ {
+ if (task != null)
+ {
+ this.queueProcessor.Pause(task);
+ }
+ }
+
public void PauseQueueToolbar()
{
this.PauseQueue();
}
+ public void StopQueue()
+ {
+ if (this.queueProcessor.IsEncoding)
+ {
+ MessageBoxResult result = this.errorService.ShowMessageBox(
+ "There are currently jobs running. Would you like to complete the current jobs before stopping the queue?",
+ "Confirm",
+ MessageBoxButton.YesNoCancel,
+ MessageBoxImage.Question);
+
+ if (result == MessageBoxResult.Yes)
+ {
+ this.queueProcessor.Stop(false);
+ }
+ else if (result == MessageBoxResult.Cancel)
+ {
+ return;
+ }
+ else
+ {
+ this.queueProcessor.Stop(true);
+ }
+ }
+ else
+ {
+ this.queueProcessor.Stop(true);
+ }
+
+ this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
+ this.IsQueueRunning = false;
+ }
+
public void RemoveSelectedJobs()
{
if (this.SelectedItems.Count == 0)
@@ -286,7 +326,6 @@ namespace HandBrakeWPF.ViewModels if (result == MessageBoxResult.Yes)
{
- this.queueProcessor.Stop();
this.queueProcessor.Remove(task);
removed = true;
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs index 56d8f719f..3e38a35eb 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs @@ -201,11 +201,12 @@ namespace HandBrakeWPF.ViewModels if (result == MessageBoxResult.Yes)
{
- processor.Stop();
+ processor.Stop(true);
this.MainViewModel?.Shutdown();
return true;
}
+
return false;
}
diff --git a/win/CS/HandBrakeWPF/Views/QueueView.xaml b/win/CS/HandBrakeWPF/Views/QueueView.xaml index cb30f44d6..f2830a710 100644 --- a/win/CS/HandBrakeWPF/Views/QueueView.xaml +++ b/win/CS/HandBrakeWPF/Views/QueueView.xaml @@ -100,13 +100,24 @@ </StackPanel>
</Button>
- <Button Name="Pause" AutomationProperties.Name="Pause Queue" cal:Message.Attach="[Event Click] = [Action PauseQueueToolbar]" Grid.Column="1"
+ <StackPanel Grid.Column="1" Orientation="Horizontal">
+ <Button Name="Pause" AutomationProperties.Name="{x:Static Properties:Resources.QueueView_Pause}" cal:Message.Attach="[Event Click] = [Action PauseQueueToolbar]"
Visibility="{Binding IsQueueRunning, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}">
- <StackPanel Orientation="Horizontal">
- <Image Width="16" Height="16" Margin="2,0,0,0" Source="Images/Pause.png" />
- <Label Margin="5,0,0,0" VerticalAlignment="Center" Content="{x:Static Properties:Resources.QueueView_Pause}" />
- </StackPanel>
- </Button>
+ <StackPanel Orientation="Horizontal">
+ <Image Width="16" Height="16" Margin="2,0,0,0" Source="Images/Pause.png" />
+ <Label Margin="5,0,0,0" VerticalAlignment="Center" Content="{x:Static Properties:Resources.QueueView_Pause}" />
+ </StackPanel>
+ </Button>
+
+ <Button Name="Stop" AutomationProperties.Name="{x:Static Properties:Resources.QueueView_Stop}" cal:Message.Attach="[Event Click] = [Action StopQueue]"
+ Visibility="{Binding IsQueueRunning, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}"
+ Margin="5,0,0,0">
+ <StackPanel Orientation="Horizontal">
+ <Image Width="16" Height="16" Margin="2,0,0,0" Source="Images/stop.png" />
+ <Label Margin="5,0,0,0" VerticalAlignment="Center" Content="{x:Static Properties:Resources.QueueView_Stop}" />
+ </StackPanel>
+ </Button>
+ </StackPanel>
<Menu HorizontalAlignment="Right" Background="Transparent" VerticalAlignment="Bottom" Grid.Column="3" Margin="0,0,0,0" >
<MenuItem>
@@ -161,6 +172,7 @@ <ContextMenu cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}" Opened="ContextMenu_OnOpened">
<MenuItem Header="{x:Static Properties:Resources.QueueView_PlayMediaFile}" cal:Message.Attach="[Event Click] = [Action PlayFile]" />
<Separator />
+ <!--<MenuItem x:Name="PauseJobMenuItem" Header="{x:Static Properties:Resources.QueueView_Pause}" Click="QueueItem_PauseJobs" />-->
<MenuItem x:Name="ResetMenuItem" Header="{x:Static Properties:Resources.QueueView_Reset}" Click="QueueItem_Retry" />
<MenuItem x:Name="DeleteMenuItem" Header="{x:Static Properties:Resources.QueueView_Delete}" Click="QueueItem_Delete" />
<Separator />
diff --git a/win/CS/HandBrakeWPF/Views/QueueView.xaml.cs b/win/CS/HandBrakeWPF/Views/QueueView.xaml.cs index 9ffdad8eb..1c6674dd5 100644 --- a/win/CS/HandBrakeWPF/Views/QueueView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/QueueView.xaml.cs @@ -1,33 +1,24 @@ // --------------------------------------------------------------------------------------------------------------------
-// <copyright file="QueueTwoView.xaml.cs" company="HandBrake Project (http://handbrake.fr)">
+// <copyright file="QueueView.xaml.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>
-// Interaction logic for QueueTwoView.xaml
-// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Views
{
- using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
+ using System.Windows.Media.Animation;
using HandBrakeWPF.Services.Queue.Model;
using HandBrakeWPF.ViewModels;
- /// <summary>
- /// Interaction logic for VideoView
- /// </summary>
public partial class QueueView : Window
{
private QueueTask mouseActiveQueueTask;
- /// <summary>
- /// Initializes a new instance of the <see cref="QueueView"/> class.
- /// </summary>
public QueueView()
{
this.InitializeComponent();
@@ -165,6 +156,11 @@ namespace HandBrakeWPF.Views }
}
+ private void QueueItem_PauseJobs(object sender, RoutedEventArgs e)
+ {
+ ((QueueViewModel)this.DataContext).PauseJob(this.mouseActiveQueueTask);
+ }
+
private void QueueItem_Edit(object sender, RoutedEventArgs e)
{
((QueueViewModel)this.DataContext).EditJob(this.mouseActiveQueueTask);
|