Skip to content

Commit

Permalink
rebase after merge main in base branch
Browse files Browse the repository at this point in the history
  • Loading branch information
PankajBhojwani committed Jan 12, 2022
1 parent b73cdd0 commit f8b7db9
Show file tree
Hide file tree
Showing 17 changed files with 152 additions and 133 deletions.
21 changes: 12 additions & 9 deletions src/cascadia/TerminalSettingsEditor/MainPage.cpp
Expand Up @@ -311,26 +311,27 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
auto state{ winrt::make<ProfilePageNavigationState>(profileVM,
_settingsClone.GlobalSettings().ColorSchemes(),
*this) };
_lastProfilesNavState = state;

_profileViewModelChangedRevoker = _lastProfilesNavState.Profile().PropertyChanged(winrt::auto_revoke, [=](auto&&, const PropertyChangedEventArgs& args) {
_profileViewModelChangedRevoker = state.Profile().PropertyChanged(winrt::auto_revoke, [=](auto&&, const PropertyChangedEventArgs& args) {
const auto settingName{ args.PropertyName() };
if (settingName == L"CurrentPage")
{
const auto currentPage = _lastProfilesNavState.Profile().CurrentPage();
const auto currentPage = state.Profile().CurrentPage();
if (currentPage == L"Base")
{
contentFrame().Navigate(xaml_typename<Editor::Profiles_Base>(), _lastProfilesNavState);
contentFrame().Navigate(xaml_typename<Editor::Profiles_Base>(), state);
_breadcrumbs.Clear();
_breadcrumbs.Append(RS_(L"Nav_ProfileDefaults/Content"));
}
else if (currentPage == L"Appearance")
{
contentFrame().Navigate(xaml_typename<Editor::Profiles_Appearance>(), _lastProfilesNavState);
contentFrame().Navigate(xaml_typename<Editor::Profiles_Appearance>(), state);
_breadcrumbs.Append(RS_(L"Profile_Appearance/Header"));
}
else if (currentPage == L"Advanced")
{
contentFrame().Navigate(xaml_typename<Editor::Profiles_Advanced>(), _lastProfilesNavState);
contentFrame().Navigate(xaml_typename<Editor::Profiles_Advanced>(), state);
_breadcrumbs.Append(RS_(L"Profile_Advanced/Header"));
}
}
Expand Down Expand Up @@ -368,6 +369,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
auto state{ winrt::make<ProfilePageNavigationState>(profile,
_settingsClone.GlobalSettings().ColorSchemes(),
*this) };
_lastProfilesNavState = state;

_profileViewModelChangedRevoker.revoke();
_breadcrumbs.Clear();

Expand All @@ -384,25 +387,25 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// We decided that it's better for the owner of the BreadcrumbBar to also be responsible
// for navigation, so the navigation to Profiles_Advanced/Profiles_Appearance from
// Profiles_Base got moved here.
_profileViewModelChangedRevoker = state.Profile().PropertyChanged(winrt::auto_revoke, [=](auto&&, const PropertyChangedEventArgs& args) {
_profileViewModelChangedRevoker = profile.PropertyChanged(winrt::auto_revoke, [=](auto&&, const PropertyChangedEventArgs& args) {
const auto settingName{ args.PropertyName() };
if (settingName == L"CurrentPage")
{
const auto currentPage = state.Profile().CurrentPage();
if (currentPage == L"Base")
{
contentFrame().Navigate(xaml_typename<Editor::Profiles_Base>(), _lastProfilesNavState);
contentFrame().Navigate(xaml_typename<Editor::Profiles_Base>(), state);
_breadcrumbs.Clear();
_breadcrumbs.Append(profile.Name());
}
else if (currentPage == L"Appearance")
{
contentFrame().Navigate(xaml_typename<Editor::Profiles_Appearance>(), _lastProfilesNavState);
contentFrame().Navigate(xaml_typename<Editor::Profiles_Appearance>(), state);
_breadcrumbs.Append(RS_(L"Profile_Appearance/Header"));
}
else if (currentPage == L"Advanced")
{
contentFrame().Navigate(xaml_typename<Editor::Profiles_Advanced>(), _lastProfilesNavState);
contentFrame().Navigate(xaml_typename<Editor::Profiles_Advanced>(), state);
_breadcrumbs.Append(RS_(L"Profile_Advanced/Header"));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/MainPage.h
Expand Up @@ -50,6 +50,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

winrt::Microsoft::Terminal::Settings::Editor::ColorSchemesPageNavigationState _colorSchemesNavState{ nullptr };

winrt::Microsoft::Terminal::Settings::Editor::ProfilePageNavigationState _lastProfilesNavState{ nullptr };
Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker _profileViewModelChangedRevoker;
};
}
Expand Down
11 changes: 11 additions & 0 deletions src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp
Expand Up @@ -137,6 +137,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_defaultAppearanceViewModel.IsDefault(true);
}

winrt::hstring ProfileViewModel::CurrentPage()
{
return _currentPage;
}

void ProfileViewModel::CurrentPage(const winrt::hstring newPage)
{
_currentPage = newPage;
_NotifyChanges(L"CurrentPage");
}

Model::TerminalSettings ProfileViewModel::TermSettings() const
{
return Model::TerminalSettings::CreateWithProfile(_appSettings, _profile, nullptr).DefaultSettings();
Expand Down
4 changes: 4 additions & 0 deletions src/cascadia/TerminalSettingsEditor/ProfileViewModel.h
Expand Up @@ -77,6 +77,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void DeleteUnfocusedAppearance();
bool AtlasEngineAvailable() const noexcept;

winrt::hstring CurrentPage();
void CurrentPage(const winrt::hstring newPage);

WINRT_PROPERTY(bool, IsBaseLayer, false);
WINRT_PROPERTY(IHostedInWindow, WindowRoot, nullptr);
GETSET_BINDABLE_ENUM_SETTING(AntiAliasingMode, Microsoft::Terminal::Control::TextAntialiasingMode, _profile, AntialiasingMode);
Expand Down Expand Up @@ -119,6 +122,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
winrt::hstring _lastStartingDirectoryPath;
Editor::AppearanceViewModel _defaultAppearanceViewModel;
Windows::Foundation::Collections::IMapView<hstring, Model::ColorScheme> _Schemes;
winrt::hstring _currentPage;

static Windows::Foundation::Collections::IObservableVector<Editor::Font> _MonospaceFontList;
static Windows::Foundation::Collections::IObservableVector<Editor::Font> _FontList;
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl
Expand Up @@ -54,6 +54,7 @@ namespace Microsoft.Terminal.Settings.Editor

Boolean CanDeleteProfile { get; };
Boolean IsBaseLayer;
String CurrentPage;
Boolean UseParentProcessDirectory;
Boolean UseCustomStartingDirectory { get; };
AppearanceViewModel DefaultAppearance { get; };
Expand Down
19 changes: 10 additions & 9 deletions src/cascadia/TerminalSettingsEditor/Profiles_Advanced.cpp
Expand Up @@ -23,12 +23,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void Profiles_Advanced::OnNavigatedTo(const NavigationEventArgs& e)
{
_State = e.Parameter().as<Editor::ProfilePageNavigationState>();
auto state{ e.Parameter().as<Editor::ProfilePageNavigationState>() };
_Profile = state.Profile();

// Subscribe to some changes in the view model
// These changes should force us to update our own set of "Current<Setting>" members,
// and propagate those changes to the UI
_ViewModelChangedRevoker = _State.Profile().PropertyChanged(winrt::auto_revoke, [=](auto&&, const PropertyChangedEventArgs& args) {
_ViewModelChangedRevoker = _Profile.PropertyChanged(winrt::auto_revoke, [=](auto&&, const PropertyChangedEventArgs& args) {
const auto settingName{ args.PropertyName() };
if (settingName == L"AntialiasingMode")
{
Expand All @@ -52,27 +53,27 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

bool Profiles_Advanced::IsBellStyleFlagSet(const uint32_t flag)
{
return (WI_EnumValue(_State.Profile().BellStyle()) & flag) == flag;
return (WI_EnumValue(_Profile.BellStyle()) & flag) == flag;
}

void Profiles_Advanced::SetBellStyleAudible(winrt::Windows::Foundation::IReference<bool> on)
{
auto currentStyle = State().Profile().BellStyle();
auto currentStyle = _Profile.BellStyle();
WI_UpdateFlag(currentStyle, Model::BellStyle::Audible, winrt::unbox_value<bool>(on));
State().Profile().BellStyle(currentStyle);
_Profile.BellStyle(currentStyle);
}

void Profiles_Advanced::SetBellStyleWindow(winrt::Windows::Foundation::IReference<bool> on)
{
auto currentStyle = State().Profile().BellStyle();
auto currentStyle = _Profile.BellStyle();
WI_UpdateFlag(currentStyle, Model::BellStyle::Window, winrt::unbox_value<bool>(on));
State().Profile().BellStyle(currentStyle);
_Profile.BellStyle(currentStyle);
}

void Profiles_Advanced::SetBellStyleTaskbar(winrt::Windows::Foundation::IReference<bool> on)
{
auto currentStyle = State().Profile().BellStyle();
auto currentStyle = _Profile.BellStyle();
WI_UpdateFlag(currentStyle, Model::BellStyle::Taskbar, winrt::unbox_value<bool>(on));
State().Profile().BellStyle(currentStyle);
_Profile.BellStyle(currentStyle);
}
}
6 changes: 3 additions & 3 deletions src/cascadia/TerminalSettingsEditor/Profiles_Advanced.h
Expand Up @@ -24,9 +24,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void SetBellStyleTaskbar(winrt::Windows::Foundation::IReference<bool> on);

WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_PROPERTY(Editor::ProfilePageNavigationState, State, nullptr);
GETSET_BINDABLE_ENUM_SETTING(AntiAliasingMode, Microsoft::Terminal::Control::TextAntialiasingMode, State().Profile, AntialiasingMode);
GETSET_BINDABLE_ENUM_SETTING(CloseOnExitMode, Microsoft::Terminal::Settings::Model::CloseOnExitMode, State().Profile, CloseOnExit);
WINRT_PROPERTY(Editor::ProfileViewModel, Profile, nullptr);
GETSET_BINDABLE_ENUM_SETTING(AntiAliasingMode, Microsoft::Terminal::Control::TextAntialiasingMode, _Profile, AntialiasingMode);
GETSET_BINDABLE_ENUM_SETTING(CloseOnExitMode, Microsoft::Terminal::Settings::Model::CloseOnExitMode, _Profile, CloseOnExit);

private:
Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker _ViewModelChangedRevoker;
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsEditor/Profiles_Advanced.idl
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.Terminal.Settings.Editor
[default_interface] runtimeclass Profiles_Advanced : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged
{
Profiles_Advanced();
ProfilePageNavigationState State { get; };
ProfileViewModel Profile { get; };

Boolean IsBellStyleFlagSet(UInt32 flag);
void SetBellStyleAudible(Windows.Foundation.IReference<Boolean> on);
Expand Down
52 changes: 26 additions & 26 deletions src/cascadia/TerminalSettingsEditor/Profiles_Advanced.xaml
Expand Up @@ -34,24 +34,24 @@
Grid.Row="0"
Margin="{StaticResource StandardIndentMargin}"
Style="{StaticResource DisclaimerStyle}"
Visibility="{x:Bind State.Profile.IsBaseLayer}" />
Visibility="{x:Bind Profile.IsBaseLayer}" />
<ScrollViewer Grid.Row="1"
ViewChanging="ViewChanging">
<StackPanel Margin="13,0,0,0"
Style="{StaticResource PivotStackStyle}">
<!-- Suppress Application Title -->
<local:SettingContainer x:Uid="Profile_SuppressApplicationTitle"
ClearSettingValue="{x:Bind State.Profile.ClearSuppressApplicationTitle}"
HasSettingValue="{x:Bind State.Profile.HasSuppressApplicationTitle, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.SuppressApplicationTitleOverrideSource, Mode=OneWay}">
<ToggleSwitch IsOn="{x:Bind State.Profile.SuppressApplicationTitle, Mode=TwoWay}" />
ClearSettingValue="{x:Bind Profile.ClearSuppressApplicationTitle}"
HasSettingValue="{x:Bind Profile.HasSuppressApplicationTitle, Mode=OneWay}"
SettingOverrideSource="{x:Bind Profile.SuppressApplicationTitleOverrideSource, Mode=OneWay}">
<ToggleSwitch IsOn="{x:Bind Profile.SuppressApplicationTitle, Mode=TwoWay}" />
</local:SettingContainer>

<!-- Antialiasing Mode -->
<local:SettingContainer x:Uid="Profile_AntialiasingMode"
ClearSettingValue="{x:Bind State.Profile.ClearAntialiasingMode}"
HasSettingValue="{x:Bind State.Profile.HasAntialiasingMode, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.AntialiasingModeOverrideSource, Mode=OneWay}"
ClearSettingValue="{x:Bind Profile.ClearAntialiasingMode}"
HasSettingValue="{x:Bind Profile.HasAntialiasingMode, Mode=OneWay}"
SettingOverrideSource="{x:Bind Profile.AntialiasingModeOverrideSource, Mode=OneWay}"
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
Expand All @@ -61,38 +61,38 @@

<!-- AltGr Aliasing -->
<local:SettingContainer x:Uid="Profile_AltGrAliasing"
ClearSettingValue="{x:Bind State.Profile.ClearAltGrAliasing}"
HasSettingValue="{x:Bind State.Profile.HasAltGrAliasing, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.AltGrAliasingOverrideSource, Mode=OneWay}">
<ToggleSwitch IsOn="{x:Bind State.Profile.AltGrAliasing, Mode=TwoWay}" />
ClearSettingValue="{x:Bind Profile.ClearAltGrAliasing}"
HasSettingValue="{x:Bind Profile.HasAltGrAliasing, Mode=OneWay}"
SettingOverrideSource="{x:Bind Profile.AltGrAliasingOverrideSource, Mode=OneWay}">
<ToggleSwitch IsOn="{x:Bind Profile.AltGrAliasing, Mode=TwoWay}" />
</local:SettingContainer>

<!-- Snap On Input -->
<local:SettingContainer x:Uid="Profile_SnapOnInput"
ClearSettingValue="{x:Bind State.Profile.ClearSnapOnInput}"
HasSettingValue="{x:Bind State.Profile.HasSnapOnInput, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.SnapOnInputOverrideSource, Mode=OneWay}">
<ToggleSwitch IsOn="{x:Bind State.Profile.SnapOnInput, Mode=TwoWay}" />
ClearSettingValue="{x:Bind Profile.ClearSnapOnInput}"
HasSettingValue="{x:Bind Profile.HasSnapOnInput, Mode=OneWay}"
SettingOverrideSource="{x:Bind Profile.SnapOnInputOverrideSource, Mode=OneWay}">
<ToggleSwitch IsOn="{x:Bind Profile.SnapOnInput, Mode=TwoWay}" />
</local:SettingContainer>

<!-- History Size -->
<local:SettingContainer x:Uid="Profile_HistorySize"
ClearSettingValue="{x:Bind State.Profile.ClearHistorySize}"
HasSettingValue="{x:Bind State.Profile.HasHistorySize, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.HistorySizeOverrideSource, Mode=OneWay}">
ClearSettingValue="{x:Bind Profile.ClearHistorySize}"
HasSettingValue="{x:Bind Profile.HasHistorySize, Mode=OneWay}"
SettingOverrideSource="{x:Bind Profile.HistorySizeOverrideSource, Mode=OneWay}">
<muxc:NumberBox x:Uid="Profile_HistorySizeBox"
LargeChange="100"
Minimum="0"
SmallChange="10"
Style="{StaticResource NumberBoxSettingStyle}"
Value="{x:Bind State.Profile.HistorySize, Mode=TwoWay}" />
Value="{x:Bind Profile.HistorySize, Mode=TwoWay}" />
</local:SettingContainer>

<!-- Close On Exit -->
<local:SettingContainer x:Uid="Profile_CloseOnExit"
ClearSettingValue="{x:Bind State.Profile.ClearCloseOnExit}"
HasSettingValue="{x:Bind State.Profile.HasCloseOnExit, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.CloseOnExitOverrideSource, Mode=OneWay}"
ClearSettingValue="{x:Bind Profile.ClearCloseOnExit}"
HasSettingValue="{x:Bind Profile.HasCloseOnExit, Mode=OneWay}"
SettingOverrideSource="{x:Bind Profile.CloseOnExitOverrideSource, Mode=OneWay}"
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
Expand All @@ -102,9 +102,9 @@

<!-- Bell Style -->
<local:SettingContainer x:Uid="Profile_BellStyle"
ClearSettingValue="{x:Bind State.Profile.ClearBellStyle}"
HasSettingValue="{x:Bind State.Profile.HasBellStyle, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.BellStyleOverrideSource, Mode=OneWay}"
ClearSettingValue="{x:Bind Profile.ClearBellStyle}"
HasSettingValue="{x:Bind Profile.HasBellStyle, Mode=OneWay}"
SettingOverrideSource="{x:Bind Profile.BellStyleOverrideSource, Mode=OneWay}"
Style="{StaticResource ExpanderSettingContainerStyle}">
<StackPanel>
<CheckBox x:Uid="Profile_BellStyleAudible"
Expand Down

0 comments on commit f8b7db9

Please sign in to comment.