[QuickAccent]Fix unstable language loading (#36721)
This commit is contained in:
Родитель
df48a33bb9
Коммит
4951a63352
|
@ -63,8 +63,15 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||||
this.QuickAccent_Language_Select.DeselectAll();
|
this.QuickAccent_Language_Select.DeselectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool loadingLanguageListDontTriggerSelectionChanged;
|
||||||
|
|
||||||
private void QuickAccent_SelectedLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void QuickAccent_SelectedLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (loadingLanguageListDontTriggerSelectionChanged)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var listView = sender as ListView;
|
var listView = sender as ListView;
|
||||||
|
|
||||||
ViewModel.SelectedLanguageOptions = listView.SelectedItems
|
ViewModel.SelectedLanguageOptions = listView.SelectedItems
|
||||||
|
@ -76,10 +83,13 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||||
|
|
||||||
private void QuickAccent_Language_Select_Loaded(object sender, RoutedEventArgs e)
|
private void QuickAccent_Language_Select_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
loadingLanguageListDontTriggerSelectionChanged = true;
|
||||||
foreach (var languageOption in ViewModel.SelectedLanguageOptions)
|
foreach (var languageOption in ViewModel.SelectedLanguageOptions)
|
||||||
{
|
{
|
||||||
this.QuickAccent_Language_Select.SelectedItems.Add(languageOption);
|
this.QuickAccent_Language_Select.SelectedItems.Add(languageOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadingLanguageListDontTriggerSelectionChanged = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||||
{
|
{
|
||||||
SelectedLanguageOptions = _powerAccentSettings.Properties.SelectedLang.Value.Split(',')
|
SelectedLanguageOptions = _powerAccentSettings.Properties.SelectedLang.Value.Split(',')
|
||||||
.Select(l => Languages.Find(lang => lang.LanguageCode == l))
|
.Select(l => Languages.Find(lang => lang.LanguageCode == l))
|
||||||
|
.Where(l => l != null) // Wrongly typed languages will appear as null after find. We want to remove those to avoid crashes.
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
else if (_powerAccentSettings.Properties.SelectedLang.Value.Contains("ALL"))
|
else if (_powerAccentSettings.Properties.SelectedLang.Value.Contains("ALL"))
|
||||||
|
|
Загрузка…
Ссылка в новой задаче