mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[Hosts]Add setting to select the file encoding (#26495)
This commit is contained in:
committed by
GitHub
parent
177c58f494
commit
9960d2d536
@@ -4,7 +4,7 @@
|
||||
|
||||
namespace Settings.UI.Library.Enumerations
|
||||
{
|
||||
public enum AdditionalLinesPosition
|
||||
public enum HostsAdditionalLinesPosition
|
||||
{
|
||||
Top = 0,
|
||||
Bottom = 1,
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace Settings.UI.Library.Enumerations
|
||||
{
|
||||
public enum HostsEncoding
|
||||
{
|
||||
Utf8 = 0,
|
||||
Utf8Bom = 1,
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,17 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
||||
public bool LoopbackDuplicates { get; set; }
|
||||
|
||||
public AdditionalLinesPosition AdditionalLinesPosition { get; set; }
|
||||
public HostsAdditionalLinesPosition AdditionalLinesPosition { get; set; }
|
||||
|
||||
public HostsEncoding Encoding { get; set; }
|
||||
|
||||
public HostsProperties()
|
||||
{
|
||||
ShowStartupWarning = true;
|
||||
LaunchAdministrator = true;
|
||||
LoopbackDuplicates = false;
|
||||
AdditionalLinesPosition = AdditionalLinesPosition.Top;
|
||||
AdditionalLinesPosition = HostsAdditionalLinesPosition.Top;
|
||||
Encoding = HostsEncoding.Utf8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user