mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-27 14:59:16 +08:00
Changes Language selection UI
- Groups languages into two groups - Sort them by localized language name - Remove unneeded looping when no languages selected
This commit is contained in:
parent
714ce45465
commit
90c5d326f2
@ -61,6 +61,11 @@ namespace PowerAccent.Core
|
||||
return GetDefaultLetterKeyALL(letter);
|
||||
}
|
||||
|
||||
if (langs.Length == 0)
|
||||
{
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
|
||||
var characters = new List<string>();
|
||||
foreach (var lang in langs)
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ public class SettingsService
|
||||
_keyboardListener.UpdateExcludedApps(ExcludedApps);
|
||||
|
||||
SelectedLang = settings.Properties.SelectedLang.Value
|
||||
.Split(',')
|
||||
.Split(',', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(lang => Enum.TryParse(lang, out Language selectedLangValue) ? selectedLangValue : Language.SPECIAL)
|
||||
.ToArray();
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
public class PowerAccentLanguageGroupModel : List<PowerAccentLanguageModel>
|
||||
{
|
||||
public PowerAccentLanguageGroupModel(List<PowerAccentLanguageModel> languages, string group)
|
||||
: base(languages)
|
||||
{
|
||||
this.Group = group;
|
||||
}
|
||||
|
||||
public string Group { get; init; }
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
// 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 Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
public record PowerAccentLanguageModel(string LanguageCode, string LanguageResourceID, string GroupResourceID)
|
||||
{
|
||||
public string Language { get; set; }
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
x:Class="Microsoft.PowerToys.Settings.UI.Views.PowerAccentPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Lib="using:Microsoft.PowerToys.Settings.UI.Library"
|
||||
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
@ -9,6 +10,15 @@
|
||||
xmlns:ui="using:CommunityToolkit.WinUI"
|
||||
AutomationProperties.LandmarkType="Main"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<CollectionViewSource
|
||||
x:Name="LanguagesCustomViewSource"
|
||||
IsSourceGrouped="True"
|
||||
Source="{x:Bind ViewModel.LanguageGroups, Mode=OneWay}" />
|
||||
<DataTemplate x:Key="LanguageViewTemplate" x:DataType="Lib:PowerAccentLanguageModel">
|
||||
<TextBlock Text="{x:Bind Language}" />
|
||||
</DataTemplate>
|
||||
</Page.Resources>
|
||||
|
||||
<controls:SettingsPageControl
|
||||
x:Uid="QuickAccent"
|
||||
@ -70,6 +80,9 @@
|
||||
MinHeight="{StaticResource SettingActionControlMinWidth}"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch"
|
||||
ItemTemplate="{StaticResource LanguageViewTemplate}"
|
||||
ItemsSource="{x:Bind LanguagesCustomViewSource.View, Mode=OneWay}"
|
||||
Loaded="QuickAccent_Language_Select_Loaded"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Visible"
|
||||
ScrollViewer.HorizontalScrollMode="Enabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||
@ -93,153 +106,46 @@
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
CheckBoxBorderBrush="{ThemeResource CheckBoxBorderThemeBrush}"
|
||||
CheckBoxBrush="{ThemeResource CheckBoxBackgroundThemeBrush}"
|
||||
CheckBrush="{ThemeResource CheckBoxForegroundUnchecked}"
|
||||
CheckBoxBrush="{ThemeResource CheckBoxCheckBackgroundFillUnchecked}"
|
||||
CheckBoxCornerRadius="{ThemeResource ControlCornerRadius}"
|
||||
CheckBoxDisabledBorderBrush="{ThemeResource CheckBoxDisabledBorderThemeBrush}"
|
||||
CheckBoxDisabledBrush="{ThemeResource CheckBoxCheckBackgroundFillUncheckedDisabled}"
|
||||
CheckBoxPointerOverBorderBrush="{ThemeResource CheckBoxPointerOverBorderThemeBrush}"
|
||||
CheckBoxPointerOverBrush="{ThemeResource CheckBoxCheckBackgroundFillUncheckedPointerOver}"
|
||||
CheckBoxPressedBorderBrush="{ThemeResource CheckBoxPressedBorderThemeBrush}"
|
||||
CheckBoxPressedBrush="{ThemeResource CheckBoxCheckBackgroundFillUncheckedPressed}"
|
||||
CheckBoxSelectedBrush="{ThemeResource CheckBoxCheckBackgroundFillChecked}"
|
||||
CheckBoxSelectedDisabledBrush="{ThemeResource CheckBoxCheckBackgroundFillCheckedDisabled}"
|
||||
CheckBoxSelectedPointerOverBrush="{ThemeResource CheckBoxCheckBackgroundFillCheckedPointerOver}"
|
||||
CheckBoxSelectedPressedBrush="{ThemeResource CheckBoxCheckBackgroundFillCheckedPressed}"
|
||||
CheckBrush="{ThemeResource CheckBoxCheckGlyphForegroundChecked}"
|
||||
CheckDisabledBrush="{ThemeResource CheckBoxCheckGlyphForegroundCheckedDisabled}"
|
||||
CheckMode="Inline"
|
||||
CheckPressedBrush="{ThemeResource CheckBoxCheckGlyphForegroundUncheckedPressed}"
|
||||
ContentMargin="{TemplateBinding Padding}"
|
||||
ContentTransitions="{TemplateBinding ContentTransitions}"
|
||||
DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
|
||||
DragBackground="{ThemeResource ListViewItemDragBackgroundThemeBrush}"
|
||||
DragForeground="{ThemeResource ListViewItemDragForegroundThemeBrush}"
|
||||
DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}"
|
||||
FocusBorderBrush="{ThemeResource SystemControlForegroundAltHighBrush}"
|
||||
FocusSecondaryBorderBrush="{ThemeResource SystemControlForegroundBaseHighBrush}"
|
||||
PlaceholderBackground="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"
|
||||
PointerOverBackground="{ThemeResource SystemControlHighlightListLowBrush}"
|
||||
PointerOverForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
|
||||
PressedBackground="{ThemeResource SystemControlHighlightListMediumBrush}"
|
||||
ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
|
||||
SelectedBackground="{ThemeResource SystemControlHighlightListAccentLowBrush}"
|
||||
SelectedForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
|
||||
SelectedPointerOverBackground="{ThemeResource SystemControlHighlightListAccentMediumBrush}"
|
||||
SelectedPressedBackground="{ThemeResource SystemControlHighlightListAccentHighBrush}"
|
||||
SelectionCheckMarkVisualEnabled="True" />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
<!-- These should be in the same order as the array items in PowerAccentViewModel.cs -->
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Special" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Bulgarian" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Catalan" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Crimean" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Currency" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Croatian" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Czech" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Danish" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Gaeilge" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Gaidhlig" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Dutch" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Greek" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Estonian" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Esperanto" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Finnish" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_French" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_German" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Hebrew" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Hungarian" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Icelandic" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_IPA" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Italian" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Kurdish" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Lithuanian" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Macedonian" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Maori" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Norwegian" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Pinyin" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Polish" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Portuguese" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Romanian" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Romanization" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Slovak" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Slovenian" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Spanish" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Serbian" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Serbian_Cyrillic" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Swedish" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Turkish" />
|
||||
</ListViewItem>
|
||||
<ListViewItem>
|
||||
<TextBlock x:Uid="QuickAccent_SelectedLanguage_Welsh" />
|
||||
</ListViewItem>
|
||||
<ListView.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.HeaderTemplate>
|
||||
<DataTemplate x:DataType="Lib:PowerAccentLanguageGroupModel">
|
||||
<Border AutomationProperties.AccessibilityView="Raw">
|
||||
<TextBlock
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
Style="{ThemeResource SubtitleTextBlockStyle}"
|
||||
Text="{x:Bind Group}" />
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</GroupStyle.HeaderTemplate>
|
||||
</GroupStyle>
|
||||
</ListView.GroupStyle>
|
||||
</ListView>
|
||||
</tkcontrols:SettingsCard>
|
||||
</tkcontrols:SettingsExpander.Items>
|
||||
|
@ -31,25 +31,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
|
||||
private void InitializeControlsStates()
|
||||
{
|
||||
SetListViewSelected();
|
||||
SetCheckBoxStatus();
|
||||
}
|
||||
|
||||
private void SetListViewSelected()
|
||||
{
|
||||
foreach (var languageIndex in ViewModel.SelectedLangIndexes)
|
||||
{
|
||||
var item = this.QuickAccent_Language_Select.Items.ElementAtOrDefault(languageIndex);
|
||||
if (item != null)
|
||||
{
|
||||
this.QuickAccent_Language_Select.SelectedItems.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCheckBoxStatus()
|
||||
{
|
||||
if (ViewModel.SelectedLangIndexes.Length == 0)
|
||||
if (ViewModel.SelectedLanguageOptions.Length == 0)
|
||||
{
|
||||
this.QuickAccent_SelectedLanguage_All.IsChecked = false;
|
||||
this.QuickAccent_SelectedLanguage_All.IsThreeState = false;
|
||||
@ -79,10 +66,20 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
private void QuickAccent_SelectedLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var listView = sender as ListView;
|
||||
var indexes = listView.SelectedItems.Select(listView.Items.IndexOf).ToArray();
|
||||
ViewModel.SelectedLangIndexes = indexes;
|
||||
|
||||
ViewModel.SelectedLanguageOptions = listView.SelectedItems
|
||||
.Select(item => item as PowerAccentLanguageModel)
|
||||
.ToArray();
|
||||
|
||||
SetCheckBoxStatus();
|
||||
}
|
||||
|
||||
private void QuickAccent_Language_Select_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
foreach (var languageOption in ViewModel.SelectedLanguageOptions)
|
||||
{
|
||||
this.QuickAccent_Language_Select.SelectedItems.Add(languageOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3540,130 +3540,136 @@ Activate by holding the key for the character you want to add an accent to, then
|
||||
<data name="QuickAccent_SelectedLanguage.Description" xml:space="preserve">
|
||||
<value>Show only accented characters common to the selected set</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_All.Content" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_All.Content" xml:space="preserve">
|
||||
<value>All available</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Special.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_Group_Special" xml:space="preserve">
|
||||
<value>Special sets</value>
|
||||
</data>
|
||||
<data name="QuickAccent_Group_Language" xml:space="preserve">
|
||||
<value>Language sets</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Special" xml:space="preserve">
|
||||
<value>Special Characters</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Bulgarian.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Bulgarian" xml:space="preserve">
|
||||
<value>Bulgarian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Catalan.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Catalan" xml:space="preserve">
|
||||
<value>Catalan</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Crimean.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Crimean" xml:space="preserve">
|
||||
<value>Crimean Tatar</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Currency.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Currency" xml:space="preserve">
|
||||
<value>Currency</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Croatian.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Croatian" xml:space="preserve">
|
||||
<value>Croatian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Czech.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Czech" xml:space="preserve">
|
||||
<value>Czech</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Danish.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Danish" xml:space="preserve">
|
||||
<value>Danish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Gaeilge.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Gaeilge" xml:space="preserve">
|
||||
<value>Gaeilge</value>
|
||||
<comment>Gaelic language spoken in Ireland</comment>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Gaidhlig.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Gaidhlig" xml:space="preserve">
|
||||
<value>Gàidhlig</value>
|
||||
<comment>Scottish Gaelic</comment>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_German.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_German" xml:space="preserve">
|
||||
<value>German</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Greek.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Greek" xml:space="preserve">
|
||||
<value>Greek</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Hebrew.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Hebrew" xml:space="preserve">
|
||||
<value>Hebrew</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_French.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_French" xml:space="preserve">
|
||||
<value>French</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Finnish.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Finnish" xml:space="preserve">
|
||||
<value>Finnish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Estonian.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Estonian" xml:space="preserve">
|
||||
<value>Estonian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Esperanto.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Esperanto" xml:space="preserve">
|
||||
<value>Esperanto</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_IPA.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_IPA" xml:space="preserve">
|
||||
<value>IPA</value>
|
||||
<comment>International Phonetic Alphabet</comment>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Lithuanian.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Lithuanian" xml:space="preserve">
|
||||
<value>Lithuanian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Macedonian.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Macedonian" xml:space="preserve">
|
||||
<value>Macedonian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Maori.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Maori" xml:space="preserve">
|
||||
<value>Maori</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Romanization.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Romanization" xml:space="preserve">
|
||||
<value>Middle Eastern Romanization</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Dutch.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Dutch" xml:space="preserve">
|
||||
<value>Dutch</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Norwegian.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Norwegian" xml:space="preserve">
|
||||
<value>Norwegian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Pinyin.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Pinyin" xml:space="preserve">
|
||||
<value>Pinyin</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Polish.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Polish" xml:space="preserve">
|
||||
<value>Polish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Portuguese.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Portuguese" xml:space="preserve">
|
||||
<value>Portuguese</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Slovak.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Slovak" xml:space="preserve">
|
||||
<value>Slovak</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Slovenian.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Slovenian" xml:space="preserve">
|
||||
<value>Slovenian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Spanish.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Spanish" xml:space="preserve">
|
||||
<value>Spanish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Swedish.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Swedish" xml:space="preserve">
|
||||
<value>Swedish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Turkish.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Turkish" xml:space="preserve">
|
||||
<value>Turkish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Icelandic.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Icelandic" xml:space="preserve">
|
||||
<value>Icelandic</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Romanian.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Romanian" xml:space="preserve">
|
||||
<value>Romanian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Serbian.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Serbian" xml:space="preserve">
|
||||
<value>Serbian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Serbian_Cyrillic.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Serbian_Cyrillic" xml:space="preserve">
|
||||
<value>Serbian Cyrillic</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Hungarian.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Hungarian" xml:space="preserve">
|
||||
<value>Hungarian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Italian.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Italian" xml:space="preserve">
|
||||
<value>Italian</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Kurdish.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Kurdish" xml:space="preserve">
|
||||
<value>Kurdish</value>
|
||||
</data>
|
||||
<data name="QuickAccent_SelectedLanguage_Welsh.Text" xml:space="preserve">
|
||||
<data name="QuickAccent_SelectedLanguage_Welsh" xml:space="preserve">
|
||||
<value>Welsh</value>
|
||||
</data>
|
||||
<data name="Hosts.ModuleDescription" xml:space="preserve">
|
||||
|
@ -3,10 +3,11 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using global::PowerToys.GPOWrapper;
|
||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
||||
@ -22,50 +23,53 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
private readonly ISettingsUtils _settingsUtils;
|
||||
|
||||
// These should be in the same order as the ComboBoxItems in PowerAccentPage.xaml
|
||||
private readonly string[] _languageOptions =
|
||||
{
|
||||
"SPECIAL",
|
||||
"BG",
|
||||
"CA",
|
||||
"CRH",
|
||||
"CUR",
|
||||
"HR",
|
||||
"CZ",
|
||||
"DK",
|
||||
"GA",
|
||||
"GD",
|
||||
"NL",
|
||||
"EL",
|
||||
"EST",
|
||||
"EPO",
|
||||
"FI",
|
||||
"FR",
|
||||
"DE",
|
||||
"HE",
|
||||
"HU",
|
||||
"IS",
|
||||
"IPA",
|
||||
"IT",
|
||||
"KU",
|
||||
"LT",
|
||||
"MK",
|
||||
"MI",
|
||||
"NO",
|
||||
"PI",
|
||||
"PL",
|
||||
"PT",
|
||||
"RO",
|
||||
"ROM",
|
||||
"SK",
|
||||
"SL",
|
||||
"SP",
|
||||
"SR",
|
||||
"SR_CYRL",
|
||||
"SV",
|
||||
"TK",
|
||||
"CY",
|
||||
};
|
||||
private const string SpecialGroup = "QuickAccent_Group_Special";
|
||||
private const string LanguageGroup = "QuickAccent_Group_Language";
|
||||
|
||||
public List<PowerAccentLanguageModel> Languages { get; } = [
|
||||
new PowerAccentLanguageModel("SPECIAL", "QuickAccent_SelectedLanguage_Special", SpecialGroup),
|
||||
new PowerAccentLanguageModel("BG", "QuickAccent_SelectedLanguage_Bulgarian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("CA", "QuickAccent_SelectedLanguage_Catalan", LanguageGroup),
|
||||
new PowerAccentLanguageModel("CRH", "QuickAccent_SelectedLanguage_Crimean", LanguageGroup),
|
||||
new PowerAccentLanguageModel("CUR", "QuickAccent_SelectedLanguage_Currency", SpecialGroup),
|
||||
new PowerAccentLanguageModel("HR", "QuickAccent_SelectedLanguage_Croatian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("CZ", "QuickAccent_SelectedLanguage_Czech", LanguageGroup),
|
||||
new PowerAccentLanguageModel("DK", "QuickAccent_SelectedLanguage_Danish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("GA", "QuickAccent_SelectedLanguage_Gaeilge", LanguageGroup),
|
||||
new PowerAccentLanguageModel("GD", "QuickAccent_SelectedLanguage_Gaidhlig", LanguageGroup),
|
||||
new PowerAccentLanguageModel("NL", "QuickAccent_SelectedLanguage_Dutch", LanguageGroup),
|
||||
new PowerAccentLanguageModel("EL", "QuickAccent_SelectedLanguage_Greek", LanguageGroup),
|
||||
new PowerAccentLanguageModel("EST", "QuickAccent_SelectedLanguage_Estonian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("EPO", "QuickAccent_SelectedLanguage_Esperanto", LanguageGroup),
|
||||
new PowerAccentLanguageModel("FI", "QuickAccent_SelectedLanguage_Finnish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("FR", "QuickAccent_SelectedLanguage_French", LanguageGroup),
|
||||
new PowerAccentLanguageModel("DE", "QuickAccent_SelectedLanguage_German", LanguageGroup),
|
||||
new PowerAccentLanguageModel("HE", "QuickAccent_SelectedLanguage_Hebrew", LanguageGroup),
|
||||
new PowerAccentLanguageModel("HU", "QuickAccent_SelectedLanguage_Hungarian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("IS", "QuickAccent_SelectedLanguage_Icelandic", LanguageGroup),
|
||||
new PowerAccentLanguageModel("IPA", "QuickAccent_SelectedLanguage_IPA", SpecialGroup),
|
||||
new PowerAccentLanguageModel("IT", "QuickAccent_SelectedLanguage_Italian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("KU", "QuickAccent_SelectedLanguage_Kurdish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("LT", "QuickAccent_SelectedLanguage_Lithuanian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("MK", "QuickAccent_SelectedLanguage_Macedonian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("MI", "QuickAccent_SelectedLanguage_Maori", LanguageGroup),
|
||||
new PowerAccentLanguageModel("NO", "QuickAccent_SelectedLanguage_Norwegian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("PI", "QuickAccent_SelectedLanguage_Pinyin", LanguageGroup),
|
||||
new PowerAccentLanguageModel("PL", "QuickAccent_SelectedLanguage_Polish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("PT", "QuickAccent_SelectedLanguage_Portuguese", LanguageGroup),
|
||||
new PowerAccentLanguageModel("RO", "QuickAccent_SelectedLanguage_Romanian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("ROM", "QuickAccent_SelectedLanguage_Romanization", SpecialGroup),
|
||||
new PowerAccentLanguageModel("SK", "QuickAccent_SelectedLanguage_Slovak", LanguageGroup),
|
||||
new PowerAccentLanguageModel("SL", "QuickAccent_SelectedLanguage_Slovenian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("SP", "QuickAccent_SelectedLanguage_Spanish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("SR", "QuickAccent_SelectedLanguage_Serbian", LanguageGroup),
|
||||
new PowerAccentLanguageModel("SR_CYRL", "QuickAccent_SelectedLanguage_Serbian_Cyrillic", LanguageGroup),
|
||||
new PowerAccentLanguageModel("SV", "QuickAccent_SelectedLanguage_Swedish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("TK", "QuickAccent_SelectedLanguage_Turkish", LanguageGroup),
|
||||
new PowerAccentLanguageModel("CY", "QuickAccent_SelectedLanguage_Welsh", LanguageGroup),
|
||||
];
|
||||
|
||||
public PowerAccentLanguageGroupModel[] LanguageGroups { get; private set; }
|
||||
|
||||
private readonly string[] _toolbarOptions =
|
||||
{
|
||||
@ -91,6 +95,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
GeneralSettingsConfig = settingsRepository.SettingsConfig;
|
||||
|
||||
InitializeEnabledValue();
|
||||
InitializeLanguages();
|
||||
|
||||
if (_settingsUtils.SettingsExists(PowerAccentSettings.ModuleName))
|
||||
{
|
||||
@ -107,11 +112,17 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_powerAccentSettings.Properties.SelectedLang.Value) && !_powerAccentSettings.Properties.SelectedLang.Value.Contains("ALL"))
|
||||
{
|
||||
SelectedLangIndexes = _powerAccentSettings.Properties.SelectedLang.Value.Split(',').Select(l => Array.IndexOf(_languageOptions, l)).ToArray();
|
||||
SelectedLanguageOptions = _powerAccentSettings.Properties.SelectedLang.Value.Split(',')
|
||||
.Select(l => Languages.Find(lang => lang.LanguageCode == l))
|
||||
.ToArray();
|
||||
}
|
||||
else if (_powerAccentSettings.Properties.SelectedLang.Value.Contains("ALL"))
|
||||
{
|
||||
SelectedLanguageOptions = Languages.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedLangIndexes = Enumerable.Range(0, _languageOptions.Length).ToArray();
|
||||
SelectedLanguageOptions = Array.Empty<PowerAccentLanguageModel>();
|
||||
}
|
||||
|
||||
_toolbarPositionIndex = Array.IndexOf(_toolbarOptions, _powerAccentSettings.Properties.ToolbarPosition.Value);
|
||||
@ -135,6 +146,23 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds Localized Language Name, sorts by it and splits languages into two groups.
|
||||
/// </summary>
|
||||
private void InitializeLanguages()
|
||||
{
|
||||
foreach (var item in Languages)
|
||||
{
|
||||
item.Language = ResourceLoaderInstance.ResourceLoader.GetString(item.LanguageResourceID);
|
||||
}
|
||||
|
||||
Languages.Sort((x, y) => string.Compare(x.Language, y.Language, StringComparison.Ordinal));
|
||||
LanguageGroups = Languages
|
||||
.GroupBy(language => language.GroupResourceID)
|
||||
.Select(grp => new PowerAccentLanguageGroupModel(grp.ToList(), ResourceLoaderInstance.ResourceLoader.GetString(grp.Key)))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
@ -261,27 +289,18 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool AllSelected => _selectedLanguages.Length == _languageOptions.Length;
|
||||
public bool AllSelected => _selectedLanguageOptions.Length == Languages.Count;
|
||||
|
||||
private string[] _selectedLanguages;
|
||||
private PowerAccentLanguageModel[] _selectedLanguageOptions;
|
||||
|
||||
private int[] _selectedLangIndexes;
|
||||
|
||||
public int[] SelectedLangIndexes
|
||||
public PowerAccentLanguageModel[] SelectedLanguageOptions
|
||||
{
|
||||
get => _selectedLangIndexes;
|
||||
get => _selectedLanguageOptions;
|
||||
set
|
||||
{
|
||||
if (_selectedLangIndexes == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_selectedLangIndexes = value;
|
||||
_selectedLanguages = _selectedLangIndexes.Select(s => _languageOptions[s]).ToArray();
|
||||
|
||||
_powerAccentSettings.Properties.SelectedLang.Value = string.Join(',', _selectedLanguages);
|
||||
RaisePropertyChanged(nameof(SelectedLangIndexes));
|
||||
_selectedLanguageOptions = value;
|
||||
_powerAccentSettings.Properties.SelectedLang.Value = string.Join(',', _selectedLanguageOptions.Select(l => l.LanguageCode));
|
||||
RaisePropertyChanged(nameof(SelectedLanguageOptions));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user