Add missing functionality to SUI (#8786)

<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? -->
## Summary of the Pull Request
Add checkbox for 'inherit from parent process' for starting directory
When checked, the textbox and browse button are disabled
If the starting directory is empty, the checkbox is automatically checked

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #8761 
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] Schema updated.
* [x] I work here

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
<img width="328" alt="pardir1" src="https://user-images.githubusercontent.com/26824113/104529798-64038980-55bf-11eb-93fd-75e6cf1e2547.png">
<img width="317" alt="pardir2" src="https://user-images.githubusercontent.com/26824113/104529803-66fe7a00-55bf-11eb-89b6-5b35c8ab89b8.png">
This commit is contained in:
PankajBhojwani 2021-01-14 11:06:10 -08:00 committed by GitHub
parent e0f585251a
commit 9905bd5f09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 3 deletions

View file

@ -114,6 +114,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
disclaimer = RS_(L"Profile_DeleteButtonDisclaimerDynamic");
}
DeleteButtonDisclaimer().Text(disclaimer);
// Check the use parent directory box if the starting directory is empty
if (_State.Profile().StartingDirectory().empty())
{
StartingDirectoryUseParentCheckbox().IsChecked(true);
}
}
ColorScheme Profiles::CurrentColorScheme()
@ -142,6 +148,23 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
state->DeleteProfile();
}
void Profiles::UseParentProcessDirectory_Check(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
{
auto state{ winrt::get_self<ProfilePageNavigationState>(_State) };
state->Profile().StartingDirectory(L"");
// Disable the text box and browse button
StartingDirectory().IsEnabled(false);
StartingDirectoryBrowse().IsEnabled(false);
}
void Profiles::UseParentProcessDirectory_Uncheck(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
{
// Enable the text box and browse button
StartingDirectory().IsEnabled(true);
StartingDirectoryBrowse().IsEnabled(true);
}
fire_and_forget Profiles::BackgroundImage_Click(IInspectable const&, RoutedEventArgs const&)
{
auto lifetime = get_strong();

View file

@ -116,6 +116,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
fire_and_forget Icon_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);
void BIAlignment_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);
void DeleteConfirmation_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);
void UseParentProcessDirectory_Check(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);
void UseParentProcessDirectory_Uncheck(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);
// CursorShape visibility logic
void CursorShape_Changed(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);

View file

@ -69,14 +69,22 @@ the MIT License. See LICENSE in the project root for license information. -->
<!--Starting Directory-->
<ContentPresenter Style="{StaticResource SettingContainerStyle}">
<StackPanel Orientation="Horizontal">
<TextBox x:Uid="Profile_StartingDirectory"
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBox x:Uid="Profile_StartingDirectory"
x:Name="StartingDirectory"
Text="{x:Bind State.Profile.StartingDirectory, Mode=TwoWay}"
Style="{StaticResource TextBoxSettingStyle}"/>
<Button x:Uid="Profile_StartingDirectoryBrowse"
<Button x:Uid="Profile_StartingDirectoryBrowse"
x:Name="StartingDirectoryBrowse"
Click="StartingDirectory_Click"
Style="{StaticResource BrowseButtonStyle}"/>
</StackPanel>
<CheckBox x:Uid="Profile_StartingDirectoryUseParentCheckbox"
x:Name="StartingDirectoryUseParentCheckbox"
Style="{StaticResource CheckBoxSettingStyle}"
Checked="UseParentProcessDirectory_Check"
Unchecked="UseParentProcessDirectory_Uncheck"/>
</StackPanel>
</ContentPresenter>

View file

@ -603,6 +603,12 @@
<data name="Profile_StartingDirectoryBrowse.Content" xml:space="preserve">
<value>Browse...</value>
</data>
<data name="Profile_StartingDirectoryUseParentCheckbox.Content" xml:space="preserve">
<value>Use parent process directory</value>
</data>
<data name="Profile_StartingDirectoryUseParentCheckbox.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
<value>If checked, this profile will spawn in the directory from which Windows Terminal was launched.</value>
</data>
<data name="Profile_SuppressApplicationTitle.Content" xml:space="preserve">
<value>Suppress title changes</value>
</data>