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

Polish OpenSettings action for Settings UI and Profile page navigation on refresh #8670

Merged
merged 8 commits into from
Jan 4, 2021
4 changes: 3 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,9 @@ namespace winrt::TerminalApp::implementation
settingsItem.Click({ this, &TerminalPage::_SettingsButtonOnClick });
newTabFlyout.Items().Append(settingsItem);

auto settingsKeyChord = keyBindings.GetKeyBindingForAction(ShortcutAction::OpenSettings);
Microsoft::Terminal::Settings::Model::OpenSettingsArgs args{ SettingsTarget::SettingsFile };
Microsoft::Terminal::Settings::Model::ActionAndArgs settingsAction{ ShortcutAction::OpenSettings, args };
const auto settingsKeyChord{ keyBindings.GetKeyBindingForActionWithArgs(settingsAction) };
if (settingsKeyChord)
{
_SetAcceleratorForMenuItem(settingsItem, settingsKeyChord);
Expand Down
10 changes: 5 additions & 5 deletions src/cascadia/TerminalSettingsEditor/MainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
if (const auto tag{ navViewItem.Tag() })
{
if (tag.try_as<Model::Profile>())
if (tag.try_as<Editor::ProfileViewModel>())
{
// hide NavViewItem pointing to a Profile
navViewItem.Visibility(Visibility::Collapsed);
Expand Down Expand Up @@ -104,13 +104,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
if (const auto tag{ selectedItem.as<MUX::Controls::NavigationViewItem>().Tag() })
{
if (const auto profile{ tag.try_as<Model::Profile>() })
if (const auto oldProfile{ tag.try_as<Editor::ProfileViewModel>() })
{
// check if the profile still exists
if (_settingsClone.FindProfile(profile.Guid()))
if (const auto profile{ _settingsClone.FindProfile(oldProfile.Guid()) })
{
// Navigate to the page with the given profile
contentFrame().Navigate(xaml_typename<Editor::Profiles>(), winrt::make<ProfilePageNavigationState>(_viewModelForProfile(profile), _settingsClone.GlobalSettings().ColorSchemes(), *this));
_Navigate(_viewModelForProfile(profile));
return;
}
}
Expand All @@ -126,7 +126,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// could not find the page we were on, fallback to first menu item
const auto firstItem{ navigationMenu.MenuItems().GetAt(0) };
navigationMenu.SelectedItem(firstItem);
if (const auto tag{ navigationMenu.SelectedItem().as<NavigationViewItem>().Tag() })
if (const auto tag{ navigationMenu.SelectedItem().as<MUX::Controls::NavigationViewItem>().Tag() })
{
_Navigate(unbox_value<hstring>(tag));
}
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsModel/ActionArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
return RS_(L"OpenDefaultSettingsCommandKey");
case SettingsTarget::AllFiles:
return RS_(L"OpenBothSettingsFilesCommandKey");
case SettingsTarget::SettingsUI:
return RS_(L"OpenSettingsUICommandKey");
default:
return RS_(L"OpenSettingsCommandKey");
}
Expand Down
3 changes: 3 additions & 0 deletions src/cascadia/TerminalSettingsModel/ActionArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
struct OpenSettingsArgs : public OpenSettingsArgsT<OpenSettingsArgs>
{
OpenSettingsArgs() = default;
OpenSettingsArgs(const SettingsTarget& target) :
_Target{ target } {}
GETSET_PROPERTY(SettingsTarget, Target, SettingsTarget::SettingsFile);

static constexpr std::string_view TargetKey{ "target" };
Expand Down Expand Up @@ -850,4 +852,5 @@ namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation
BASIC_FACTORY(CloseOtherTabsArgs);
BASIC_FACTORY(CloseTabsAfterArgs);
BASIC_FACTORY(MoveTabArgs);
BASIC_FACTORY(OpenSettingsArgs);
}
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsModel/ActionArgs.idl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ namespace Microsoft.Terminal.Settings.Model

[default_interface] runtimeclass OpenSettingsArgs : IActionArgs
{
OpenSettingsArgs(SettingsTarget target);
SettingsTarget Target { get; };
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,7 @@
<data name="BreakIntoDebuggerCommandKey" xml:space="preserve">
<value>Break into the debugger</value>
</data>
<data name="OpenSettingsUICommandKey" xml:space="preserve">
<value>Open Settings...</value>
</data>
</root>