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

Dialogue to show all keyboard shortcuts #5849

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
36 changes: 36 additions & 0 deletions src/cascadia/TerminalApp/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,40 @@
<value>Command Prompt</value>
<comment>This is the name of "Command Prompt", as localized in Windows. The localization here should match the one in the Windows product for "Command Prompt"</comment>
</data>
<data name="ShortcutsDialog.CloseButtonText" xml:space="preserve">
<value>OK</value>
<comment>Close Button Text </comment>
</data>
<data name="ShortcutsDialog.Title" xml:space="preserve">
<value>Defult Keybindings</value>
<comment></comment>
</data>
<data name="ShortcutsDialog_ClosePaneLabel.Text" xml:space="preserve">
<value>Close Pane:</value>
<comment></comment>
</data>
<data name="ShortcutsDialog_CopyLabel.Text" xml:space="preserve">
<value>Copy:</value>
<comment></comment>
</data>
<data name="ShortcutsDialog_FindLabel.Text" xml:space="preserve">
<value>Find:</value>
<comment></comment>
</data>
<data name="ShortcutsDialog_PasteLabel.Text" xml:space="preserve">
<value>Paste:</value>
<comment></comment>
</data>
<data name="ShortcutsDialog_ResizePaneLabel.Text" xml:space="preserve">
<value>Resize Pane:</value>
<comment></comment>
</data>
<data name="ShortcutsDialog_SplitPaneLabel.Text" xml:space="preserve">
<value>Split Pane:</value>
<comment></comment>
</data>
<data name="ShortcutsMenuItem" xml:space="preserve">
<value>Keybindings</value>
<comment></comment>
</data>
</root>
28 changes: 28 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ namespace winrt::TerminalApp::implementation
_showDialogHandlers(*this, FindName(L"AboutDialog").try_as<WUX::Controls::ContentDialog>());
}


// Method Description:
// - Show a dialog with Shortcuts information. Displays the app's defult keybindings
Chips1234 marked this conversation as resolved.
Show resolved Hide resolved
void TerminalPage::_ShowShortcutsDialog()
{
_showDialogHandlers(*this, FindName(L"ShortcutsDialog").try_as<WUX::Controls::ContentDialog>());
}

winrt::hstring TerminalPage::ApplicationDisplayName()
{
if (const auto appLogic{ implementation::AppLogic::Current() })
Expand Down Expand Up @@ -381,6 +389,13 @@ namespace winrt::TerminalApp::implementation
{
_SetAcceleratorForMenuItem(settingsItem, settingsKeyChord);
}

// Create the shortcuts button.
auto shortcutsItem = WUX::Controls::MenuFlyoutItem{};
shortcutsItem.Text(RS_(L"ShortcutsMenuItem"));

shortcutsItem.Click({ this, &TerminalPage::_ShortcutsButtonOnClick });
newTabFlyout.Items().Append(shortcutsItem);

// Create the feedback button.
auto feedbackFlyout = WUX::Controls::MenuFlyoutItem{};
Expand Down Expand Up @@ -649,6 +664,19 @@ namespace winrt::TerminalApp::implementation
_LaunchSettings(altPressed);
}

// Method Description:
// - Called when the shortcuts button is clicked. See _ShowShortcutsDialog for more info.
// Arguments:
// - <unused>
// Return Value:
// - <none>
void TerminalPage::_ShortcutsButtonOnClick(const IInspectable&,
const RoutedEventArgs&)
{
_ShowShortcutsDialog();
}


// Method Description:
// - Called when the feedback button is clicked. Launches github in your
// default browser, navigated to the "issues" page of the Terminal repo.
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ namespace winrt::TerminalApp::implementation
winrt::fire_and_forget _ProcessStartupActions();

void _ShowAboutDialog();
void _ShowShortcutsDialog();
void _ShowCloseWarningDialog();

void _CreateNewTabFlyout();
Expand All @@ -106,6 +107,7 @@ namespace winrt::TerminalApp::implementation
winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection _CreateConnectionFromSettings(GUID profileGuid, winrt::Microsoft::Terminal::Settings::TerminalSettings settings);

void _SettingsButtonOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
void _ShortcutsButtonOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
void _FeedbackButtonOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
void _AboutButtonOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
void _CloseWarningPrimaryButtonOnClick(Windows::UI::Xaml::Controls::ContentDialog sender, Windows::UI::Xaml::Controls::ContentDialogButtonClickEventArgs eventArgs);
Expand Down
25 changes: 25 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,30 @@ the MIT License. See LICENSE in the project root for license information. -->
DefaultButton="Primary"
PrimaryButtonClick="_CloseWarningPrimaryButtonOnClick">
</ContentDialog>

<ContentDialog
x:Load="False"
x:Name="ShortcutsDialog"
x:Uid="ShortcutsDialog"
DefaultButton="Close">
<StackPanel Orientation="Horizontal">
<TextBlock IsTextSelectionEnabled="True">
<Run x:Uid="ShortcutsDialog_CopyLabel"/>
<Run Text="Ctrl+C"/> <LineBreak/>
<Run x:Uid="ShortcutsDialog_PasteLabel"/>
<Run Text="Ctrl+V"/> <LineBreak/>
<Run x:Uid="ShortcutsDialog_FindLabel"/>
<Run Text="Ctrl+F"/> <LineBreak/>
<Run x:Uid="ShortcutsDialog_SplitPaneLabel"/>
<Run Text="Alt+Shift+D"/> <LineBreak/>
<Run x:Uid="ShortcutsDialog_ClosePaneLabel"/>
<Run Text="Alt+Shift+W"/> <LineBreak/>
<Run x:Uid="ShortcutsDialog_ResizePaneLabel"/>
<Run Text="Alt+Shift+Up, Alt+Shift+Down, Alt+Shift+Left, Alt+Shift+Right"/> <LineBreak/>
<Run x:Uid="ShortcutsDialog_ChangeFocusLabel"/>
<Run Text="Alt+Up, Alt+Down, Alt+Left, Alt+Right"/> <LineBreak/>
</TextBlock>
</StackPanel>
</ContentDialog>
</Grid>
</Page>