[Hosts]Add setting to select the file encoding (#26495)

This commit is contained in:
Davide Giacometti
2023-06-06 17:11:37 +02:00
committed by GitHub
parent 177c58f494
commit 9960d2d536
10 changed files with 68 additions and 13 deletions

View File

@@ -3537,4 +3537,17 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="MWB_SecurityKeyLabel.PlaceholderText" xml:space="preserve">
<value>Security key</value>
</data>
<data name="Hosts_Encoding.Description" xml:space="preserve">
<value>Chose the encoding of the hosts file</value>
<comment>"Hosts" refers to the system hosts file, do not loc</comment>
</data>
<data name="Hosts_Encoding.Header" xml:space="preserve">
<value>Encoding</value>
</data>
<data name="Hosts_Encoding_Utf8.Content" xml:space="preserve">
<value>UTF-8</value>
</data>
<data name="Hosts_Encoding_Utf8Bom.Content" xml:space="preserve">
<value>UTF-8 with BOM</value>
</data>
</root>

View File

@@ -109,7 +109,20 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (value != (int)Settings.Properties.AdditionalLinesPosition)
{
Settings.Properties.AdditionalLinesPosition = (AdditionalLinesPosition)value;
Settings.Properties.AdditionalLinesPosition = (HostsAdditionalLinesPosition)value;
NotifyPropertyChanged();
}
}
}
public int Encoding
{
get => (int)Settings.Properties.Encoding;
set
{
if (value != (int)Settings.Properties.Encoding)
{
Settings.Properties.Encoding = (HostsEncoding)value;
NotifyPropertyChanged();
}
}

View File

@@ -60,6 +60,12 @@
x:Uid="ToggleSwitch"
IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.LoopbackDuplicates}" />
</labs:SettingsCard>
<labs:SettingsCard x:Uid="Hosts_Encoding">
<ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{x:Bind Path=ViewModel.Encoding, Mode=TwoWay}">
<ComboBoxItem x:Uid="Hosts_Encoding_Utf8" />
<ComboBoxItem x:Uid="Hosts_Encoding_Utf8Bom" />
</ComboBox>
</labs:SettingsCard>
</controls:SettingsGroup>
</StackPanel>
</controls:SettingsPageControl.ModuleContent>