mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-02-16 10:58:31 -05:00
Add support for per-feed user agent
This commit is contained in:
@@ -94,6 +94,13 @@
|
||||
<ComboBoxItem Content="{x:Static properties:Resources.openAllMultipleToolbarButton}"
|
||||
Tag="{x:Static feedCenter:MultipleOpenAction.IndividualPages}" />
|
||||
</ComboBox>
|
||||
<ComboBox Name="UserAgentComboBox"
|
||||
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||
mah:TextBoxHelper.Watermark="{x:Static properties:Resources.userAgentLabel}"
|
||||
DisplayMemberPath="Caption"
|
||||
ItemsSource="{Binding Source={x:Static options:UserAgentItem.UserAgents}}"
|
||||
SelectedValuePath="UserAgent"
|
||||
SelectedValue="{Binding Path=UserAgent, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=true}" />
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="{x:Static properties:Resources.authenticationTab}">
|
||||
|
||||
@@ -12,11 +12,9 @@
|
||||
d:DesignWidth="300">
|
||||
<StackPanel options:Spacing.Vertical="10">
|
||||
<CheckBox Content="{x:Static properties:Resources.startWithWindowsCheckBox}"
|
||||
Name="StartWithWindowsCheckBox"
|
||||
IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=StartWithWindows}"
|
||||
Click="OnSaveSettings" />
|
||||
<ComboBox Name="BrowserComboBox"
|
||||
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||
<ComboBox mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||
mah:TextBoxHelper.Watermark="{x:Static properties:Resources.defaultBrowserLabel}"
|
||||
d:DataContext="{d:DesignInstance Type=installedBrowsers:InstalledBrowser}"
|
||||
DisplayMemberPath="Name"
|
||||
@@ -24,12 +22,11 @@
|
||||
SelectedValuePath="Key"
|
||||
SelectedValue="{Binding Source={x:Static properties:Settings.Default}, Path=Browser}"
|
||||
SelectionChanged="OnSaveSettings" />
|
||||
<ComboBox Name="UserAgentComboBox"
|
||||
mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||
<ComboBox mah:TextBoxHelper.UseFloatingWatermark="True"
|
||||
mah:TextBoxHelper.Watermark="{x:Static properties:Resources.defaultUserAgentLabel}"
|
||||
d:DataContext="{d:DesignInstance Type=options:UserAgentItem}"
|
||||
DisplayMemberPath="Caption"
|
||||
ItemsSource="{Binding Source={x:Static options:UserAgentItem.UserAgents}}"
|
||||
ItemsSource="{Binding Source={x:Static options:UserAgentItem.DefaultUserAgents}}"
|
||||
SelectedValuePath="UserAgent"
|
||||
SelectedValue="{Binding Source={x:Static properties:Settings.Default}, Path=DefaultUserAgent}"
|
||||
SelectionChanged="OnSaveSettings" />
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FeedCenter.Properties;
|
||||
|
||||
namespace FeedCenter.Options;
|
||||
|
||||
public class UserAgentItem
|
||||
{
|
||||
public string Caption { get; set; }
|
||||
public string UserAgent { get; set; }
|
||||
|
||||
public static List<UserAgentItem> UserAgents => new()
|
||||
public static List<UserAgentItem> DefaultUserAgents => new()
|
||||
{
|
||||
new UserAgentItem
|
||||
{
|
||||
Caption = Properties.Resources.DefaultUserAgentCaption,
|
||||
Caption = Properties.Resources.ApplicationUserAgentCaption,
|
||||
UserAgent = string.Empty
|
||||
},
|
||||
new UserAgentItem
|
||||
@@ -30,4 +31,29 @@ public class UserAgentItem
|
||||
UserAgent = "curl/7.47.0"
|
||||
}
|
||||
};
|
||||
|
||||
public string UserAgent { get; set; }
|
||||
|
||||
public static List<UserAgentItem> UserAgents
|
||||
{
|
||||
get
|
||||
{
|
||||
var defaultUserAgents = DefaultUserAgents;
|
||||
|
||||
var applicationDefaultUserAgent = defaultUserAgents.First(dua => dua.UserAgent == Settings.Default.DefaultUserAgent);
|
||||
|
||||
var userAgents = new List<UserAgentItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Caption = string.Format(Resources.DefaultUserAgentCaption, applicationDefaultUserAgent.Caption),
|
||||
UserAgent = null
|
||||
}
|
||||
};
|
||||
|
||||
userAgents.AddRange(defaultUserAgents);
|
||||
|
||||
return userAgents;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user