From 62b0ab362266e3faccb72a4b997c69e71ed10268 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 18 Jan 2023 17:40:02 -0800 Subject: [PATCH] set automation name manually --- .../TerminalSettingsEditor/ColorSchemes.cpp | 15 +++++++++++++++ .../TerminalSettingsEditor/ColorSchemes.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp b/src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp index 86bc0f20ef1..80a83607cef 100644 --- a/src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp +++ b/src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp @@ -37,6 +37,21 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { _ViewModel = e.Parameter().as(); _ViewModel.CurrentPage(ColorSchemesSubPage::Base); + + _layoutUpdatedRevoker = LayoutUpdated(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) { + // Only let this succeed once. + _layoutUpdatedRevoker.revoke(); + + for (const auto scheme : _ViewModel.AllColorSchemes()) + { + if (scheme.IsDefaultScheme()) + { + winrt::hstring newName{ fmt::format(L"{} ({})", scheme.Name(), RS_(L"ColorScheme_DefaultTag/Text")) }; + Automation::AutomationProperties::SetName(ColorSchemeListView().ContainerFromItem(scheme), newName); + break; + } + } + }); } void ColorSchemes::AddNew_Click(const IInspectable& /*sender*/, const RoutedEventArgs& /*e*/) diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemes.h b/src/cascadia/TerminalSettingsEditor/ColorSchemes.h index e46bf19dfb8..63f755a6b26 100644 --- a/src/cascadia/TerminalSettingsEditor/ColorSchemes.h +++ b/src/cascadia/TerminalSettingsEditor/ColorSchemes.h @@ -13,6 +13,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { struct ColorSchemes : public HasScrollViewer, ColorSchemesT { + public: ColorSchemes(); void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e); @@ -25,6 +26,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation WINRT_OBSERVABLE_PROPERTY(Editor::ColorSchemesPageViewModel, ViewModel, _PropertyChangedHandlers, nullptr); WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler); + + private: + winrt::Windows::UI::Xaml::FrameworkElement::LayoutUpdated_revoker _layoutUpdatedRevoker; }; }