Skip to content
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

Maintain current Pivot selection when saving on the Profiles page #8803

Merged
34 commits merged into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b60245f
50 ways to _not do this correctly_
zadjii-msft Jan 13, 2021
24540c7
Merge remote-tracking branch 'origin/main' into dev/migrie/b/8764b-sc…
zadjii-msft Jan 13, 2021
8334a2d
what if we just took Bikini Bottom, and _pushed it somewhere else_
zadjii-msft Jan 13, 2021
9cb1c2e
Make the BG image settings appear when then path contains something
zadjii-msft Jan 13, 2021
3cc5cb6
Some cleanup of the converters
zadjii-msft Jan 13, 2021
33029e6
Add a checkbox for "Use desktop wallpaper"
zadjii-msft Jan 13, 2021
9e9f0f5
This is so very much closer
zadjii-msft Jan 13, 2021
a06c0f3
Yea this works nicely
zadjii-msft Jan 13, 2021
677b920
Code cleanup for review
zadjii-msft Jan 13, 2021
cb0db01
spellcheck
zadjii-msft Jan 13, 2021
15c9a78
Merge remote-tracking branch 'origin/main' into dev/migrie/b/8763-bg-…
zadjii-msft Jan 13, 2021
a5a46af
Amazingly, persist the selected scheme across saves/navigations
zadjii-msft Jan 13, 2021
ce8a681
cleanup
zadjii-msft Jan 13, 2021
844d59e
this is a dead end I think
zadjii-msft Jan 14, 2021
7663069
Merge branch 'dev/migrie/b/8763-bg-image-polish' into dev/migrie/b/87…
zadjii-msft Jan 14, 2021
ce0686d
HO BOY this is stupid but it sure does work
zadjii-msft Jan 14, 2021
92afd3f
I really annot believe this works
zadjii-msft Jan 14, 2021
eed5788
do it to the other buttons as well
zadjii-msft Jan 14, 2021
cade076
Merge remote-tracking branch 'origin/main' into dev/migrie/b/8763-bg-…
zadjii-msft Jan 14, 2021
608ef13
disable the bg input when it's desktopWallpaper
zadjii-msft Jan 14, 2021
bfaafcb
sHoUlDn't bE ToO DiFfIcUlT
zadjii-msft Jan 14, 2021
a9521b2
I'll un-check you bot
zadjii-msft Jan 15, 2021
dbd2057
Merge remote-tracking branch 'origin/main' into dev/migrie/b/8763-bg-…
zadjii-msft Jan 15, 2021
ae271b7
Merge remote-tracking branch 'origin/main' into dev/migrie/b/8765-sui…
zadjii-msft Jan 15, 2021
688c732
Merge branch 'dev/migrie/b/8763-bg-image-polish' into dev/migrie/b/87…
zadjii-msft Jan 15, 2021
ee797a6
This works like a charm
zadjii-msft Jan 15, 2021
6fbf76a
cleanup for review
zadjii-msft Jan 15, 2021
39857f3
Merge remote-tracking branch 'origin/main' into dev/migrie/b/8765-sui…
zadjii-msft Jan 19, 2021
a1d8068
a bad merge
zadjii-msft Jan 19, 2021
3f98fb7
Merge branch 'dev/migrie/b/8765-sui-color-scheme-page' into dev/migri…
zadjii-msft Jan 19, 2021
7af113e
These weren't necessary after all!
zadjii-msft Jan 19, 2021
7c75714
nits
zadjii-msft Jan 19, 2021
3e427ea
Merge branch 'dev/migrie/b/8765-sui-color-scheme-page' into dev/migri…
zadjii-msft Jan 19, 2021
bd8da46
Merge remote-tracking branch 'origin/main' into dev/migrie/b/8769a-pr…
zadjii-msft Jan 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/cascadia/TerminalSettingsEditor/MainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_InitializeProfilesList();

_colorSchemesNavState = winrt::make<ColorSchemesPageNavigationState>(_settingsClone.GlobalSettings());

// We have to provide _some_ profile in the profile nav state, so just
// hook it up with the base for now. It'll get updated when we actually
// navigate to a profile.
auto profileVM{ _viewModelForProfile(_settingsClone.ProfileDefaults()) };
profileVM.IsBaseLayer(true);
_profilesNavState = winrt::make<ProfilePageNavigationState>(profileVM,
_settingsClone.GlobalSettings().ColorSchemes(),
*this);

// Add an event handler for when the user wants to delete a profile.
_profilesNavState.DeleteProfile({ this, &MainPage::_DeleteProfile });
}

// Method Description:
Expand Down Expand Up @@ -98,6 +110,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

// Update the Nav State with the new version of the settings
_colorSchemesNavState.Globals(_settingsClone.GlobalSettings());
_profilesNavState.Schemes(_settingsClone.GlobalSettings().ColorSchemes());
// We'll update the profile in the _profilesNavState whenever we actually navigate to one

_RefreshCurrentPage();
}
Expand Down Expand Up @@ -226,7 +240,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
auto profileVM{ _viewModelForProfile(_settingsClone.ProfileDefaults()) };
profileVM.IsBaseLayer(true);
contentFrame().Navigate(xaml_typename<Editor::Profiles>(), winrt::make<ProfilePageNavigationState>(profileVM, _settingsClone.GlobalSettings().ColorSchemes(), *this));

// Update the profiles navigation state
_profilesNavState.Profile(profileVM);

contentFrame().Navigate(xaml_typename<Editor::Profiles>(), _profilesNavState);
}
else if (clickedItemTag == colorSchemesTag)
{
Expand All @@ -240,12 +258,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void MainPage::_Navigate(const Editor::ProfileViewModel& profile)
{
auto state{ winrt::make<ProfilePageNavigationState>(profile, _settingsClone.GlobalSettings().ColorSchemes(), *this) };

// Add an event handler for when the user wants to delete a profile.
state.DeleteProfile({ this, &MainPage::_DeleteProfile });
// Update the profiles navigation state
_profilesNavState.Profile(profile);

contentFrame().Navigate(xaml_typename<Editor::Profiles>(), state);
contentFrame().Navigate(xaml_typename<Editor::Profiles>(), _profilesNavState);
}

void MainPage::OpenJsonTapped(IInspectable const& /*sender*/, Windows::UI::Xaml::Input::TappedRoutedEventArgs const& /*args*/)
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/MainPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void _RefreshCurrentPage();

ColorSchemesPageNavigationState _colorSchemesNavState{ nullptr };
ProfilePageNavigationState _profilesNavState{ nullptr };
};
}

Expand Down
9 changes: 9 additions & 0 deletions src/cascadia/TerminalSettingsEditor/Profiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
StartingDirectoryUseParentCheckbox().IsChecked(true);
}

// Navigate to the pivot in the provided navigation state
ProfilesPivot().SelectedIndex(static_cast<int>(_State.LastActivePivot()));
}

ColorScheme Profiles::CurrentColorScheme()
Expand Down Expand Up @@ -366,4 +369,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
return _State.Profile().CursorShape() == TerminalControl::CursorStyle::Vintage;
}

void Profiles::Pivot_SelectionChanged(Windows::Foundation::IInspectable const& /*sender*/,
Windows::UI::Xaml::RoutedEventArgs const& /*e*/)
{
_State.LastActivePivot(static_cast<Editor::ProfilesPivots>(ProfilesPivot().SelectedIndex()));
}

}
25 changes: 23 additions & 2 deletions src/cascadia/TerminalSettingsEditor/Profiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
struct ProfilePageNavigationState : ProfilePageNavigationStateT<ProfilePageNavigationState>
{
public:
ProfilePageNavigationState(const Editor::ProfileViewModel& viewModel, const Windows::Foundation::Collections::IMapView<hstring, Model::ColorScheme>& schemes, const IHostedInWindow& windowRoot) :
ProfilePageNavigationState(const Editor::ProfileViewModel& viewModel,
const Windows::Foundation::Collections::IMapView<hstring, Model::ColorScheme>& schemes,
const IHostedInWindow& windowRoot) :
_Profile{ viewModel },
_Schemes{ schemes },
_WindowRoot{ windowRoot }
Expand All @@ -99,9 +101,27 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

TYPED_EVENT(DeleteProfile, Editor::ProfilePageNavigationState, Editor::DeleteProfileEventArgs);
GETSET_PROPERTY(IHostedInWindow, WindowRoot, nullptr);
GETSET_PROPERTY(Editor::ProfileViewModel, Profile, nullptr);
GETSET_PROPERTY(Editor::ProfilesPivots, LastActivePivot, Editor::ProfilesPivots::General);

public:
// Manually define Profile(), so we can overload the setter
Editor::ProfileViewModel Profile() const noexcept { return _Profile; }

void Profile(const Editor::ProfileViewModel& value) noexcept
{
// If the profile has a different guid than the new one, then reset
// the selected pivot to the "General" tab.
const auto& oldGuid = _Profile.Guid();
const auto& newGuid = value.Guid();
if (oldGuid != newGuid)
{
_LastActivePivot = Editor::ProfilesPivots::General;
}
_Profile = value;
}

private:
Editor::ProfileViewModel _Profile{ nullptr };
Windows::Foundation::Collections::IMapView<hstring, Model::ColorScheme> _Schemes;
};

Expand All @@ -123,6 +143,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
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);
void Pivot_SelectionChanged(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);
Expand Down
9 changes: 8 additions & 1 deletion src/cascadia/TerminalSettingsEditor/Profiles.idl
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,19 @@ namespace Microsoft.Terminal.Settings.Editor
Guid ProfileGuid { get; };
}

enum ProfilesPivots {
General = 0,
Appearance = 1,
Advanced = 2
};

runtimeclass ProfilePageNavigationState
{
Windows.Foundation.Collections.IMapView<String, Microsoft.Terminal.Settings.Model.ColorScheme> Schemes;
IHostedInWindow WindowRoot; // necessary to send the right HWND into the file picker dialogs.

ProfileViewModel Profile { get; };
ProfileViewModel Profile;
ProfilesPivots LastActivePivot;

event Windows.Foundation.TypedEventHandler<ProfilePageNavigationState, DeleteProfileEventArgs> DeleteProfile;
};
Expand Down
4 changes: 3 additions & 1 deletion src/cascadia/TerminalSettingsEditor/Profiles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ the MIT License. See LICENSE in the project root for license information. -->
Style="{StaticResource DisclaimerStyle}"
Visibility="{x:Bind State.Profile.IsBaseLayer}"/>

<Pivot HorizontalAlignment="Left"
<Pivot x:Name="ProfilesPivot"
HorizontalAlignment="Left"
Grid.Row="1"
SelectionChanged="Pivot_SelectionChanged"
Margin="{StaticResource PivotIndentMargin}">
<!-- General Tab -->
<PivotItem x:Uid="Profile_General">
Expand Down