-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a new page for "Add new profile" in the SUI #9352
Merged
Merged
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
3402193
initial
PankajBhojwani 7d94b5e
add new works
PankajBhojwani ff4971c
events
PankajBhojwani 0fc1578
duplicate button
PankajBhojwani b3adf6b
works now
PankajBhojwani e4d1a02
okay now it works
PankajBhojwani c472b60
addressing comments
PankajBhojwani 2b23b94
conflict
PankajBhojwani 4326dd8
abstract, localize
PankajBhojwani 9d9a733
nits
PankajBhojwani 981dfdc
address comments
PankajBhojwani 44dbab6
test
PankajBhojwani 6e7f158
throw if null
PankajBhojwani b91af0c
nits, dynamic profile test
PankajBhojwani c4b165c
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani 0cd2739
dynamic
PankajBhojwani 962fa05
line
PankajBhojwani 5ed77c6
format
PankajBhojwani cd9373f
user defaults tag
PankajBhojwani 6cc15fb
format
PankajBhojwani 109e347
automation property, nits
PankajBhojwani 7e5cd28
spaces
PankajBhojwani ad73ab6
comment
PankajBhojwani 2b0416c
format
PankajBhojwani 7a57a99
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani d24b425
appearance setting macro
PankajBhojwani dec8950
duplicate now includes unfocusedAppearance
PankajBhojwani 2d31527
conflict
PankajBhojwani 1b9bb9b
format
PankajBhojwani aa5e0d7
rename the create new button
PankajBhojwani 51ec91c
check for user default profile settings before using it
PankajBhojwani 2c31c87
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani db1358e
deduplication counter
PankajBhojwani 62ff394
conflict
PankajBhojwani 947efeb
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani 294d4e2
fix copy number
PankajBhojwani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "pch.h" | ||
#include "AddProfile.h" | ||
#include "AddProfile.g.cpp" | ||
#include "AddProfilePageNavigationState.g.cpp" | ||
#include "EnumEntry.h" | ||
|
||
using namespace winrt::Windows::Foundation; | ||
using namespace winrt::Windows::System; | ||
using namespace winrt::Windows::UI::Core; | ||
using namespace winrt::Windows::UI::Xaml::Navigation; | ||
using namespace winrt::Microsoft::Terminal::Settings::Model; | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | ||
{ | ||
AddProfile::AddProfile() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
void AddProfile::OnNavigatedTo(const NavigationEventArgs& e) | ||
{ | ||
_State = e.Parameter().as<Editor::AddProfilePageNavigationState>(); | ||
DHowett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
void AddProfile::AddNewClick(const IInspectable& /*sender*/, | ||
const Windows::UI::Xaml::RoutedEventArgs& /*eventArgs*/) | ||
{ | ||
_State.RequestAddNew(); | ||
} | ||
|
||
void AddProfile::DuplicateClick(const IInspectable& /*sender*/, | ||
const Windows::UI::Xaml::RoutedEventArgs& /*eventArgs*/) | ||
{ | ||
if (const auto selected = Profiles().SelectedItem()) | ||
{ | ||
_State.RequestDuplicate(selected.try_as<Model::Profile>().Guid()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/*++ | ||
Copyright (c) Microsoft Corporation | ||
Licensed under the MIT license. | ||
|
||
Module Name: | ||
- AddProfile.h | ||
|
||
Abstract: | ||
- This creates the 'add new profile' page in the settings UI and handles | ||
user interaction with it, raising events to the main page as necessary | ||
|
||
|
||
Author(s): | ||
- Pankaj Bhojwani - March 2021 | ||
|
||
--*/ | ||
|
||
#pragma once | ||
|
||
#include "AddProfile.g.h" | ||
#include "AddProfilePageNavigationState.g.h" | ||
#include "Utils.h" | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | ||
{ | ||
struct AddProfilePageNavigationState : AddProfilePageNavigationStateT<AddProfilePageNavigationState> | ||
{ | ||
public: | ||
AddProfilePageNavigationState(const Model::CascadiaSettings& settings) : | ||
_Settings{ settings } {} | ||
|
||
void RequestAddNew() | ||
{ | ||
_AddNewHandlers(winrt::guid{}); | ||
} | ||
|
||
void RequestDuplicate(GUID profile) | ||
{ | ||
_AddNewHandlers(profile); | ||
} | ||
|
||
WINRT_PROPERTY(Model::CascadiaSettings, Settings, nullptr) | ||
WINRT_CALLBACK(AddNew, AddNewArgs); | ||
}; | ||
|
||
struct AddProfile : AddProfileT<AddProfile> | ||
{ | ||
public: | ||
AddProfile(); | ||
|
||
void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e); | ||
|
||
void AddNewClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs); | ||
void DuplicateClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs); | ||
|
||
WINRT_PROPERTY(Editor::AddProfilePageNavigationState, State, nullptr); | ||
}; | ||
} | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation | ||
{ | ||
BASIC_FACTORY(AddProfile); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
namespace Microsoft.Terminal.Settings.Editor | ||
{ | ||
delegate void AddNewArgs(Guid profile); | ||
|
||
runtimeclass AddProfilePageNavigationState | ||
{ | ||
Microsoft.Terminal.Settings.Model.CascadiaSettings Settings; | ||
void RequestAddNew(); | ||
void RequestDuplicate(Guid profile); | ||
event AddNewArgs AddNew; | ||
}; | ||
|
||
[default_interface] runtimeclass AddProfile : Windows.UI.Xaml.Controls.Page | ||
{ | ||
AddProfile(); | ||
AddProfilePageNavigationState State { get; }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<!-- | ||
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under | ||
the MIT License. See LICENSE in the project root for license information. | ||
--> | ||
<Page x:Class="Microsoft.Terminal.Settings.Editor.AddProfile" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:Microsoft.Terminal.Settings.Editor" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:model="using:Microsoft.Terminal.Settings.Model" | ||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" | ||
mc:Ignorable="d"> | ||
|
||
<Page.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="CommonResources.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
<model:IconPathConverter x:Key="IconSourceConverter" /> | ||
</ResourceDictionary> | ||
</Page.Resources> | ||
|
||
<ScrollViewer> | ||
<StackPanel Style="{StaticResource SettingsStackStyle}"> | ||
<Button x:Uid="AddProfile_AddNewButton" | ||
AutomationProperties.AutomationId="AddProfile_AddNewButton" | ||
AutomationProperties.Name="{Binding Tag, RelativeSource={RelativeSource Self}}" | ||
Click="AddNewClick" | ||
Style="{StaticResource AccentButtonStyle}"> | ||
<Button.Content> | ||
<StackPanel Orientation="Horizontal"> | ||
<FontIcon FontSize="{StaticResource StandardIconSize}" | ||
Glyph="" /> | ||
<TextBlock x:Uid="AddProfile_AddNewTextBlock" | ||
Style="{StaticResource IconButtonTextBlockStyle}" /> | ||
</StackPanel> | ||
</Button.Content> | ||
</Button> | ||
<StackPanel Margin="{StaticResource StandardControlMargin}"> | ||
<local:SettingContainer x:Uid="AddProfile_Duplicate"> | ||
<muxc:RadioButtons x:Name="Profiles" | ||
ItemsSource="{x:Bind State.Settings.AllProfiles, Mode=OneWay}"> | ||
<muxc:RadioButtons.ItemTemplate> | ||
<DataTemplate x:DataType="model:Profile"> | ||
<Grid HorizontalAlignment="Stretch" | ||
ColumnSpacing="8"> | ||
|
||
<Grid.ColumnDefinitions> | ||
<!-- icon --> | ||
<ColumnDefinition Width="16" /> | ||
<!-- profile name --> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<IconSourceElement Grid.Column="0" | ||
Width="16" | ||
Height="16" | ||
IconSource="{x:Bind Icon, Mode=OneWay, Converter={StaticResource IconSourceConverter}}" /> | ||
|
||
<TextBlock Grid.Column="1" | ||
Text="{x:Bind Name}" /> | ||
|
||
</Grid> | ||
</DataTemplate> | ||
</muxc:RadioButtons.ItemTemplate> | ||
</muxc:RadioButtons> | ||
</local:SettingContainer> | ||
<Button x:Uid="AddProfile_DuplicateButton" | ||
Margin="{StaticResource StandardControlMargin}" | ||
AutomationProperties.AutomationId="AddProfile_DuplicateButton" | ||
AutomationProperties.Name="{Binding Tag, RelativeSource={RelativeSource Self}}" | ||
Click="DuplicateClick" | ||
Style="{StaticResource AccentButtonStyle}"> | ||
PankajBhojwani marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<Button.Content> | ||
<StackPanel Orientation="Horizontal"> | ||
<FontIcon FontSize="{StaticResource StandardIconSize}" | ||
Glyph="" /> | ||
<TextBlock x:Uid="AddProfile_DuplicateTextBlock" | ||
Style="{StaticResource IconButtonTextBlockStyle}" /> | ||
</StackPanel> | ||
</Button.Content> | ||
</Button> | ||
</StackPanel> | ||
</StackPanel> | ||
</ScrollViewer> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bonus points: add a test that specifically covers the dynamic profile case (since that one is more complex)