-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
RichCommands: Switch tabs command #11916
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
Merged
yaira2
merged 7 commits into
files-community:main
from
ferrariofilippo:RichCommand_Swap_Tab
Mar 31, 2023
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9ae17b6
RichCommands: More tabs commands
ferrariofilippo 8f781c7
Merge branch 'main' into RichCommand_Swap_Tab
ferrariofilippo 37b8d70
Requested Changes & Close current tab
ferrariofilippo a59b251
Update src/Files.App/Actions/Navigation/CloseSelectedTabAction.cs
ferrariofilippo c17d56c
Update src/Files.App/Actions/Navigation/CloseSelectedTabAction.cs
ferrariofilippo ed790a1
Update src/Files.App/Actions/Navigation/PreviousTabAction.cs
ferrariofilippo 2d12d03
Merge branch 'main' into RichCommand_Swap_Tab
ferrariofilippo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/Files.App/Actions/Navigation/CloseSelectedTabAction.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.Extensions; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class CloseSelectedTabAction : ObservableObject, IAction | ||
{ | ||
private readonly IMultitaskingContext context = Ioc.Default.GetRequiredService<IMultitaskingContext>(); | ||
|
||
public string Label { get; } = "CloseTab".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "TODO: Need to be described."; | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.W, VirtualKeyModifiers.Control); | ||
|
||
public HotKey SecondHotKey { get; } = new(VirtualKey.F4, VirtualKeyModifiers.Control); | ||
|
||
public RichGlyph Glyph { get; } = new(); | ||
|
||
public bool IsExecutable => | ||
context.Control is not null && | ||
context.TabCount > 0 && | ||
context.CurrentTabItem is not null; | ||
|
||
public CloseSelectedTabAction() | ||
{ | ||
context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
context.Control!.CloseTab(context.CurrentTabItem); | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
switch (e.PropertyName) | ||
{ | ||
case nameof(IMultitaskingContext.CurrentTabItem): | ||
case nameof(IMultitaskingContext.Control): | ||
case nameof(IMultitaskingContext.TabCount): | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.Extensions; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class NextTabAction : ObservableObject, IAction | ||
{ | ||
private readonly IMultitaskingContext multitaskingContext = Ioc.Default.GetRequiredService<IMultitaskingContext>(); | ||
|
||
public string Label { get; } = "NextTab".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "TODO: Need to be described."; | ||
|
||
public bool IsExecutable => multitaskingContext.TabCount > 1; | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.Tab, VirtualKeyModifiers.Control); | ||
|
||
public NextTabAction() | ||
{ | ||
multitaskingContext.PropertyChanged += MultitaskingContext_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
App.AppModel.TabStripSelectedIndex = (App.AppModel.TabStripSelectedIndex + 1) % multitaskingContext.TabCount; | ||
return Task.CompletedTask; | ||
} | ||
|
||
private void MultitaskingContext_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName == nameof(IMultitaskingContext.TabCount)) | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
using Files.App.Extensions; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Windows.System; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class PreviousTabAction : ObservableObject, IAction | ||
{ | ||
private readonly IMultitaskingContext multitaskingContext = Ioc.Default.GetRequiredService<IMultitaskingContext>(); | ||
|
||
public string Label { get; } = "PreviousTab".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "TODO: Need to be described."; | ||
|
||
public bool IsExecutable => multitaskingContext.TabCount > 1; | ||
|
||
public HotKey HotKey { get; } = new(VirtualKey.Tab, VirtualKeyModifiers.Control | VirtualKeyModifiers.Shift); | ||
|
||
public PreviousTabAction() | ||
{ | ||
multitaskingContext.PropertyChanged += MultitaskingContext_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
if (App.AppModel.TabStripSelectedIndex is 0) | ||
App.AppModel.TabStripSelectedIndex = multitaskingContext.TabCount - 1; | ||
else | ||
App.AppModel.TabStripSelectedIndex--; | ||
|
||
return Task.CompletedTask; | ||
ferrariofilippo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
private void MultitaskingContext_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName == nameof(IMultitaskingContext.TabCount)) | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.