Skip to content

Commit

Permalink
Remember preferred quality, json chat compression, & text chat timest…
Browse files Browse the repository at this point in the history
…amp style (#1154)

* Add settings for chat json compression & chat text timestamp

* Cleanup

* Extend settings to chat updater page

* Remember preferred quality
  • Loading branch information
ScrubN authored Jul 17, 2024
1 parent 68d60e0 commit cf9101a
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 14 deletions.
9 changes: 9 additions & 0 deletions TwitchDownloaderWPF/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@
<setting name="VodTrimMode" serializeAs="String">
<value>1</value>
</setting>
<setting name="ChatJsonCompression" serializeAs="String">
<value>0</value>
</setting>
<setting name="ChatTextTimestampStyle" serializeAs="String">
<value>0</value>
</setting>
<setting name="PreferredQuality" serializeAs="String">
<value />
</setting>
</TwitchDownloaderWPF.Properties.Settings>
</userSettings>
</configuration>
11 changes: 5 additions & 6 deletions TwitchDownloaderWPF/PageChatDownload.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@
<RadioButton x:Name="radioHTML" Content="HTML" Checked="radioHTML_Checked" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
</hc:ButtonGroup>
<StackPanel Visibility="Visible" x:Name="compressionOptions" Margin="5,8,0,0" Orientation="Horizontal">
<RadioButton x:Name="radioCompressionNone" IsChecked="True" Content="{lex:Loc ChatCompressionNone}" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioCompressionGzip" Content="{lex:Loc ChatCompressionGzip}" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioCompressionNone" IsChecked="True" Content="{lex:Loc ChatCompressionNone}" Margin="3,0,0,0" Checked="RadioCompressionNone_OnCheckedChanged" Unchecked="RadioCompressionNone_OnCheckedChanged" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioCompressionGzip" Content="{lex:Loc ChatCompressionGzip}" Margin="3,0,0,0" Checked="RadioCompressionGzip_OnCheckedChanged" Unchecked="RadioCompressionGzip_OnCheckedChanged" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
</StackPanel>
<StackPanel Visibility="Collapsed" x:Name="timeOptions" Margin="5,8,0,0" Orientation="Horizontal">
<RadioButton x:Name="radioTimestampUTC" IsChecked="True" Content="{lex:Loc TimestampUtc}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampRelative" Content="{lex:Loc TimestampRelative}" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampNone" Content="{lex:Loc TimestampNone}" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampUTC" IsChecked="True" Content="{lex:Loc TimestampUtc}" Checked="RadioTimestampUTC_OnCheckedChanged" Unchecked="RadioTimestampUTC_OnCheckedChanged" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampRelative" Content="{lex:Loc TimestampRelative}" Margin="3,0,0,0" Checked="RadioTimestampRelative_OnCheckedChanged" Unchecked="RadioTimestampRelative_OnCheckedChanged" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampNone" Content="{lex:Loc TimestampNone}" Margin="3,0,0,0" Checked="RadioTimestampNone_OnCheckedChanged" Unchecked="RadioTimestampNone_OnCheckedChanged" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
</StackPanel>
<StackPanel Margin="5,5,0,0">
<StackPanel Orientation="Horizontal">
Expand All @@ -106,7 +106,6 @@
<hc:NumericUpDown Margin="3,-1,0,0" Minimum="0" Maximum="48" Value="0" x:Name="numEndHour" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<hc:NumericUpDown Margin="3,-1,0,0" Minimum="0" Maximum="60" Value="0" x:Name="numEndMinute" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<hc:NumericUpDown Margin="3,-1,0,0" Minimum="0" Maximum="60" Value="0" x:Name="numEndSecond" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />

</StackPanel>
</StackPanel>
<StackPanel x:Name="stackEmbedChecks" Visibility="Visible">
Expand Down
61 changes: 60 additions & 1 deletion TwitchDownloaderWPF/PageChatDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down Expand Up @@ -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();
}
}
}
10 changes: 5 additions & 5 deletions TwitchDownloaderWPF/PageChatUpdate.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@
<RadioButton x:Name="radioHTML" Content="HTML" Checked="radioHTML_Checked" Background="{DynamicResource AppElementBackground}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
</hc:ButtonGroup>
<StackPanel Visibility="Visible" x:Name="compressionOptions" Margin="5,8,0,0" Orientation="Horizontal">
<RadioButton x:Name="radioCompressionNone" IsChecked="True" Content="{lex:Loc ChatCompressionNone}" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioCompressionGzip" Content="{lex:Loc ChatCompressionGzip}" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioCompressionNone" IsChecked="True" Content="{lex:Loc ChatCompressionNone}" Checked="RadioCompressionNone_OnCheckedChanged" Unchecked="RadioCompressionNone_OnCheckedChanged" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioCompressionGzip" Content="{lex:Loc ChatCompressionGzip}" Checked="RadioCompressionGzip_OnCheckedChanged" Unchecked="RadioCompressionGzip_OnCheckedChanged" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
</StackPanel>
<StackPanel Visibility="Collapsed" x:Name="timeOptions" Margin="5,8,0,0" Orientation="Horizontal">
<RadioButton x:Name="radioTimestampUTC" IsChecked="True" Content="{lex:Loc TimestampUtc}" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampRelative" Content="{lex:Loc TimestampRelative}" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampNone" Content="{lex:Loc TimestampNone}" Margin="3,0,0,0" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampUTC" IsChecked="True" Content="{lex:Loc TimestampUtc}" Checked="RadioTimestampUTC_OnCheckedChanged" Unchecked="RadioTimestampUTC_OnCheckedChanged" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampRelative" Content="{lex:Loc TimestampRelative}" Margin="3,0,0,0" Checked="RadioTimestampRelative_OnCheckedChanged" Unchecked="RadioTimestampRelative_OnCheckedChanged" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
<RadioButton x:Name="radioTimestampNone" Content="{lex:Loc TimestampNone}" Margin="3,0,0,0" Checked="RadioTimestampNone_OnCheckedChanged" Unchecked="RadioTimestampNone_OnCheckedChanged" BorderBrush="{DynamicResource AppElementBorder}" Foreground="{DynamicResource AppText}" />
</StackPanel>
<StackPanel Margin="5,5,0,0">
<StackPanel Orientation="Horizontal">
Expand Down
61 changes: 60 additions & 1 deletion TwitchDownloaderWPF/PageChatUpdate.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down Expand Up @@ -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();
}
}
}
36 changes: 36 additions & 0 deletions TwitchDownloaderWPF/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions TwitchDownloaderWPF/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@
<Setting Name="VodTrimMode" Type="System.Int32" Scope="User">
<Value Profile="(Default)">1</Value>
</Setting>
<Setting Name="ChatJsonCompression" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="ChatTextTimestampStyle" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="PreferredQuality" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

2 changes: 1 addition & 1 deletion TwitchDownloaderWPF/WindowQueueOptions.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<CheckBox x:Name="checkVideo" Content="{lex:Loc DownloadVideo}" HorizontalAlignment="Left" Margin="0,8,0,0" VerticalAlignment="Top" Checked="CheckVideo_OnChecked" Unchecked="CheckVideo_OnChecked" Foreground="{DynamicResource AppText}" BorderBrush="{DynamicResource AppElementBorder}"/>
<StackPanel Orientation="Horizontal" Margin="20,5,0,0">
<TextBlock x:Name="TextPreferredQuality" Text="{lex:Loc PreferredQuality}" HorizontalAlignment="Right" Margin="5,5,0,0" Foreground="{DynamicResource AppTextDisabled}" />
<ComboBox SelectedIndex="0" x:Name="ComboPreferredQuality" IsEnabled="False" Margin="5,0,0,0" MinWidth="90" Background="{DynamicResource AppElementBackground}" Foreground="{DynamicResource AppText}" BorderBrush="{DynamicResource AppElementBorder}">
<ComboBox SelectedIndex="0" x:Name="ComboPreferredQuality" IsEnabled="False" Margin="5,0,0,0" MinWidth="90" SelectionChanged="ComboPreferredQuality_OnSelectionChanged" Background="{DynamicResource AppElementBackground}" Foreground="{DynamicResource AppText}" BorderBrush="{DynamicResource AppElementBorder}">
<ComboBoxItem Content="Source" />
<ComboBoxItem Content="1440p" />
<ComboBoxItem Content="1080p" />
Expand Down
21 changes: 21 additions & 0 deletions TwitchDownloaderWPF/WindowQueueOptions.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ public WindowQueueOptions(List<TaskData> 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)
Expand Down Expand Up @@ -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;
}
}
}
}

0 comments on commit cf9101a

Please sign in to comment.