From dd86130227573d5fb9ddfc15fcb28667fa470092 Mon Sep 17 00:00:00 2001
From: Sebastian Janning <janning@innovista.de>
Date: Tue, 10 Apr 2018 15:41:04 +0200
Subject: [PATCH] option to disable preview on summary tab (issue #1267)

---
 .../Properties/ResourcesUI.Designer.cs        |  9 +++++++
 .../HandBrakeWPF/Properties/ResourcesUI.resx  |  3 +++
 win/CS/HandBrakeWPF/UserSettingConstants.cs   |  5 ++++
 .../ViewModels/OptionsViewModel.cs            | 26 ++++++++++++++++---
 .../ViewModels/SummaryViewModel.cs            | 18 +++++++++++++
 win/CS/HandBrakeWPF/Views/OptionsView.xaml    |  1 +
 win/CS/HandBrakeWPF/Views/SummaryView.xaml    |  4 ++-
 7 files changed, 62 insertions(+), 4 deletions(-)

diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
index 6c09b67bd..a331ce7a1 100644
--- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
+++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
@@ -1689,6 +1689,15 @@ namespace HandBrakeWPF.Properties {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Show previews on summary tab..
+        /// </summary>
+        public static string OptionsView_ShowPreviewOnSummaryTab {
+            get {
+                return ResourceManager.GetString("OptionsView_ShowPreviewOnSummaryTab", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to Show the encode status in the application title bar..
         /// </summary>
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
index 16fc60bed..e0b83221c 100644
--- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
+++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
@@ -1022,4 +1022,7 @@ This will not affect your current settings in the Subtitle tab.</value>
   <data name="MainView_ShowPreview" xml:space="preserve">
     <value>Preview</value>
   </data>
+  <data name="OptionsView_ShowPreviewOnSummaryTab" xml:space="preserve">
+    <value>Show previews on summary tab.</value>
+  </data>
 </root>
\ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs
index 0d9270d78..34d24d25d 100644
--- a/win/CS/HandBrakeWPF/UserSettingConstants.cs
+++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs
@@ -236,6 +236,11 @@ namespace HandBrakeWPF
         /// </summary>
         public const string ShowStatusInTitleBar = "ShowStatusInTitleBar";
 
+        /// <summary>
+        /// Setting to turn on/off the ability to show previews in the summary tab.
+        /// </summary>
+        public const string ShowPreviewOnSummaryTab = "ShowPreviewOnSummaryTab";
+
         /// <summary>
         /// Setting to turn on/off the ability to play a sound when an encodeis done.
         /// </summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
index b0a47cde0..19209101f 100644
--- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
@@ -75,7 +75,7 @@ namespace HandBrakeWPF.ViewModels
         private int selectedVerbosity;
         private bool sendFileAfterEncode;
         private string sendFileTo;
-        private string sendFileToPath;       
+        private string sendFileToPath;
         private string vlcPath;
         private string whenDone;
         private BindingList<string> whenDoneOptions = new BindingList<string>();
@@ -95,6 +95,7 @@ namespace HandBrakeWPF.ViewModels
         private long pauseOnLowDiskspaceLevel;
         private bool useQsvDecodeForNonQsvEnc;
         private bool showStatusInTitleBar;
+        private bool showPreviewOnSummaryTab;
 
         private string whenDoneAudioFile;
         private bool playSoundWhenDone;
@@ -379,6 +380,23 @@ namespace HandBrakeWPF.ViewModels
             }
         }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether to show previews in the summary tab.
+        /// </summary>
+        public bool ShowPreviewOnSummaryTab
+        {
+            get
+            {
+                return this.showPreviewOnSummaryTab;
+            }
+            set
+            {
+                if (value == this.showPreviewOnSummaryTab) return;
+                this.showPreviewOnSummaryTab = value;
+                this.NotifyOfPropertyChange(() => this.ShowPreviewOnSummaryTab);
+            }
+        }
+
         /// <summary>
         /// When Done Audio File
         /// </summary>
@@ -484,8 +502,8 @@ namespace HandBrakeWPF.ViewModels
             {
                 if (this.IsValidAutonameFormat(value, false))
                 {
-                    this.autonameFormat = value;   
-                } 
+                    this.autonameFormat = value;
+                }
 
                 this.NotifyOfPropertyChange("AutonameFormat");
             }
@@ -1280,6 +1298,7 @@ namespace HandBrakeWPF.ViewModels
             this.ResetWhenDoneAction = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ResetWhenDoneAction);
             this.ShowQueueInline = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowQueueInline);
             this.ShowStatusInTitleBar = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowStatusInTitleBar);
+            this.ShowPreviewOnSummaryTab = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowPreviewOnSummaryTab);
             this.WhenDoneAudioFile = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenDoneAudioFile)) ?? string.Empty;
             this.WhenDoneAudioFileFullPath = this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenDoneAudioFile);
             this.PlaySoundWhenDone = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PlaySoundWhenDone);
@@ -1443,6 +1462,7 @@ namespace HandBrakeWPF.ViewModels
             this.userSettingService.SetUserSetting(UserSettingConstants.ResetWhenDoneAction, this.ResetWhenDoneAction);
             this.userSettingService.SetUserSetting(UserSettingConstants.ShowQueueInline, this.ShowQueueInline);
             this.userSettingService.SetUserSetting(UserSettingConstants.ShowStatusInTitleBar, this.ShowStatusInTitleBar);
+            this.userSettingService.SetUserSetting(UserSettingConstants.ShowPreviewOnSummaryTab, this.ShowPreviewOnSummaryTab);
             this.userSettingService.SetUserSetting(UserSettingConstants.PlaySoundWhenDone, this.PlaySoundWhenDone);
             this.userSettingService.SetUserSetting(UserSettingConstants.PlaySoundWhenQueueDone, this.PlaySoundWhenQueueDone);
             this.userSettingService.SetUserSetting(UserSettingConstants.WhenDoneAudioFile, this.WhenDoneAudioFileFullPath);
diff --git a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs
index ac12baf2c..e2a294009 100644
--- a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs
@@ -48,6 +48,8 @@ namespace HandBrakeWPF.ViewModels
         private bool isPreviousPreviewControlVisible;
         private bool isNextPreviewControlVisible;
 
+        private bool showPreview;
+
         public SummaryViewModel(IScan scanService, IUserSettingService userSettingService)
         {
             this.scanService = scanService;
@@ -174,6 +176,20 @@ namespace HandBrakeWPF.ViewModels
             }
         }
 
+        public bool ShowPreview
+        {
+            get
+            {
+                return this.showPreview;
+            }
+            set
+            {
+                if (value == this.showPreview) return;
+                this.showPreview = value;
+                this.NotifyOfPropertyChange(() => this.ShowPreview);
+            }
+        }
+
         #endregion
 
         #region Task Properties 
@@ -492,6 +508,8 @@ namespace HandBrakeWPF.ViewModels
             // Preview
             this.PreviewInfo = string.Format(ResourcesUI.SummaryView_PreviewInfo, this.selectedPreview, this.userSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount));
             this.NotifyOfPropertyChange(() => this.PreviewInfo);
+
+            this.ShowPreview = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowPreviewOnSummaryTab);
         }
 
         private string GetFilterDescription()
diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml
index 0743e0b9d..cf2c877e5 100644
--- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml
+++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml
@@ -175,6 +175,7 @@
                             <CheckBox Content="{x:Static Properties:ResourcesUI.Options_AdvancedTab}" IsChecked="{Binding ShowAdvancedTab}" />
                             <CheckBox Content="{x:Static Properties:ResourcesUI.Options_ShowQueueInline}" IsChecked="{Binding ShowQueueInline}" Visibility="Collapsed" />
                             <CheckBox Content="{x:Static Properties:ResourcesUI.OptionsView_ShowStatusInTitleBar}" IsChecked="{Binding ShowStatusInTitleBar}" />
+                            <CheckBox Content="{x:Static Properties:ResourcesUI.OptionsView_ShowPreviewOnSummaryTab}" IsChecked="{Binding ShowPreviewOnSummaryTab}" />
                         </StackPanel>
                     </StackPanel>
                 </StackPanel>
diff --git a/win/CS/HandBrakeWPF/Views/SummaryView.xaml b/win/CS/HandBrakeWPF/Views/SummaryView.xaml
index 884216802..edfbd1fac 100644
--- a/win/CS/HandBrakeWPF/Views/SummaryView.xaml
+++ b/win/CS/HandBrakeWPF/Views/SummaryView.xaml
@@ -95,7 +95,9 @@
         </Grid>
 
         <!-- Column 2 -->
-        <Grid Grid.Column="1" Margin="10,0,0,5">
+        <Grid Grid.Column="1"
+              Margin="10,0,0,5"
+              Visibility="{Binding ShowPreview, Converter={StaticResource boolToVisConverter}}">
             <Grid.ColumnDefinitions>
                 <ColumnDefinition Width="Auto" />
                 <ColumnDefinition Width="*" />
-- 
2.40.0