]> granicus.if.org Git - handbrake/commitdiff
WinGui: Adding Stats and Log Tabs to the new experimental queue view. #1087
authorsr55 <sr55.hb@outlook.com>
Sat, 22 Sep 2018 20:36:22 +0000 (21:36 +0100)
committersr55 <sr55.hb@outlook.com>
Sat, 22 Sep 2018 20:36:22 +0000 (21:36 +0100)
win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
win/CS/HandBrakeWPF/Services/Queue/Model/QueueStats.cs
win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
win/CS/HandBrakeWPF/Views/Queue/QueueTwoContent.xaml

index 4c3609f4e0f0dc1c1532d79e63aec13c4c2bc871..e1e5222c4e0884c0778461ffacc57f24abcbd56d 100644 (file)
@@ -2123,6 +2123,24 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Encode Time:.\r
+        /// </summary>\r
+        public static string QueueView_Duration {\r
+            get {\r
+                return ResourceManager.GetString("QueueView_Duration", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to End Time:.\r
+        /// </summary>\r
+        public static string QueueView_EndTime {\r
+            get {\r
+                return ResourceManager.GetString("QueueView_EndTime", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Export Queue for CLI.\r
         /// </summary>\r
@@ -2132,6 +2150,15 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Filesize: .\r
+        /// </summary>\r
+        public static string QueueView_FileSize {\r
+            get {\r
+                return ResourceManager.GetString("QueueView_FileSize", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Hibernate.\r
         /// </summary>\r
@@ -2150,6 +2177,15 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to The log will be available after the encode completes..\r
+        /// </summary>\r
+        public static string QueueView_LogNotAvailableYet {\r
+            get {\r
+                return ResourceManager.GetString("QueueView_LogNotAvailableYet", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Log off.\r
         /// </summary>\r
@@ -2195,6 +2231,15 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Paused Duration:.\r
+        /// </summary>\r
+        public static string QueueView_PausedDuration {\r
+            get {\r
+                return ResourceManager.GetString("QueueView_PausedDuration", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Picture Settings:.\r
         /// </summary>\r
@@ -2240,6 +2285,33 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Start Time:.\r
+        /// </summary>\r
+        public static string QueueView_StartTime {\r
+            get {\r
+                return ResourceManager.GetString("QueueView_StartTime", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Statistics.\r
+        /// </summary>\r
+        public static string QueueView_Statistics {\r
+            get {\r
+                return ResourceManager.GetString("QueueView_Statistics", resourceCulture);\r
+            }\r
+        }\r
+        \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Statistics will be available after an encode completes..\r
+        /// </summary>\r
+        public static string QueueView_StatsNotAvailableYet {\r
+            get {\r
+                return ResourceManager.GetString("QueueView_StatsNotAvailableYet", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Subtitles:.\r
         /// </summary>\r
@@ -2249,6 +2321,15 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Summary.\r
+        /// </summary>\r
+        public static string QueueView_Summary {\r
+            get {\r
+                return ResourceManager.GetString("QueueView_Summary", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Suspend.\r
         /// </summary>\r
index dfa6745dcbd4b830bfcf5854942238fd9aad4b82..9f7a186b92d07791e2f426bdd81216d6b24e36bb 100644 (file)
@@ -1061,4 +1061,31 @@ This will not affect your current settings in the Subtitle tab.</value>
   <data name="Options_ShowExperimentalQueueDesign" xml:space="preserve">\r
     <value>Show the new experimental queue design.</value>\r
   </data>\r
+  <data name="QueueView_Duration" xml:space="preserve">\r
+    <value>Encode Time:</value>\r
+  </data>\r
+  <data name="QueueView_EndTime" xml:space="preserve">\r
+    <value>End Time:</value>\r
+  </data>\r
+  <data name="QueueView_FileSize" xml:space="preserve">\r
+    <value>Filesize: </value>\r
+  </data>\r
+  <data name="QueueView_PausedDuration" xml:space="preserve">\r
+    <value>Paused Duration:</value>\r
+  </data>\r
+  <data name="QueueView_StartTime" xml:space="preserve">\r
+    <value>Start Time:</value>\r
+  </data>\r
+  <data name="QueueView_LogNotAvailableYet" xml:space="preserve">\r
+    <value>The log will be available after the encode completes.</value>\r
+  </data>\r
+  <data name="QueueView_Statistics" xml:space="preserve">\r
+    <value>Statistics</value>\r
+  </data>\r
+  <data name="QueueView_StatsNotAvailableYet" xml:space="preserve">\r
+    <value>Statistics will be available after an encode completes.</value>\r
+  </data>\r
+  <data name="QueueView_Summary" xml:space="preserve">\r
+    <value>Summary</value>\r
+  </data>\r
 </root>
\ No newline at end of file
index d12c99059c6f338dfee844f430551a5f4c9b695f..77454c4ad28e5ffe6580b58a1fe60571f396d0a1 100644 (file)
@@ -68,6 +68,11 @@ namespace HandBrakeWPF.Services.Queue.Model
         {
             get
             {
+                if (this.endTime == DateTime.MinValue)
+                {
+                    return TimeSpan.MinValue;
+                }
+
                 return this.EndTime - this.StartTime - this.PausedDuration;
             }
         }
index aefcf2980ef451213e30a13280a7f90f4320b80d..a11b14571af2e4f4395e67060d32c2b49b876f2c 100644 (file)
@@ -42,7 +42,6 @@ namespace HandBrakeWPF.ViewModels
         private readonly IErrorService errorService;\r
         private readonly IUserSettingService userSettingService;\r
         private readonly IQueueProcessor queueProcessor;\r
-        private bool isEncoding;\r
         private string jobStatus;\r
         private string jobsPending;\r
         private string whenDoneAction;\r
@@ -79,7 +78,7 @@ namespace HandBrakeWPF.ViewModels
             this.SelectedItems = new BindingList<QueueTask>();\r
             this.DisplayName = "Queue";\r
             this.IsQueueRunning = false;\r
-            \r
+\r
             this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction);\r
         }\r
 \r
@@ -189,11 +188,10 @@ namespace HandBrakeWPF.ViewModels
                 this.NotifyOfPropertyChange(() => this.CanRetryJob);\r
                 this.NotifyOfPropertyChange(() => this.CanEditJob);\r
                 this.NotifyOfPropertyChange(() => this.CanRemoveJob);\r
+                this.NotifyOfPropertyChange(() => this.StatsVisible);\r
             }\r
         }\r
 \r
-        public bool ShowLogTab { get; private set; }\r
-\r
         public string ActivityLog { get; private set; }\r
 \r
         public bool CanRetryJob => this.SelectedTask != null && this.SelectedTask.Status != QueueItemStatus.Waiting;\r
@@ -239,6 +237,20 @@ namespace HandBrakeWPF.ViewModels
 \r
         public bool IsInline { get; set; }\r
 \r
+        public bool StatsVisible\r
+        {\r
+            get\r
+            {\r
+                if (this.SelectedTask != null &&\r
+                    (this.selectedTask.Status == QueueItemStatus.Completed || this.selectedTask.Status == QueueItemStatus.Error))\r
+                {\r
+                    return true;\r
+                }\r
+\r
+                return false;\r
+            }\r
+        }\r
+\r
         #endregion\r
 \r
         #region Public Methods\r
@@ -340,7 +352,7 @@ namespace HandBrakeWPF.ViewModels
             this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);\r
             this.IsQueueRunning = false;\r
 \r
-            MessageBox.Show(Resources.QueueViewModel_QueuePauseNotice, Resources.QueueViewModel_Queue, \r
+            MessageBox.Show(Resources.QueueViewModel_QueuePauseNotice, Resources.QueueViewModel_Queue,\r
                 MessageBoxButton.OK, MessageBoxImage.Information);\r
         }\r
 \r
@@ -397,9 +409,9 @@ namespace HandBrakeWPF.ViewModels
             {\r
                 MessageBoxResult result =\r
                     this.errorService.ShowMessageBox(\r
-                        Resources.QueueViewModel_JobCurrentlyRunningWarning, \r
-                        Resources.Warning, \r
-                        MessageBoxButton.YesNo, \r
+                        Resources.QueueViewModel_JobCurrentlyRunningWarning,\r
+                        Resources.Warning,\r
+                        MessageBoxButton.YesNo,\r
                         MessageBoxImage.Question);\r
 \r
                 if (result == MessageBoxResult.Yes)\r
@@ -461,12 +473,12 @@ namespace HandBrakeWPF.ViewModels
         public void Export()\r
         {\r
             SaveFileDialog dialog = new SaveFileDialog\r
-                {\r
-                    Filter = "Json (*.json)|*.json", \r
-                    OverwritePrompt = true, \r
-                    DefaultExt = ".json", \r
-                    AddExtension = true\r
-                };\r
+            {\r
+                Filter = "Json (*.json)|*.json",\r
+                OverwritePrompt = true,\r
+                DefaultExt = ".json",\r
+                AddExtension = true\r
+            };\r
 \r
             if (dialog.ShowDialog() == true)\r
             {\r
@@ -495,9 +507,9 @@ namespace HandBrakeWPF.ViewModels
         public void EditJob(QueueTask task)\r
         {\r
             MessageBoxResult result = this.errorService.ShowMessageBox(\r
-                Resources.QueueViewModel_EditConfrimation, \r
-                "Modify Job?", \r
-                MessageBoxButton.YesNo, \r
+                Resources.QueueViewModel_EditConfrimation,\r
+                "Modify Job?",\r
+                MessageBoxButton.YesNo,\r
                 MessageBoxImage.Question);\r
 \r
             if (result != MessageBoxResult.Yes)\r
@@ -612,11 +624,37 @@ namespace HandBrakeWPF.ViewModels
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Open the Log file directory\r
+        /// </summary>\r
+        public void OpenLogDirectory()\r
+        {\r
+            string logDir = DirectoryUtilities.GetLogDirectory();\r
+            string windir = Environment.GetEnvironmentVariable("WINDIR");\r
+            Process prc = new Process { StartInfo = { FileName = windir + @"\explorer.exe", Arguments = logDir } };\r
+            prc.Start();\r
+        }\r
+\r
+        /// <summary>\r
+        /// Copy the log file to the system clipboard\r
+        /// </summary>\r
+        public void CopyLog()\r
+        {\r
+            try\r
+            {\r
+                Clipboard.SetDataObject(this.ActivityLog, true);\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                this.errorService.ShowError(Resources.Clipboard_Unavailable, Resources.Clipboard_Unavailable_Solution, exc);\r
+            }\r
+        }\r
+\r
         private void HandleLogData()\r
         {\r
-            if (this.SelectedTask == null || this.SelectedTask.Status == QueueItemStatus.InProgress)\r
+            if (this.SelectedTask == null || this.SelectedTask.Status == QueueItemStatus.InProgress || this.SelectedTask.Status == QueueItemStatus.Waiting)\r
             {\r
-                this.ShowLogTab = false;\r
+                this.ActivityLog = ResourcesUI.QueueView_LogNotAvailableYet;\r
             }\r
             else\r
             {\r
@@ -632,18 +670,15 @@ namespace HandBrakeWPF.ViewModels
                             this.ActivityLog = logContent;\r
                         }\r
 \r
-                        this.ShowLogTab = true;\r
                     }\r
                 }\r
                 catch (Exception exc)\r
                 {\r
                     Debug.WriteLine(exc);\r
-                    this.ShowLogTab = true;\r
                     this.ActivityLog = exc.ToString();\r
                 }\r
             }\r
 \r
-            this.NotifyOfPropertyChange(() => this.ShowLogTab);\r
             this.NotifyOfPropertyChange(() => this.ActivityLog);\r
         }\r
 \r
@@ -661,7 +696,7 @@ namespace HandBrakeWPF.ViewModels
             Execute.OnUIThread(() =>\r
             {\r
                 string jobsPending = string.Format(Resources.Main_JobsPending_addon, this.queueProcessor.Count);\r
-                this.IntermediateProgress = false; \r
+                this.IntermediateProgress = false;\r
 \r
                 if (e.IsSubtitleScan)\r
                 {\r
@@ -724,6 +759,8 @@ namespace HandBrakeWPF.ViewModels
             this.NotifyOfPropertyChange(() => this.CanRetryJob);\r
             this.NotifyOfPropertyChange(() => this.CanEditJob);\r
             this.NotifyOfPropertyChange(() => this.CanRemoveJob);\r
+            this.NotifyOfPropertyChange(() => this.StatsVisible);\r
+            this.HandleLogData();\r
         }\r
 \r
         /// <summary>\r
@@ -772,7 +809,7 @@ namespace HandBrakeWPF.ViewModels
         {\r
             this.JobStatus = Resources.QueueViewModel_QueueStarted;\r
             this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);\r
-            this.IsQueueRunning = true; \r
+            this.IsQueueRunning = true;\r
         }\r
 \r
         private void QueueProcessor_QueuePaused(object sender, EventArgs e)\r
index 3e3a93d803114cddfa7150a4fc8fd0816b57057a..1a8828be5d4e956324b964fac66290ef6fc0adb2 100644 (file)
                                     <TextBlock Text="{Binding Task.Destination, Converter={StaticResource filePathToFilenameConverter}}" />
                                 </StackPanel>
 
-                                <ProgressBar Minimum="0" Height="4" Maximum="100" Name="pbStatus" Margin="0,0,5,0"
+                                <ProgressBar Minimum="0" Height="4" Maximum="100" Name="pbStatus" Margin="0,2,5,0"
                                              Value="{Binding DataContext.ProgressValue, ElementName=queueJobs}" IsIndeterminate="{Binding DataContext.IntermediateProgress, ElementName=queueJobs}"
                                              Visibility="{Binding ShowEncodeProgress, Converter={StaticResource boolToVisConverter}}" />
                             </StackPanel>
                     </DataTemplate>
                 </ListBox.ItemTemplate>
             </ListBox>
-
-            <TabControl x:Name="summaryTabControl"  Grid.Column="1"  Margin="0,0,10,10">
-                <TabItem Header="Summary" >
+            
+            <TabControl x:Name="summaryTabControl"  Grid.Column="1"  Margin="0,0,10,10" >
+                <TabItem Header="{x:Static Properties:ResourcesUI.QueueView_Summary}" >
                     <ScrollViewer VerticalScrollBarVisibility="Auto" Margin="5,5,0,5">
 
                         <StackPanel Orientation="Vertical"  Margin="5,5,0,5">
                         </StackPanel>
                     </ScrollViewer>
                 </TabItem>
+
+                <TabItem Header="{x:Static Properties:ResourcesUI.QueueView_Statistics}" >
+                    <ScrollViewer VerticalScrollBarVisibility="Auto" Margin="10,0,0,5">
+                        <StackPanel>
+                            <TextBlock Text="{x:Static Properties:ResourcesUI.QueueView_StatsNotAvailableYet}" Margin="0,10,0,0" Visibility="{Binding StatsVisible, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
+
+                            <Grid Style="{StaticResource LongToolTipHolder}" Margin="0,5,0,0" Visibility="{Binding StatsVisible, Converter={StaticResource boolToVisConverter}}">
+                                <Grid.Resources>
+                                    <Style TargetType="TextBlock">
+                                        <Setter Property="Margin" Value="0,5,0,5" />
+                                    </Style>
+                                </Grid.Resources>
+
+                                <Grid.RowDefinitions>
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                </Grid.RowDefinitions>
+
+                                <Grid.ColumnDefinitions>
+                                    <ColumnDefinition Width="Auto" MinWidth="100" />
+                                    <ColumnDefinition Width="*" />
+                                </Grid.ColumnDefinitions>
+
+                                <TextBlock FontWeight="Bold" Text="{x:Static Properties:ResourcesUI.QueueView_StartTime}" VerticalAlignment="Top" Grid.Row="0" Grid.Column="0" />
+                                <TextBlock Text="{Binding SelectedTask.Statistics.StartTime}" TextWrapping="Wrap" Grid.Row="0" Grid.Column="1" />
+
+                                <TextBlock FontWeight="Bold" Text="{x:Static Properties:ResourcesUI.QueueView_EndTime}" VerticalAlignment="Top" Grid.Row="1" Grid.Column="0" />
+                                <TextBlock Text="{Binding SelectedTask.Statistics.EndTime}" TextWrapping="Wrap" Grid.Row="1" Grid.Column="1" />
+
+                                <TextBlock FontWeight="Bold" Text="{x:Static Properties:ResourcesUI.QueueView_PausedDuration}" VerticalAlignment="Top" Grid.Row="2" Grid.Column="0" />
+                                <TextBlock Text="{Binding SelectedTask.Statistics.PausedDuration,StringFormat=hh\\:mm\\:ss}" TextWrapping="Wrap" Grid.Row="2" Grid.Column="1" />
+
+                                <TextBlock FontWeight="Bold" Text="{x:Static Properties:ResourcesUI.QueueView_Duration}" VerticalAlignment="Top" Grid.Row="3" Grid.Column="0" />
+                                <TextBlock Text="{Binding SelectedTask.Statistics.Duration,StringFormat=hh\\:mm\\:ss}" TextWrapping="Wrap" Grid.Row="3" Grid.Column="1" />
+
+                                <TextBlock FontWeight="Bold" Text="{x:Static Properties:ResourcesUI.QueueView_FileSize}" VerticalAlignment="Top" Grid.Row="4" Grid.Column="0" />
+                                <StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="1" >
+                                    <TextBlock Text="{Binding SelectedTask.Statistics.FinalFileSizeInMegaBytes}" TextWrapping="Wrap" />
+                                    <TextBlock Text=" MB" />
+                                </StackPanel>
+
+                            </Grid>
+
+                        </StackPanel>
+                    </ScrollViewer>
+                </TabItem>
+
+                <TabItem Header="{x:Static Properties:ResourcesUI.MainView_ActivityLog}">
+                    <TextBox ScrollViewer.VerticalScrollBarVisibility="Visible" Text="{Binding ActivityLog, Mode=OneWay}" TextWrapping="Wrap" x:Name="logText">
+                        <TextBox.ContextMenu>
+                            <ContextMenu>
+                                <MenuItem Header="{x:Static Properties:ResourcesUI.LogView_CopyClipboard}" cal:Message.Attach="[Event Click] = [Action CopyLog]" >
+                                    <MenuItem.Icon>
+                                        <Image Width="16" Source="../Images/copy.png" />
+                                    </MenuItem.Icon>
+                                </MenuItem>
+                                <MenuItem Header="{x:Static Properties:ResourcesUI.LogView_OpenLogDir}" cal:Message.Attach="[Event Click] = [Action OpenLogDirectory]">
+                                    <MenuItem.Icon>
+                                        <Image Width="16" Source="../Images/folder.png" />
+                                    </MenuItem.Icon>
+                                </MenuItem>
+                            </ContextMenu>
+                        </TextBox.ContextMenu>
+                    </TextBox>
+                </TabItem>
             </TabControl>
 
         </Grid>