Skip to content

Commit

Permalink
Remember preferred quality
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrubN committed Jul 16, 2024
1 parent 2c446dd commit 60ad605
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
3 changes: 3 additions & 0 deletions TwitchDownloaderWPF/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@
<setting name="ChatTextTimestampStyle" serializeAs="String">
<value>0</value>
</setting>
<setting name="PreferredQuality" serializeAs="String">
<value />
</setting>
</TwitchDownloaderWPF.Properties.Settings>
</userSettings>
</configuration>
12 changes: 12 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.

3 changes: 3 additions & 0 deletions TwitchDownloaderWPF/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@
<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 60ad605

Please sign in to comment.