From 4faf02a4726f20bb5a8503936ae45df91bd1aaee Mon Sep 17 00:00:00 2001 From: Marco Franzen Date: Mon, 24 Apr 2023 21:43:12 +0200 Subject: [PATCH 1/4] explicitly set the tab icon and header for WSL distributions --- src/Files.App/Filesystem/WSLDistroManager.cs | 2 +- src/Files.App/ViewModels/MainPageViewModel.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Files.App/Filesystem/WSLDistroManager.cs b/src/Files.App/Filesystem/WSLDistroManager.cs index da248164378f..905cb6bf23a6 100644 --- a/src/Files.App/Filesystem/WSLDistroManager.cs +++ b/src/Files.App/Filesystem/WSLDistroManager.cs @@ -63,7 +63,7 @@ public async Task UpdateDrivesAsync() } } - public bool TryGetDistro(string path, out WslDistroItem? distro) + public bool TryGetDistro(string path, [NotNullWhen(true)] out WslDistroItem? distro) { var normalizedPath = PathNormalization.NormalizePath(path); distro = Distros.FirstOrDefault(x => normalizedPath.StartsWith(PathNormalization.NormalizePath(x.Path), StringComparison.OrdinalIgnoreCase)); diff --git a/src/Files.App/ViewModels/MainPageViewModel.cs b/src/Files.App/ViewModels/MainPageViewModel.cs index 737f686d3726..f1141262f8d6 100644 --- a/src/Files.App/ViewModels/MainPageViewModel.cs +++ b/src/Files.App/ViewModels/MainPageViewModel.cs @@ -221,6 +221,11 @@ public async Task UpdateTabInfo(TabItem tabItem, object navigationArg) // If localized string is empty use the library name. tabLocationHeader = string.IsNullOrEmpty(libName) ? library.Text : libName; } + else if (App.WSLDistroManager.TryGetDistro(currentPath, out WslDistroItem? wslDistro) && currentPath.Equals(wslDistro.Path)) + { + tabLocationHeader = wslDistro.Text; + iconSource.ImageSource = new Microsoft.UI.Xaml.Media.Imaging.BitmapImage(wslDistro.Logo); + } else { var normalizedCurrentPath = PathNormalization.NormalizePath(currentPath); From 38e80284546fa898b065443656948c259445cbf8 Mon Sep 17 00:00:00 2001 From: Marco Franzen Date: Mon, 24 Apr 2023 21:43:48 +0200 Subject: [PATCH 2/4] explicitly set the tab icon for cloud drives --- src/Files.App/ViewModels/MainPageViewModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Files.App/ViewModels/MainPageViewModel.cs b/src/Files.App/ViewModels/MainPageViewModel.cs index f1141262f8d6..e9e0d5b97a08 100644 --- a/src/Files.App/ViewModels/MainPageViewModel.cs +++ b/src/Files.App/ViewModels/MainPageViewModel.cs @@ -232,6 +232,7 @@ public async Task UpdateTabInfo(TabItem tabItem, object navigationArg) var matchingCloudDrive = App.CloudDrivesManager.Drives.FirstOrDefault(x => normalizedCurrentPath.Equals(PathNormalization.NormalizePath(x.Path), StringComparison.OrdinalIgnoreCase)); if (matchingCloudDrive is not null) { + iconSource.ImageSource = matchingCloudDrive.Icon; tabLocationHeader = matchingCloudDrive.Text; } else if (PathNormalization.NormalizePath(PathNormalization.GetPathRoot(currentPath)) == normalizedCurrentPath) // If path is a drive's root From d407b25b4e8ac78b33f9d22312ef78b5a8a6384d Mon Sep 17 00:00:00 2001 From: Marco Franzen Date: Mon, 24 Apr 2023 21:44:06 +0200 Subject: [PATCH 3/4] removed unused usings --- src/Files.App/Filesystem/Cloud/CloudDrivesManager.cs | 7 ------- src/Files.App/Filesystem/WSLDistroManager.cs | 6 +----- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/Files.App/Filesystem/Cloud/CloudDrivesManager.cs b/src/Files.App/Filesystem/Cloud/CloudDrivesManager.cs index e1d204cd668f..c8db4410cdf1 100644 --- a/src/Files.App/Filesystem/Cloud/CloudDrivesManager.cs +++ b/src/Files.App/Filesystem/Cloud/CloudDrivesManager.cs @@ -1,18 +1,11 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. -using CommunityToolkit.Mvvm.DependencyInjection; using CommunityToolkit.WinUI; using Files.App.DataModels.NavigationControlItems; -using Files.App.Helpers; -using Files.Shared; using Files.Shared.Cloud; using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; using System.Collections.Specialized; -using System.Linq; -using System.Threading.Tasks; using Windows.Storage; namespace Files.App.Filesystem.Cloud diff --git a/src/Files.App/Filesystem/WSLDistroManager.cs b/src/Files.App/Filesystem/WSLDistroManager.cs index 905cb6bf23a6..f4d56d473298 100644 --- a/src/Files.App/Filesystem/WSLDistroManager.cs +++ b/src/Files.App/Filesystem/WSLDistroManager.cs @@ -2,12 +2,8 @@ // Licensed under the MIT License. See the LICENSE. using Files.App.DataModels.NavigationControlItems; -using Files.App.Helpers; -using System; -using System.Collections.Generic; using System.Collections.Specialized; -using System.Linq; -using System.Threading.Tasks; +using System.Diagnostics.CodeAnalysis; using Windows.Storage; using static Files.App.Constants; From 865f79a504e206009aa66079469d84e69c3c6458 Mon Sep 17 00:00:00 2001 From: Marco Franzen Date: Mon, 1 May 2023 11:49:36 +0200 Subject: [PATCH 4/4] include namespace --- src/Files.App/ViewModels/MainPageViewModel.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Files.App/ViewModels/MainPageViewModel.cs b/src/Files.App/ViewModels/MainPageViewModel.cs index 3ca4cec3c3c6..95cf866eec8e 100644 --- a/src/Files.App/ViewModels/MainPageViewModel.cs +++ b/src/Files.App/ViewModels/MainPageViewModel.cs @@ -6,7 +6,9 @@ using Files.App.UserControls.MultitaskingControl; using Files.App.Views; using Files.Backend.Services; +using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media.Imaging; using Microsoft.UI.Xaml.Navigation; using System.Windows.Input; using Windows.System; @@ -187,16 +189,16 @@ public async Task UpdateTabInfo(TabItem tabItem, object navigationArg) } } - public async Task<(string tabLocationHeader, Microsoft.UI.Xaml.Controls.IconSource tabIcon, string toolTipText)> GetSelectedTabInfoAsync(string currentPath) + public async Task<(string tabLocationHeader, IconSource tabIcon, string toolTipText)> GetSelectedTabInfoAsync(string currentPath) { string? tabLocationHeader; - var iconSource = new Microsoft.UI.Xaml.Controls.ImageIconSource(); + var iconSource = new ImageIconSource(); string toolTipText = currentPath; if (string.IsNullOrEmpty(currentPath) || currentPath == "Home") { tabLocationHeader = "Home".GetLocalizedResource(); - iconSource.ImageSource = new Microsoft.UI.Xaml.Media.Imaging.BitmapImage(new Uri(Constants.FluentIconsPaths.HomeIcon)); + iconSource.ImageSource = new BitmapImage(new Uri(Constants.FluentIconsPaths.HomeIcon)); } else if (currentPath.Equals(CommonPaths.DesktopPath, StringComparison.OrdinalIgnoreCase)) { @@ -227,7 +229,7 @@ public async Task UpdateTabInfo(TabItem tabItem, object navigationArg) else if (App.WSLDistroManager.TryGetDistro(currentPath, out WslDistroItem? wslDistro) && currentPath.Equals(wslDistro.Path)) { tabLocationHeader = wslDistro.Text; - iconSource.ImageSource = new Microsoft.UI.Xaml.Media.Imaging.BitmapImage(wslDistro.Logo); + iconSource.ImageSource = new BitmapImage(wslDistro.Logo); } else {