diff options
author | sr55 <[email protected]> | 2019-03-03 17:54:41 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2019-03-03 17:54:41 +0000 |
commit | 536b4f8aeb8cc399dbd01601bdca4add87b0e45a (patch) | |
tree | 94df68f4b824c0273f274081008f96f6328be61d /win/CS | |
parent | 3f00ad4e38deca496922f836d31c44f8b630fbf4 (diff) |
WinGui: Queue -> Overhaul the context menu on the queue to offer context aware tasks for the selected tasks.
Diffstat (limited to 'win/CS')
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.Designer.cs | 19 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.resx | 7 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 4 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/QueueView.xaml | 30 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/QueueView.xaml.cs | 69 |
5 files changed, 105 insertions, 24 deletions
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index ead05b8b7..afb24dd5f 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -3802,6 +3802,15 @@ namespace HandBrakeWPF.Properties { } /// <summary> + /// Looks up a localized string similar to Delete Selected. + /// </summary> + public static string QueueView_DeleteSelected { + get { + return ResourceManager.GetString("QueueView_DeleteSelected", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Destination: . /// </summary> public static string QueueView_Destination { @@ -4144,6 +4153,16 @@ namespace HandBrakeWPF.Properties { } /// <summary> + /// Looks up a localized string similar to Encoding: Pass {0} of {1}, {2:00.00}%, FPS: {3:000.0}, Avg FPS: {4:000.0} + ///Time Remaining: {5}, Elapsed: {6:d\:hh\:mm\:ss} {7}. + /// </summary> + public static string QueueViewModel_EncodeStatusChanged_StatusLabel { + get { + return ResourceManager.GetString("QueueViewModel_EncodeStatusChanged_StatusLabel", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to This encode is currently in progress. If you delete it, the encode will be stopped. Are you sure you wish to proceed?. /// </summary> public static string QueueViewModel_JobCurrentlyRunningWarning { diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 7cc191852..21de9c96c 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -1918,4 +1918,11 @@ This will not impact any of the software encoders.</value> <data name="QueueView_Import" xml:space="preserve">
<value>Import</value>
</data>
+ <data name="QueueViewModel_EncodeStatusChanged_StatusLabel" xml:space="preserve">
+ <value>Encoding: Pass {0} of {1}, {2:00.00}%, FPS: {3:000.0}, Avg FPS: {4:000.0}
+Time Remaining: {5}, Elapsed: {6:d\:hh\:mm\:ss} {7}</value>
+ </data>
+ <data name="QueueView_DeleteSelected" xml:space="preserve">
+ <value>Delete Selected</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index 20cc0bbbe..b250c1456 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -125,7 +125,7 @@ namespace HandBrakeWPF.ViewModels }
}
- public bool IsJobStatusVisible => !string.IsNullOrEmpty(this.JobStatus);
+ public bool IsJobStatusVisible => !string.IsNullOrEmpty(this.JobStatus) && this.SelectedTask?.Status == QueueItemStatus.InProgress;
/// <summary>
/// Gets or sets JobsPending.
@@ -819,7 +819,7 @@ namespace HandBrakeWPF.ViewModels else
{
this.JobStatus =
- string.Format(Resources.MainViewModel_EncodeStatusChanged_StatusLabel,
+ string.Format(Resources.QueueViewModel_EncodeStatusChanged_StatusLabel,
e.Task,
e.TaskCount,
e.PercentComplete,
diff --git a/win/CS/HandBrakeWPF/Views/QueueView.xaml b/win/CS/HandBrakeWPF/Views/QueueView.xaml index 75c324536..b44312832 100644 --- a/win/CS/HandBrakeWPF/Views/QueueView.xaml +++ b/win/CS/HandBrakeWPF/Views/QueueView.xaml @@ -160,21 +160,16 @@ <ListBox.ContextMenu>
<ContextMenu cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}" Opened="ContextMenu_OnOpened">
- <MenuItem cal:Message.Attach="[Event Click] = [Action StartQueue]" Header="{x:Static Properties:Resources.QueueView_Start}" />
- <MenuItem cal:Message.Attach="[Event Click] = [Action PauseQueue]" Header="{x:Static Properties:Resources.QueueView_Pause}" />
+ <MenuItem Header="{x:Static Properties:Resources.QueueView_PlayMediaFile}" cal:Message.Attach="[Event Click] = [Action PlayFile]" />
<Separator />
- <MenuItem cal:Message.Attach="[Event Click] = [Action ResetFailed]" Header="{x:Static Properties:Resources.QueueView_ResetFailed}" />
- <MenuItem cal:Message.Attach="[Event Click] = [Action ResetSelectedJobs]" Header="{x:Static Properties:Resources.QueueView_ResetSelectedJobs}" />
- <MenuItem cal:Message.Attach="[Event Click] = [Action ResetAllJobs]" Header="{x:Static Properties:Resources.QueueView_ResetAllJobs}" />
+ <MenuItem x:Name="RetryMenuItem" Header="{x:Static Properties:Resources.QueueView_Retry}" Click="QueueItem_Retry" />
+ <MenuItem x:Name="DeleteMenuItem" Header="{x:Static Properties:Resources.QueueView_Delete}" Click="QueueItem_Delete" />
<Separator />
- <MenuItem cal:Message.Attach="[Event Click] = [Action ClearCompleted]" Header="{x:Static Properties:Resources.QueueView_ClearCompleted}" />
- <MenuItem cal:Message.Attach="[Event Click] = [Action Clear]" Header="{x:Static Properties:Resources.QueueView_ClearAll}" />
- <MenuItem cal:Message.Attach="[Event Click] = [Action RemoveSelectedJobs]" Header="{x:Static Properties:Resources.QueueView_ClearSelected}" />
+ <MenuItem x:Name="EditMenuItem" Header="{x:Static Properties:Resources.QueueView_Edit}" Click="QueueItem_Edit" />
<Separator />
<MenuItem Header="{x:Static Properties:Resources.QueueView_OpenSourceDir}" x:Name="openSourceDir" Click="OpenSourceDir_OnClick" />
<MenuItem Header="{x:Static Properties:Resources.QueueView_OpenDestDir}" x:Name="openDestDir" Click="OpenDestDir_OnClick" />
- <Separator />
- <MenuItem cal:Message.Attach="[Event Click] = [Action Export]" Header="{x:Static Properties:Resources.QueueView_Export}" />
+
</ContextMenu>
</ListBox.ContextMenu>
@@ -390,7 +385,6 @@ </i:Interaction.Triggers>
</Button>
-
<Button x:Name="queueOptionsDropButton" Margin="10,0,0,0" Click="QueueOptionsDropButton_OnClick"
AutomationProperties.Name="{x:Static Properties:Resources.QueueView_Actions}" IsEnabled="{Binding CanPerformActionOnSource}">
<Button.Content>
@@ -420,8 +414,10 @@ </Button>
</StackPanel>
+
+ <TextBlock FontWeight="Bold" Text="Status:" VerticalAlignment="Top" Grid.Row="0" Grid.Column="0" Margin="0,15,10,5" Visibility="{Binding IsJobStatusVisible, Converter={StaticResource boolToVisConverter}}" />
<TextBlock Text="{Binding JobStatus}" Visibility="{Binding IsJobStatusVisible, Converter={StaticResource boolToVisConverter}}"
- Margin="0,15,10,5" TextWrapping="WrapWithOverflow" TextTrimming="CharacterEllipsis" />
+ TextWrapping="WrapWithOverflow" TextTrimming="CharacterEllipsis" Margin="0,0,0,5" />
<Grid Style="{StaticResource LongToolTipHolder}" Margin="0,10,0,0" >
<Grid.Resources>
@@ -457,11 +453,11 @@ <TextBlock FontWeight="Bold" Text="{x:Static Properties:Resources.QueueView_Video}" Grid.Row="3" Grid.Column="0" />
<TextBlock Text="{Binding SelectedTask.Task, Converter={StaticResource videoOptionsTooltipConverter}}" Grid.Row="3" Grid.Column="1" TextWrapping="Wrap" />
- <TextBlock FontWeight="Bold" Text="{x:Static Properties:Resources.QueueView_Audio}" Grid.Row="4" Grid.Column="0"/>
+ <TextBlock FontWeight="Bold" Text="{x:Static Properties:Resources.QueueView_Audio}" Grid.Row="4" Grid.Column="0" VerticalAlignment="Top"/>
<TextBlock Text="{Binding SelectedTask.Task.AudioTracks, Converter={StaticResource audioTrackDisplayConverter}}"
- Grid.Row="4" Grid.Column="1"/>
+ Grid.Row="4" Grid.Column="1" />
- <TextBlock FontWeight="Bold" VerticalAlignment="Top" Text="{x:Static Properties:Resources.QueueView_Subtitles}" Grid.Row="5" Grid.Column="0" />
+ <TextBlock FontWeight="Bold" VerticalAlignment="Top" Text="{x:Static Properties:Resources.QueueView_Subtitles}" Grid.Row="5" Grid.Column="0" />
<TextBlock Text="{Binding SelectedTask.Task.SubtitleTracks, Converter={StaticResource subtitleTrackDisplayConverter}}"
Grid.Row="5" Grid.Column="1" />
@@ -530,12 +526,12 @@ <ContextMenu>
<MenuItem Header="{x:Static Properties:Resources.LogView_CopyClipboard}" cal:Message.Attach="[Event Click] = [Action CopyLog]" >
<MenuItem.Icon>
- <Image Width="16" Source="../Images/copy.png" />
+ <Image Width="16" Source="Images/copy.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{x:Static Properties:Resources.LogView_OpenLogDir}" cal:Message.Attach="[Event Click] = [Action OpenLogDirectory]">
<MenuItem.Icon>
- <Image Width="16" Source="../Images/folder.png" />
+ <Image Width="16" Source="Images/folder.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
diff --git a/win/CS/HandBrakeWPF/Views/QueueView.xaml.cs b/win/CS/HandBrakeWPF/Views/QueueView.xaml.cs index 53b4256aa..95915e828 100644 --- a/win/CS/HandBrakeWPF/Views/QueueView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/QueueView.xaml.cs @@ -9,6 +9,7 @@ namespace HandBrakeWPF.Views
{
+ using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -25,15 +26,15 @@ namespace HandBrakeWPF.Views private QueueTask mouseActiveQueueTask;
/// <summary>
- /// Initializes a new instance of the <see cref="QueueTwoContent"/> class.
+ /// Initializes a new instance of the <see cref="QueueView"/> class.
/// </summary>
public QueueView()
{
this.InitializeComponent();
- this.SizeChanged += this.Queue2View_SizeChanged;
+ this.SizeChanged += this.QueueView_SizeChanged;
}
- private void Queue2View_SizeChanged(object sender, SizeChangedEventArgs e)
+ private void QueueView_SizeChanged(object sender, SizeChangedEventArgs e)
{
// Make the view adaptive.
if (e.WidthChanged)
@@ -63,8 +64,36 @@ namespace HandBrakeWPF.Views }
}
- this.openSourceDir.IsEnabled = this.mouseActiveQueueTask != null;
- this.openDestDir.IsEnabled = this.mouseActiveQueueTask != null;
+ // Handle menu state
+ this.RetryMenuItem.Header = this.queueJobs.SelectedItems.Count > 1 ? Properties.Resources.QueueView_ResetSelectedJobs : Properties.Resources.QueueView_Retry;
+ if (this.queueJobs.SelectedItems.Count > 1)
+ {
+ this.RetryMenuItem.IsEnabled = false;
+
+ foreach (QueueTask task in this.queueJobs.SelectedItems)
+ {
+ if (task.Status == QueueItemStatus.Error || task.Status == QueueItemStatus.Completed)
+ {
+ this.RetryMenuItem.IsEnabled = true;
+ break;
+ }
+ }
+ }
+ else
+ {
+ var activeQueueTask = this.mouseActiveQueueTask;
+ if (activeQueueTask != null && (activeQueueTask.Status == QueueItemStatus.Error || activeQueueTask.Status == QueueItemStatus.Completed))
+ {
+ this.RetryMenuItem.IsEnabled = true;
+ }
+ }
+
+ this.DeleteMenuItem.Header = this.queueJobs.SelectedItems.Count > 1 ? Properties.Resources.QueueView_DeleteSelected : Properties.Resources.QueueView_Delete;
+ this.DeleteMenuItem.IsEnabled = this.mouseActiveQueueTask != null || this.queueJobs.SelectedItems.Count >= 1;
+
+ this.EditMenuItem.IsEnabled = this.mouseActiveQueueTask != null && this.queueJobs.SelectedItems.Count == 1;
+ this.openSourceDir.IsEnabled = this.mouseActiveQueueTask != null && this.queueJobs.SelectedItems.Count == 1;
+ this.openDestDir.IsEnabled = this.mouseActiveQueueTask != null && this.queueJobs.SelectedItems.Count == 1;
}
private static T FindParent<T>(DependencyObject from) where T : class
@@ -104,5 +133,35 @@ namespace HandBrakeWPF.Views button.ContextMenu.IsOpen = true;
}
}
+
+ private void QueueItem_Delete(object sender, RoutedEventArgs e)
+ {
+ if (this.queueJobs.SelectedItems.Count > 1)
+ {
+ ((QueueViewModel)this.DataContext).RemoveSelectedJobs();
+ }
+ else
+ {
+ ((QueueViewModel)this.DataContext).RemoveJob(this.mouseActiveQueueTask);
+ }
+ }
+
+ private void QueueItem_Retry(object sender, RoutedEventArgs e)
+ {
+ if (this.queueJobs.SelectedItems.Count > 1)
+ {
+ ((QueueViewModel)this.DataContext).ResetSelectedJobs();
+ }
+ else
+ {
+ ((QueueViewModel)this.DataContext).RetryJob(this.mouseActiveQueueTask);
+ }
+ }
+
+ private void QueueItem_Edit(object sender, RoutedEventArgs e)
+ {
+ ((QueueViewModel)this.DataContext).EditJob(this.mouseActiveQueueTask);
+ }
+
}
}
|