|
5 | 5 | using Microsoft.UI.Xaml.Controls; |
6 | 6 | using Microsoft.UI.Xaml.Media; |
7 | 7 | using Microsoft.UI.Xaml.Media.Imaging; |
8 | | -using Windows.Storage.Search; |
9 | | -using Microsoft.UI.Xaml.Media; |
| 8 | +using System.IO; |
10 | 9 | using Windows.Storage; |
| 10 | +using Windows.Storage.Search; |
11 | 11 | using Windows.System; |
12 | | -using System.IO; |
13 | 12 |
|
14 | 13 | namespace Files.App.Helpers |
15 | 14 | { |
16 | 15 | public static class NavigationHelpers |
17 | 16 | { |
| 17 | + private static readonly IGeneralSettingsService GeneralSettingsService = Ioc.Default.GetRequiredService<IGeneralSettingsService>(); |
| 18 | + |
18 | 19 | private static readonly IWindowsRecentItemsService WindowsRecentItemsService = Ioc.Default.GetRequiredService<IWindowsRecentItemsService>(); |
19 | 20 | private static MainPageViewModel MainPageViewModel { get; } = Ioc.Default.GetRequiredService<MainPageViewModel>(); |
20 | 21 | private static DrivesViewModel DrivesViewModel { get; } = Ioc.Default.GetRequiredService<DrivesViewModel>(); |
21 | 22 | private static INetworkService NetworkService { get; } = Ioc.Default.GetRequiredService<INetworkService>(); |
22 | 23 |
|
23 | | - public static Task OpenPathInNewTab(string? path, bool focusNewTab) |
| 24 | + /// <summary> |
| 25 | + /// Opens the path in a new tab. |
| 26 | + /// </summary> |
| 27 | + /// <param name="path">The path to open in a new tab.</param> |
| 28 | + /// <param name="switchToNewTab">Indicates whether to switch to the new tab.</param> |
| 29 | + /// <returns></returns> |
| 30 | + public static Task OpenPathInNewTab(string? path, bool switchToNewTab) |
| 31 | + { |
| 32 | + return AddNewTabByPathAsync(typeof(ShellPanesPage), path, switchToNewTab); |
| 33 | + } |
| 34 | + |
| 35 | + /// <summary> |
| 36 | + /// Opens the path in a new tab and automatically switches to the newly |
| 37 | + /// created tab if configured in settings. |
| 38 | + /// </summary> |
| 39 | + /// <param name="path">The path to open in a new tab.</param> |
| 40 | + /// <returns></returns> |
| 41 | + public static Task OpenPathInNewTab(string? path) |
24 | 42 | { |
25 | | - return AddNewTabByPathAsync(typeof(ShellPanesPage), path, focusNewTab); |
| 43 | + return AddNewTabByPathAsync(typeof(ShellPanesPage), path, GeneralSettingsService.AlwaysSwitchToNewlyOpenedTab); |
26 | 44 | } |
27 | 45 |
|
28 | 46 | public static Task AddNewTabAsync() |
29 | 47 | { |
30 | 48 | return AddNewTabByPathAsync(typeof(ShellPanesPage), "Home", true); |
31 | 49 | } |
32 | 50 |
|
33 | | - public static async Task AddNewTabByPathAsync(Type type, string? path, bool focusNewTab, int atIndex = -1) |
| 51 | + public static async Task AddNewTabByPathAsync(Type type, string? path, bool switchToNewTab, int atIndex = -1) |
34 | 52 | { |
35 | 53 | if (string.IsNullOrEmpty(path)) |
36 | 54 | { |
@@ -63,7 +81,7 @@ public static async Task AddNewTabByPathAsync(Type type, string? path, bool focu |
63 | 81 |
|
64 | 82 | MainPageViewModel.AppInstances.Insert(index, tabItem); |
65 | 83 |
|
66 | | - if (focusNewTab) |
| 84 | + if (switchToNewTab) |
67 | 85 | App.AppModel.TabStripSelectedIndex = index; |
68 | 86 | } |
69 | 87 |
|
|
0 commit comments