From cf9101a9b933c2975b13d0a2945d9349de0825ce Mon Sep 17 00:00:00 2001
From: Scrub <72096833+ScrubN@users.noreply.github.com>
Date: Tue, 16 Jul 2024 20:02:37 -0400
Subject: [PATCH] Remember preferred quality, json chat compression, & text
chat timestamp style (#1154)
* Add settings for chat json compression & chat text timestamp
* Cleanup
* Extend settings to chat updater page
* Remember preferred quality
---
TwitchDownloaderWPF/App.config | 9 +++
TwitchDownloaderWPF/PageChatDownload.xaml | 11 ++--
TwitchDownloaderWPF/PageChatDownload.xaml.cs | 61 ++++++++++++++++++-
TwitchDownloaderWPF/PageChatUpdate.xaml | 10 +--
TwitchDownloaderWPF/PageChatUpdate.xaml.cs | 61 ++++++++++++++++++-
.../Properties/Settings.Designer.cs | 36 +++++++++++
.../Properties/Settings.settings | 9 +++
TwitchDownloaderWPF/WindowQueueOptions.xaml | 2 +-
.../WindowQueueOptions.xaml.cs | 21 +++++++
9 files changed, 206 insertions(+), 14 deletions(-)
diff --git a/TwitchDownloaderWPF/App.config b/TwitchDownloaderWPF/App.config
index fadf8a0c..e16ebc9c 100644
--- a/TwitchDownloaderWPF/App.config
+++ b/TwitchDownloaderWPF/App.config
@@ -235,6 +235,15 @@
1
+
+ 0
+
+
+ 0
+
+
+
+
\ No newline at end of file
diff --git a/TwitchDownloaderWPF/PageChatDownload.xaml b/TwitchDownloaderWPF/PageChatDownload.xaml
index 08d5c749..beb9c1e0 100644
--- a/TwitchDownloaderWPF/PageChatDownload.xaml
+++ b/TwitchDownloaderWPF/PageChatDownload.xaml
@@ -84,13 +84,13 @@
-
-
+
+
-
-
-
+
+
+
@@ -106,7 +106,6 @@
-
diff --git a/TwitchDownloaderWPF/PageChatDownload.xaml.cs b/TwitchDownloaderWPF/PageChatDownload.xaml.cs
index 1f295062..e6913302 100644
--- a/TwitchDownloaderWPF/PageChatDownload.xaml.cs
+++ b/TwitchDownloaderWPF/PageChatDownload.xaml.cs
@@ -55,7 +55,21 @@ private void Page_Initialized(object sender, EventArgs e)
{
ChatFormat.Text => radioText.IsChecked = true,
ChatFormat.Html => radioHTML.IsChecked = true,
- _ => radioJson.IsChecked = true
+ ChatFormat.Json => radioJson.IsChecked = true,
+ _ => null,
+ };
+ _ = (ChatCompression)Settings.Default.ChatJsonCompression switch
+ {
+ ChatCompression.None => radioCompressionNone.IsChecked = true,
+ ChatCompression.Gzip => radioCompressionGzip.IsChecked = true,
+ _ => null,
+ };
+ _ = (TimestampFormat)Settings.Default.ChatTextTimestampStyle switch
+ {
+ TimestampFormat.Utc => radioTimestampUTC.IsChecked = true,
+ TimestampFormat.Relative => radioTimestampRelative.IsChecked = true,
+ TimestampFormat.None => radioTimestampNone.IsChecked = true,
+ _ => null,
};
}
@@ -601,5 +615,50 @@ private async void TextUrl_OnKeyDown(object sender, KeyEventArgs e)
e.Handled = true;
}
}
+
+ private void RadioCompressionNone_OnCheckedChanged(object sender, RoutedEventArgs e)
+ {
+ if (!IsInitialized)
+ return;
+
+ Settings.Default.ChatJsonCompression = (int)ChatCompression.None;
+ Settings.Default.Save();
+ }
+
+ private void RadioCompressionGzip_OnCheckedChanged(object sender, RoutedEventArgs e)
+ {
+ if (!IsInitialized)
+ return;
+
+ Settings.Default.ChatJsonCompression = (int)ChatCompression.Gzip;
+ Settings.Default.Save();
+ }
+
+ private void RadioTimestampUTC_OnCheckedChanged(object sender, RoutedEventArgs e)
+ {
+ if (!IsInitialized)
+ return;
+
+ Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.Utc;
+ Settings.Default.Save();
+ }
+
+ private void RadioTimestampRelative_OnCheckedChanged(object sender, RoutedEventArgs e)
+ {
+ if (!IsInitialized)
+ return;
+
+ Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.Relative;
+ Settings.Default.Save();
+ }
+
+ private void RadioTimestampNone_OnCheckedChanged(object sender, RoutedEventArgs e)
+ {
+ if (!IsInitialized)
+ return;
+
+ Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.None;
+ Settings.Default.Save();
+ }
}
}
\ No newline at end of file
diff --git a/TwitchDownloaderWPF/PageChatUpdate.xaml b/TwitchDownloaderWPF/PageChatUpdate.xaml
index 7bf1683d..8aaff93e 100644
--- a/TwitchDownloaderWPF/PageChatUpdate.xaml
+++ b/TwitchDownloaderWPF/PageChatUpdate.xaml
@@ -84,13 +84,13 @@
-
-
+
+
-
-
-
+
+
+
diff --git a/TwitchDownloaderWPF/PageChatUpdate.xaml.cs b/TwitchDownloaderWPF/PageChatUpdate.xaml.cs
index 732abef6..b21bedd2 100644
--- a/TwitchDownloaderWPF/PageChatUpdate.xaml.cs
+++ b/TwitchDownloaderWPF/PageChatUpdate.xaml.cs
@@ -215,7 +215,21 @@ private void Page_Initialized(object sender, EventArgs e)
{
ChatFormat.Text => radioText.IsChecked = true,
ChatFormat.Html => radioHTML.IsChecked = true,
- _ => radioJson.IsChecked = true
+ ChatFormat.Json => radioJson.IsChecked = true,
+ _ => null,
+ };
+ _ = (ChatCompression)Settings.Default.ChatJsonCompression switch
+ {
+ ChatCompression.None => radioCompressionNone.IsChecked = true,
+ ChatCompression.Gzip => radioCompressionGzip.IsChecked = true,
+ _ => null,
+ };
+ _ = (TimestampFormat)Settings.Default.ChatTextTimestampStyle switch
+ {
+ TimestampFormat.Utc => radioTimestampUTC.IsChecked = true,
+ TimestampFormat.Relative => radioTimestampRelative.IsChecked = true,
+ TimestampFormat.None => radioTimestampNone.IsChecked = true,
+ _ => null,
};
}
@@ -666,5 +680,50 @@ private void MenuItemEnqueue_Click(object sender, RoutedEventArgs e)
};
queueOptions.ShowDialog();
}
+
+ private void RadioCompressionNone_OnCheckedChanged(object sender, RoutedEventArgs e)
+ {
+ if (!IsInitialized)
+ return;
+
+ Settings.Default.ChatJsonCompression = (int)ChatCompression.None;
+ Settings.Default.Save();
+ }
+
+ private void RadioCompressionGzip_OnCheckedChanged(object sender, RoutedEventArgs e)
+ {
+ if (!IsInitialized)
+ return;
+
+ Settings.Default.ChatJsonCompression = (int)ChatCompression.Gzip;
+ Settings.Default.Save();
+ }
+
+ private void RadioTimestampUTC_OnCheckedChanged(object sender, RoutedEventArgs e)
+ {
+ if (!IsInitialized)
+ return;
+
+ Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.Utc;
+ Settings.Default.Save();
+ }
+
+ private void RadioTimestampRelative_OnCheckedChanged(object sender, RoutedEventArgs e)
+ {
+ if (!IsInitialized)
+ return;
+
+ Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.Relative;
+ Settings.Default.Save();
+ }
+
+ private void RadioTimestampNone_OnCheckedChanged(object sender, RoutedEventArgs e)
+ {
+ if (!IsInitialized)
+ return;
+
+ Settings.Default.ChatTextTimestampStyle = (int)TimestampFormat.None;
+ Settings.Default.Save();
+ }
}
}
\ No newline at end of file
diff --git a/TwitchDownloaderWPF/Properties/Settings.Designer.cs b/TwitchDownloaderWPF/Properties/Settings.Designer.cs
index 967eff76..0f0c6b35 100644
--- a/TwitchDownloaderWPF/Properties/Settings.Designer.cs
+++ b/TwitchDownloaderWPF/Properties/Settings.Designer.cs
@@ -933,5 +933,41 @@ public int VodTrimMode {
this["VodTrimMode"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public int ChatJsonCompression {
+ get {
+ return ((int)(this["ChatJsonCompression"]));
+ }
+ set {
+ this["ChatJsonCompression"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public int ChatTextTimestampStyle {
+ get {
+ return ((int)(this["ChatTextTimestampStyle"]));
+ }
+ set {
+ this["ChatTextTimestampStyle"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string PreferredQuality {
+ get {
+ return ((string)(this["PreferredQuality"]));
+ }
+ set {
+ this["PreferredQuality"] = value;
+ }
+ }
}
}
diff --git a/TwitchDownloaderWPF/Properties/Settings.settings b/TwitchDownloaderWPF/Properties/Settings.settings
index 55bedc3f..15564aee 100644
--- a/TwitchDownloaderWPF/Properties/Settings.settings
+++ b/TwitchDownloaderWPF/Properties/Settings.settings
@@ -230,6 +230,15 @@
1
+
+ 0
+
+
+ 0
+
+
+
+
diff --git a/TwitchDownloaderWPF/WindowQueueOptions.xaml b/TwitchDownloaderWPF/WindowQueueOptions.xaml
index c7717d4b..154a73eb 100644
--- a/TwitchDownloaderWPF/WindowQueueOptions.xaml
+++ b/TwitchDownloaderWPF/WindowQueueOptions.xaml
@@ -36,7 +36,7 @@
-
+
diff --git a/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs b/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs
index b38fd225..e76849bb 100644
--- a/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs
+++ b/TwitchDownloaderWPF/WindowQueueOptions.xaml.cs
@@ -98,6 +98,16 @@ public WindowQueueOptions(List dataList)
string queueFolder = Settings.Default.QueueFolder;
if (Directory.Exists(queueFolder))
textFolder.Text = queueFolder;
+
+ var preferredQuality = Settings.Default.PreferredQuality;
+ for (var i = 0; i < ComboPreferredQuality.Items.Count; i++)
+ {
+ if (ComboPreferredQuality.Items[i] is ComboBoxItem { Content: string quality } && quality == preferredQuality)
+ {
+ ComboPreferredQuality.SelectedIndex = i;
+ break;
+ }
+ }
}
private FileInfo HandleFileCollisionCallback(FileInfo fileInfo)
@@ -721,5 +731,16 @@ private void CheckVideo_OnChecked(object sender, RoutedEventArgs e)
catch { /* Ignored */ }
}
}
+
+ private void ComboPreferredQuality_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (!IsInitialized)
+ return;
+
+ if (ComboPreferredQuality.SelectedItem is ComboBoxItem { Content: string preferredQuality })
+ {
+ Settings.Default.PreferredQuality = preferredQuality;
+ }
+ }
}
}
\ No newline at end of file