Skip to content

Commit 0cd5b3b

Browse files
BlairCurreyBlair Currey
andauthored
Added ctrl+shift+k shortcut to duplicate tab (#7901)
Co-authored-by: Blair Currey <[email protected]>
1 parent 7c3511d commit 0cd5b3b

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

src/Files/UserControls/MultitaskingControl/HorizontalMultitaskingControl.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<MenuFlyoutItem
3838
x:Uid="HorizontalMultitaskingControlDuplicateTab"
3939
Click="{x:Bind vm:MainPageViewModel.DuplicateTabAtIndex}"
40+
KeyboardAcceleratorTextOverride="Ctrl+Shift+K"
4041
Text="Duplicate tab">
4142
<MenuFlyoutItem.Icon>
4243
<FontIcon FontFamily="{StaticResource CustomGlyph}" Glyph="&#xF11B;" />

src/Files/ViewModels/MainPageViewModel.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ public TabItem SelectedTabItem
4949

5050
public ICommand AddNewInstanceAcceleratorCommand { get; private set; }
5151

52+
public ICommand ReopenClosedTabAcceleratorCommand { get; private set; }
53+
5254
public MainPageViewModel()
5355
{
5456
// Create commands
5557
NavigateToNumberedTabKeyboardAcceleratorCommand = new RelayCommand<KeyboardAcceleratorInvokedEventArgs>(NavigateToNumberedTabKeyboardAccelerator);
5658
OpenNewWindowAcceleratorCommand = new RelayCommand<KeyboardAcceleratorInvokedEventArgs>(OpenNewWindowAccelerator);
5759
CloseSelectedTabKeyboardAcceleratorCommand = new RelayCommand<KeyboardAcceleratorInvokedEventArgs>(CloseSelectedTabKeyboardAccelerator);
5860
AddNewInstanceAcceleratorCommand = new RelayCommand<KeyboardAcceleratorInvokedEventArgs>(AddNewInstanceAccelerator);
61+
ReopenClosedTabAcceleratorCommand = new RelayCommand<KeyboardAcceleratorInvokedEventArgs>(ReopenClosedTabAccelerator);
5962
}
6063

6164
private void NavigateToNumberedTabKeyboardAccelerator(KeyboardAcceleratorInvokedEventArgs e)
@@ -162,16 +165,13 @@ private void CloseSelectedTabKeyboardAccelerator(KeyboardAcceleratorInvokedEvent
162165

163166
private async void AddNewInstanceAccelerator(KeyboardAcceleratorInvokedEventArgs e)
164167
{
165-
bool shift = e.KeyboardAccelerator.Modifiers.HasFlag(VirtualKeyModifiers.Shift);
168+
await AddNewTabAsync();
169+
e.Handled = true;
170+
}
166171

167-
if (!shift)
168-
{
169-
await AddNewTabAsync();
170-
}
171-
else // ctrl + shift + t, restore recently closed tab
172-
{
173-
((BaseMultitaskingControl)MultitaskingControl).ReopenClosedTab(null, null);
174-
}
172+
private void ReopenClosedTabAccelerator(KeyboardAcceleratorInvokedEventArgs e)
173+
{
174+
((BaseMultitaskingControl)MultitaskingControl).ReopenClosedTab(null, null);
175175
e.Handled = true;
176176
}
177177

src/Files/Views/ColumnShellPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
Key="K"
133133
Invoked="KeyboardAccelerator_Invoked"
134134
IsEnabled="{x:Bind IsCurrentInstance, Mode=OneWay}"
135-
Modifiers="Control" />
135+
Modifiers="Control,Shift" />
136136
</Page.KeyboardAccelerators>
137137
<Grid
138138
x:Name="RootGrid"

src/Files/Views/ColumnShellPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo
719719
UserSettingsService.PreferencesSettingsService.AreHiddenItemsVisible = !UserSettingsService.PreferencesSettingsService.AreHiddenItemsVisible;
720720
break;
721721

722-
case (true, false, false, true, VirtualKey.K): // ctrl + k, duplicate tab
722+
case (true, true, false, true, VirtualKey.K): // ctrl + shift + k, duplicate tab
723723
await NavigationHelpers.OpenPathInNewTab(this.FilesystemViewModel.WorkingDirectory);
724724
break;
725725

src/Files/Views/MainPage.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@
160160
<KeyboardAccelerator Key="T" Modifiers="Control,Shift">
161161
<i:Interaction.Behaviors>
162162
<icore:EventTriggerBehavior EventName="Invoked">
163-
<icore:InvokeCommandAction Command="{x:Bind ViewModel.AddNewInstanceAcceleratorCommand}" />
163+
<icore:InvokeCommandAction Command="{x:Bind ViewModel.ReopenClosedTabAcceleratorCommand}" />
164164
</icore:EventTriggerBehavior>
165165
</i:Interaction.Behaviors>
166166
</KeyboardAccelerator>
167-
<KeyboardAccelerator Key="K" Modifiers="Control">
167+
<KeyboardAccelerator Key="K" Modifiers="Control,Shift">
168168
<i:Interaction.Behaviors>
169169
<icore:EventTriggerBehavior EventName="Invoked">
170170
<icore:InvokeCommandAction Command="{x:Bind ViewModel.AddNewInstanceAcceleratorCommand}" />

src/Files/Views/ModernShellPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
Key="K"
109109
Invoked="KeyboardAccelerator_Invoked"
110110
IsEnabled="{x:Bind IsCurrentInstance, Mode=OneWay}"
111-
Modifiers="Control" />
111+
Modifiers="Control,Shift" />
112112
<KeyboardAccelerator
113113
Key="F2"
114114
Invoked="KeyboardAccelerator_Invoked"

src/Files/Views/ModernShellPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo
776776
UserSettingsService.PreferencesSettingsService.AreHiddenItemsVisible = !UserSettingsService.PreferencesSettingsService.AreHiddenItemsVisible;
777777
break;
778778

779-
case (true, false, false, true, VirtualKey.K): // ctrl + k, duplicate tab
779+
case (true, true, false, true, VirtualKey.K): // ctrl + shift + k, duplicate tab
780780
await NavigationHelpers.OpenPathInNewTab(this.FilesystemViewModel.WorkingDirectory);
781781
break;
782782

0 commit comments

Comments
 (0)