From aa5fb80b15eec2d672c9b4f4deee07acedb25918 Mon Sep 17 00:00:00 2001 From: Casper Verhaar Date: Mon, 31 May 2021 14:24:04 +0200 Subject: [PATCH] Replace feedback button with command palette button in dropdown (#10171) --- .../Resources/en-US/Resources.resw | 10 ++--- src/cascadia/TerminalApp/TerminalPage.cpp | 39 ++++++++++--------- src/cascadia/TerminalApp/TerminalPage.h | 2 +- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw index 27b1460a9853..d4b7f7e23e04 100644 --- a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw @@ -165,16 +165,9 @@ Failed to reload settings - - https://go.microsoft.com/fwlink/?linkid=2125419 - {Locked}This is a FWLink, so it will be localized with the fwlink tool - About - - Feedback - Settings @@ -634,4 +627,7 @@ Restore Down + + Command Palette + \ No newline at end of file diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 18afb5962a2e..9d498fc21bed 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -553,7 +553,7 @@ namespace winrt::TerminalApp::implementation // attaches it to the button. Populates the flyout with one entry per // Profile, displaying the profile's name. Clicking each flyout item will // open a new tab with that profile. - // Below the profiles are the static menu items: settings, feedback + // Below the profiles are the static menu items: settings, command palette void TerminalPage::_CreateNewTabFlyout() { auto newTabFlyout = WUX::Controls::MenuFlyout{}; @@ -703,17 +703,23 @@ namespace winrt::TerminalApp::implementation _SetAcceleratorForMenuItem(settingsItem, settingsKeyChord); } - // Create the feedback button. - auto feedbackFlyout = WUX::Controls::MenuFlyoutItem{}; - feedbackFlyout.Text(RS_(L"FeedbackMenuItem")); + // Create the command palette button. + auto commandPaletteFlyout = WUX::Controls::MenuFlyoutItem{}; + commandPaletteFlyout.Text(RS_(L"CommandPaletteMenuItem")); - WUX::Controls::FontIcon feedbackIcon{}; - feedbackIcon.Glyph(L"\xE939"); - feedbackIcon.FontFamily(Media::FontFamily{ L"Segoe MDL2 Assets" }); - feedbackFlyout.Icon(feedbackIcon); + WUX::Controls::FontIcon commandPaletteIcon{}; + commandPaletteIcon.Glyph(L"\xE945"); + commandPaletteIcon.FontFamily(Media::FontFamily{ L"Segoe MDL2 Assets" }); + commandPaletteFlyout.Icon(commandPaletteIcon); - feedbackFlyout.Click({ this, &TerminalPage::_FeedbackButtonOnClick }); - newTabFlyout.Items().Append(feedbackFlyout); + commandPaletteFlyout.Click({ this, &TerminalPage::_CommandPaletteButtonOnClick }); + newTabFlyout.Items().Append(commandPaletteFlyout); + + const auto commandPaletteKeyChord{ actionMap.GetKeyBindingForAction(ShortcutAction::ToggleCommandPalette) }; + if (commandPaletteKeyChord) + { + _SetAcceleratorForMenuItem(commandPaletteFlyout, commandPaletteKeyChord); + } } // Create the about button. @@ -884,15 +890,12 @@ namespace winrt::TerminalApp::implementation } // Method Description: - // - Called when the feedback button is clicked. Launches github in your - // default browser, navigated to the "issues" page of the Terminal repo. - void TerminalPage::_FeedbackButtonOnClick(const IInspectable&, - const RoutedEventArgs&) + // - Called when the command palette button is clicked. Opens the command palette. + void TerminalPage::_CommandPaletteButtonOnClick(const IInspectable&, + const RoutedEventArgs&) { - const auto feedbackUriValue = RS_(L"FeedbackUriValue"); - winrt::Windows::Foundation::Uri feedbackUri{ feedbackUriValue }; - - winrt::Windows::System::Launcher::LaunchUriAsync(feedbackUri); + CommandPalette().EnableCommandPaletteMode(CommandPaletteLaunchMode::Action); + CommandPalette().Visibility(Visibility::Visible); } // Method Description: diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index 9de1ded9b74a..500572dd05d2 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -196,7 +196,7 @@ namespace winrt::TerminalApp::implementation bool _displayingCloseDialog{ false }; void _SettingsButtonOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs); - void _FeedbackButtonOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs); + void _CommandPaletteButtonOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs); void _AboutButtonOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs); void _ThirdPartyNoticesOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);