Skip to content

Commit 7359df0

Browse files
Fix remaining settings container previews in SUI (#18888)
Went through the settings UI and checked which other setting containers were missing a preview. Here's the list: - starting directory - tab title - background image - answerback message - bell style Adding them was fairly straightforward. Tried to reuse existing resources when possible. The general pattern was to add a "Current<Setting>" or "<Setting>Preview" getter that just created the human-readable format of the setting. ## Validation Steps Performed ✅ value is shown (including special values!) ✅ each of these work with a screen reader Closes #18576
1 parent 07c9a99 commit 7359df0

File tree

11 files changed

+116
-26
lines changed

11 files changed

+116
-26
lines changed

src/cascadia/TerminalSettingsEditor/Appearances.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
219219
// into the path TextBox, we properly update the checkbox and stored
220220
// _lastBgImagePath. Without this, then we'll permanently hide the text
221221
// box, prevent it from ever being changed again.
222-
_NotifyChanges(L"UseDesktopBGImage", L"BackgroundImageSettingsVisible");
222+
_NotifyChanges(L"UseDesktopBGImage", L"BackgroundImageSettingsVisible", L"CurrentBackgroundImagePath");
223223
}
224224
else if (viewModelProperty == L"BackgroundImageAlignment")
225225
{
@@ -954,7 +954,21 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
954954
return GetLibraryResourceString(alignmentResourceKey);
955955
}
956956

957-
bool AppearanceViewModel::UseDesktopBGImage()
957+
hstring AppearanceViewModel::CurrentBackgroundImagePath() const
958+
{
959+
const auto bgImagePath = BackgroundImagePath();
960+
if (bgImagePath.empty())
961+
{
962+
return RS_(L"Appearance_BackgroundImageNone");
963+
}
964+
else if (bgImagePath == L"desktopWallpaper")
965+
{
966+
return RS_(L"Profile_UseDesktopImage/Content");
967+
}
968+
return bgImagePath;
969+
}
970+
971+
bool AppearanceViewModel::UseDesktopBGImage() const
958972
{
959973
return BackgroundImagePath() == L"desktopWallpaper";
960974
}
@@ -983,7 +997,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
983997
}
984998
}
985999

986-
bool AppearanceViewModel::BackgroundImageSettingsVisible()
1000+
bool AppearanceViewModel::BackgroundImageSettingsVisible() const
9871001
{
9881002
return !BackgroundImagePath().empty();
9891003
}

src/cascadia/TerminalSettingsEditor/Appearances.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
120120
void UpdateFontSetting(const FontKeyValuePair* kv);
121121

122122
// background image
123-
bool UseDesktopBGImage();
123+
hstring CurrentBackgroundImagePath() const;
124+
bool UseDesktopBGImage() const;
124125
void UseDesktopBGImage(const bool useDesktop);
125-
bool BackgroundImageSettingsVisible();
126+
bool BackgroundImageSettingsVisible() const;
126127
void SetBackgroundImageOpacityFromPercentageValue(double percentageValue);
127128
void SetBackgroundImagePath(winrt::hstring path);
128129
hstring BackgroundImageAlignmentCurrentValue() const;

src/cascadia/TerminalSettingsEditor/Appearances.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace Microsoft.Terminal.Settings.Editor
3838
void SetBackgroundImageOpacityFromPercentageValue(Double percentageValue);
3939
void SetBackgroundImagePath(String path);
4040

41+
String CurrentBackgroundImagePath { get; };
4142
Boolean UseDesktopBGImage;
4243
Boolean BackgroundImageSettingsVisible { get; };
4344
String BackgroundImageAlignmentCurrentValue { get; };

src/cascadia/TerminalSettingsEditor/Appearances.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,21 +533,21 @@
533533
<local:SettingContainer x:Name="BackgroundImageContainer"
534534
x:Uid="Profile_BackgroundImage"
535535
ClearSettingValue="{x:Bind Appearance.ClearBackgroundImagePath}"
536-
CurrentValue="{x:Bind Appearance.BackgroundImagePath, Mode=OneWay}"
536+
CurrentValue="{x:Bind Appearance.CurrentBackgroundImagePath, Mode=OneWay}"
537537
HasSettingValue="{x:Bind Appearance.HasBackgroundImagePath, Mode=OneWay}"
538538
SettingOverrideSource="{x:Bind Appearance.BackgroundImagePathOverrideSource, Mode=OneWay}"
539539
Style="{StaticResource ExpanderSettingContainerStyle}">
540540
<StackPanel Orientation="Vertical">
541541
<TextBox x:Uid="Profile_BackgroundImageBox"
542-
IsEnabled="{x:Bind mtu:Converters.StringsAreNotEqual('desktopWallpaper', Appearance.BackgroundImagePath), Mode=OneWay}"
542+
IsEnabled="{x:Bind mtu:Converters.InvertBoolean(Appearance.UseDesktopBGImage), Mode=OneWay}"
543543
IsSpellCheckEnabled="False"
544544
Style="{StaticResource TextBoxSettingStyle}"
545545
Text="{x:Bind mtu:Converters.StringOrEmptyIfPlaceholder('desktopWallpaper', Appearance.BackgroundImagePath), Mode=TwoWay, BindBack=Appearance.SetBackgroundImagePath}" />
546546
<StackPanel Orientation="Horizontal">
547547
<Button x:Uid="Profile_BackgroundImageBrowse"
548548
Margin="0,10,10,0"
549549
Click="BackgroundImage_Click"
550-
IsEnabled="{x:Bind mtu:Converters.StringsAreNotEqual('desktopWallpaper', Appearance.BackgroundImagePath), Mode=OneWay}"
550+
IsEnabled="{x:Bind mtu:Converters.InvertBoolean(Appearance.UseDesktopBGImage), Mode=OneWay}"
551551
Style="{StaticResource BrowseButtonStyle}" />
552552
<CheckBox x:Name="UseDesktopImageCheckBox"
553553
x:Uid="Profile_UseDesktopImage"

src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
7171
{
7272
// notify listener that all starting directory related values might have changed
7373
// NOTE: this is similar to what is done with BackgroundImagePath above
74-
_NotifyChanges(L"UseParentProcessDirectory", L"UseCustomStartingDirectory");
74+
_NotifyChanges(L"UseParentProcessDirectory", L"CurrentStartingDirectoryPreview");
7575
}
7676
else if (viewModelProperty == L"AntialiasingMode")
7777
{
@@ -83,7 +83,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
8383
}
8484
else if (viewModelProperty == L"BellStyle")
8585
{
86-
_NotifyChanges(L"IsBellStyleFlagSet");
86+
_NotifyChanges(L"IsBellStyleFlagSet", L"BellStylePreview");
8787
}
8888
else if (viewModelProperty == L"ScrollState")
8989
{
@@ -139,6 +139,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
139139
_parsedPadding = StringToXamlThickness(_profile.Padding());
140140
_NotifyChanges(L"LeftPadding", L"TopPadding", L"RightPadding", L"BottomPadding");
141141
}
142+
else if (viewModelProperty == L"TabTitle")
143+
{
144+
_NotifyChanges(L"TabTitlePreview");
145+
}
146+
else if (viewModelProperty == L"AnswerbackMessage")
147+
{
148+
_NotifyChanges(L"AnswerbackMessagePreview");
149+
}
142150
});
143151

144152
// Do the same for the starting directory
@@ -413,6 +421,15 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
413421
return RS_(L"Profile_TabTitleNone");
414422
}
415423

424+
hstring ProfileViewModel::AnswerbackMessagePreview() const
425+
{
426+
if (const auto answerbackMessage{ AnswerbackMessage() }; !answerbackMessage.empty())
427+
{
428+
return answerbackMessage;
429+
}
430+
return RS_(L"Profile_AnswerbackMessageNone");
431+
}
432+
416433
Editor::AppearanceViewModel ProfileViewModel::DefaultAppearance()
417434
{
418435
return _defaultAppearanceViewModel;
@@ -470,18 +487,18 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
470487
return Feature_ScrollbarMarks::IsEnabled();
471488
}
472489

473-
bool ProfileViewModel::UseParentProcessDirectory()
490+
hstring ProfileViewModel::CurrentStartingDirectoryPreview() const
474491
{
475-
return StartingDirectory().empty();
492+
if (UseParentProcessDirectory())
493+
{
494+
return RS_(L"Profile_StartingDirectoryUseParentCheckbox/Content");
495+
}
496+
return StartingDirectory();
476497
}
477498

478-
// This function simply returns the opposite of UseParentProcessDirectory.
479-
// We bind the 'IsEnabled' parameters of the textbox and browse button
480-
// to this because it needs to be the reverse of UseParentProcessDirectory
481-
// but we don't want to create a whole new converter for inverting a boolean
482-
bool ProfileViewModel::UseCustomStartingDirectory()
499+
bool ProfileViewModel::UseParentProcessDirectory() const
483500
{
484-
return !UseParentProcessDirectory();
501+
return StartingDirectory().empty();
485502
}
486503

487504
void ProfileViewModel::UseParentProcessDirectory(const bool useParent)
@@ -613,6 +630,49 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
613630
return _currentIconType == _IconTypes.GetAt(3);
614631
}
615632

633+
hstring ProfileViewModel::BellStylePreview() const
634+
{
635+
const auto bellStyle = BellStyle();
636+
if (WI_AreAllFlagsSet(bellStyle, BellStyle::Audible | BellStyle::Window | BellStyle::Taskbar))
637+
{
638+
return RS_(L"Profile_BellStyleAll/Content");
639+
}
640+
else if (bellStyle == static_cast<Model::BellStyle>(0))
641+
{
642+
return RS_(L"Profile_BellStyleNone/Content");
643+
}
644+
645+
std::vector<hstring> resultList;
646+
resultList.reserve(3);
647+
if (WI_IsFlagSet(bellStyle, BellStyle::Audible))
648+
{
649+
resultList.emplace_back(RS_(L"Profile_BellStyleAudible/Content"));
650+
}
651+
if (WI_IsFlagSet(bellStyle, BellStyle::Window))
652+
{
653+
resultList.emplace_back(RS_(L"Profile_BellStyleWindow/Content"));
654+
}
655+
if (WI_IsFlagSet(bellStyle, BellStyle::Taskbar))
656+
{
657+
resultList.emplace_back(RS_(L"Profile_BellStyleTaskbar/Content"));
658+
}
659+
660+
// add in the commas
661+
hstring result{};
662+
for (auto&& entry : resultList)
663+
{
664+
if (result.empty())
665+
{
666+
result = entry;
667+
}
668+
else
669+
{
670+
result = result + L", " + entry;
671+
}
672+
}
673+
return result;
674+
}
675+
616676
bool ProfileViewModel::IsBellStyleFlagSet(const uint32_t flag)
617677
{
618678
return (WI_EnumValue(BellStyle()) & flag) == flag;

src/cascadia/TerminalSettingsEditor/ProfileViewModel.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
5555
void SetupAppearances(Windows::Foundation::Collections::IObservableVector<Editor::ColorSchemeViewModel> schemesList);
5656

5757
// bell style bits
58+
hstring BellStylePreview() const;
5859
bool IsBellStyleFlagSet(const uint32_t flag);
5960
void SetBellStyleAudible(winrt::Windows::Foundation::IReference<bool> on);
6061
void SetBellStyleWindow(winrt::Windows::Foundation::IReference<bool> on);
@@ -95,9 +96,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
9596
bool UsingImageIcon() const;
9697

9798
// starting directory
98-
bool UseParentProcessDirectory();
99+
hstring CurrentStartingDirectoryPreview() const;
100+
bool UseParentProcessDirectory() const;
99101
void UseParentProcessDirectory(const bool useParent);
100-
bool UseCustomStartingDirectory();
101102

102103
// general profile knowledge
103104
winrt::guid OriginalProfileGuid() const noexcept;
@@ -116,6 +117,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
116117

117118
bool Orphaned() const;
118119
hstring TabTitlePreview() const;
120+
hstring AnswerbackMessagePreview() const;
119121

120122
til::typed_event<Editor::ProfileViewModel, Editor::DeleteProfileEventArgs> DeleteProfileRequested;
121123

src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ namespace Microsoft.Terminal.Settings.Editor
6060

6161
void SetAcrylicOpacityPercentageValue(Double value);
6262

63+
String BellStylePreview { get; };
6364
Boolean IsBellStyleFlagSet(UInt32 flag);
6465
void SetBellStyleAudible(Windows.Foundation.IReference<Boolean> on);
6566
void SetBellStyleWindow(Windows.Foundation.IReference<Boolean> on);
@@ -87,12 +88,13 @@ namespace Microsoft.Terminal.Settings.Editor
8788
IInspectable CurrentPathTranslationStyle;
8889
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> PathTranslationStyleList { get; };
8990

91+
String CurrentStartingDirectoryPreview { get; };
92+
Boolean UseParentProcessDirectory;
93+
9094
Boolean CanDeleteProfile { get; };
9195
Boolean FocusDeleteButton;
9296
Boolean IsBaseLayer;
9397
ProfileSubPage CurrentPage;
94-
Boolean UseParentProcessDirectory;
95-
Boolean UseCustomStartingDirectory { get; };
9698
AppearanceViewModel DefaultAppearance { get; };
9799
Guid OriginalProfileGuid { get; };
98100
Boolean HasUnfocusedAppearance { get; };
@@ -119,6 +121,7 @@ namespace Microsoft.Terminal.Settings.Editor
119121
Windows.Foundation.Collections.IVector<IInspectable> BuiltInIcons { get; };
120122

121123
String TabTitlePreview { get; };
124+
String AnswerbackMessagePreview { get; };
122125

123126
void CreateUnfocusedAppearance();
124127
void DeleteUnfocusedAppearance();

src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
<!-- Bell Style -->
9797
<local:SettingContainer x:Uid="Profile_BellStyle"
9898
ClearSettingValue="{x:Bind Profile.ClearBellStyle}"
99+
CurrentValue="{x:Bind Profile.BellStylePreview, Mode=OneWay}"
99100
HasSettingValue="{x:Bind Profile.HasBellStyle, Mode=OneWay}"
100101
SettingOverrideSource="{x:Bind Profile.BellStyleOverrideSource, Mode=OneWay}"
101102
Style="{StaticResource ExpanderSettingContainerStyle}">

src/cascadia/TerminalSettingsEditor/Profiles_Base.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@
7474
<local:SettingContainer x:Name="StartingDirectoryContainer"
7575
x:Uid="Profile_StartingDirectory"
7676
ClearSettingValue="{x:Bind Profile.ClearStartingDirectory}"
77-
CurrentValue="{x:Bind Profile.StartingDirectory, Mode=OneWay}"
77+
CurrentValue="{x:Bind Profile.CurrentStartingDirectoryPreview, Mode=OneWay}"
7878
HasSettingValue="{x:Bind Profile.HasStartingDirectory, Mode=OneWay}"
7979
SettingOverrideSource="{x:Bind Profile.StartingDirectoryOverrideSource, Mode=OneWay}"
8080
Style="{StaticResource ExpanderSettingContainerStyle}">
8181
<StackPanel Orientation="Vertical">
8282
<TextBox x:Uid="Profile_StartingDirectoryBox"
83-
IsEnabled="{x:Bind Profile.UseCustomStartingDirectory, Mode=OneWay}"
83+
IsEnabled="{x:Bind mtu:Converters.InvertBoolean(Profile.UseParentProcessDirectory), Mode=OneWay}"
8484
IsSpellCheckEnabled="False"
8585
Style="{StaticResource TextBoxSettingStyle}"
8686
Text="{x:Bind Profile.StartingDirectory, Mode=TwoWay}" />
@@ -89,7 +89,7 @@
8989
x:Uid="Profile_StartingDirectoryBrowse"
9090
Margin="0,10,10,0"
9191
Click="StartingDirectory_Click"
92-
IsEnabled="{x:Bind Profile.UseCustomStartingDirectory, Mode=OneWay}"
92+
IsEnabled="{x:Bind mtu:Converters.InvertBoolean(Profile.UseParentProcessDirectory), Mode=OneWay}"
9393
Style="{StaticResource BrowseButtonStyle}" />
9494
<CheckBox x:Name="StartingDirectoryUseParentCheckbox"
9595
x:Uid="Profile_StartingDirectoryUseParentCheckbox"

src/cascadia/TerminalSettingsEditor/Profiles_Terminal.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<!-- Answerback Message -->
7373
<local:SettingContainer x:Uid="Profile_AnswerbackMessage"
7474
ClearSettingValue="{x:Bind Profile.ClearAnswerbackMessage}"
75-
CurrentValue="{x:Bind Profile.AnswerbackMessage, Mode=OneWay}"
75+
CurrentValue="{x:Bind Profile.AnswerbackMessagePreview, Mode=OneWay}"
7676
HasSettingValue="{x:Bind Profile.HasAnswerbackMessage, Mode=OneWay}"
7777
SettingOverrideSource="{x:Bind Profile.AnswerbackMessageOverrideSource, Mode=OneWay}"
7878
Style="{StaticResource ExpanderSettingContainerStyle}">

src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,4 +2344,12 @@
23442344
<value>This option is managed by enterprise policy and cannot be changed here.</value>
23452345
<comment>This is displayed in concordance with Globals_StartOnUserLogin if the enterprise administrator has taken control of this setting.</comment>
23462346
</data>
2347+
<data name="Appearance_BackgroundImageNone" xml:space="preserve">
2348+
<value>None</value>
2349+
<comment>Text displayed when the background image path is not defined.</comment>
2350+
</data>
2351+
<data name="Profile_AnswerbackMessageNone" xml:space="preserve">
2352+
<value>None</value>
2353+
<comment>Text displayed when the answerback message is not defined.</comment>
2354+
</data>
23472355
</root>

0 commit comments

Comments
 (0)