[Settings UI] Allow renaming a profile (#8837)
This adds a "Name" text box to the Profile page in the Settings UI. Any changes to the name/icon are propagated to the relevant NavigationViewItem. Base Layer does not have a "Name". ## References #6800 - Settings UI Epic
This commit is contained in:
parent
9700598ecb
commit
d45cc4c2e1
|
@ -357,6 +357,25 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
icon.IconSource(iconSource);
|
||||
profileNavItem.Icon(icon);
|
||||
|
||||
// Update the menu item when the icon/name changes
|
||||
auto weakMenuItem{ make_weak(profileNavItem) };
|
||||
profile.PropertyChanged([weakMenuItem](const auto&, const WUX::Data::PropertyChangedEventArgs& args) {
|
||||
if (auto menuItem{ weakMenuItem.get() })
|
||||
{
|
||||
const auto& tag{ menuItem.Tag().as<Editor::ProfileViewModel>() };
|
||||
if (args.PropertyName() == L"Icon")
|
||||
{
|
||||
const auto iconSource{ IconPathConverter::IconSourceWUX(tag.Icon()) };
|
||||
WUX::Controls::IconSourceElement icon;
|
||||
icon.IconSource(iconSource);
|
||||
menuItem.Icon(icon);
|
||||
}
|
||||
else if (args.PropertyName() == L"Name")
|
||||
{
|
||||
menuItem.Content(box_value(tag.Name()));
|
||||
}
|
||||
}
|
||||
});
|
||||
return profileNavItem;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,16 @@ the MIT License. See LICENSE in the project root for license information. -->
|
|||
<PivotItem x:Uid="Profile_General">
|
||||
<ScrollViewer>
|
||||
<StackPanel Style="{StaticResource PivotStackStyle}">
|
||||
|
||||
<!--Name-->
|
||||
<ContentPresenter Visibility="{x:Bind State.Profile.IsBaseLayer, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}"
|
||||
Style="{StaticResource SettingContainerStyle}"
|
||||
Margin="0,0,0,24">
|
||||
<TextBox x:Uid="Profile_Name"
|
||||
Text="{x:Bind State.Profile.Name, Mode=TwoWay}"
|
||||
Style="{StaticResource TextBoxSettingStyle}"/>
|
||||
</ContentPresenter>
|
||||
|
||||
<!--Commandline-->
|
||||
<ContentPresenter Visibility="{x:Bind State.Profile.IsBaseLayer, Mode=OneWay, Converter={StaticResource InvertedBooleanToVisibilityConverter}}"
|
||||
Style="{StaticResource SettingContainerStyle}"
|
||||
|
|
Loading…
Reference in a new issue