From f7139066505b0b2e4933b7919ec3163d7c4e2725 Mon Sep 17 00:00:00 2001 From: Filippo Ferrario <102259289+ferrariofilippo@users.noreply.github.com> Date: Sat, 23 Nov 2024 23:14:02 +0100 Subject: [PATCH 01/11] Feature: Display drive information in Details Pane --- src/Files.App/Data/Enums/PreviewPaneStates.cs | 7 +- src/Files.App/Data/Items/DriveItem.cs | 23 +++- src/Files.App/UserControls/Pane/InfoPane.xaml | 123 ++++++++++++++++++ .../UserControls/InfoPaneViewModel.cs | 33 ++++- .../Previews/FolderPreviewViewModel.cs | 6 +- 5 files changed, 181 insertions(+), 11 deletions(-) diff --git a/src/Files.App/Data/Enums/PreviewPaneStates.cs b/src/Files.App/Data/Enums/PreviewPaneStates.cs index 36e076f797dd..f17a85256a12 100644 --- a/src/Files.App/Data/Enums/PreviewPaneStates.cs +++ b/src/Files.App/Data/Enums/PreviewPaneStates.cs @@ -31,6 +31,11 @@ public enum PreviewPaneStates /// /// Loading preview status. /// - LoadingPreview + LoadingPreview, + + /// + /// Drive preview and details available status. + /// + DrivePreviewAndDetailsAvailable, } } diff --git a/src/Files.App/Data/Items/DriveItem.cs b/src/Files.App/Data/Items/DriveItem.cs index b624f0c2161b..12f1edf930b8 100644 --- a/src/Files.App/Data/Items/DriveItem.cs +++ b/src/Files.App/Data/Items/DriveItem.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See the LICENSE. using Files.App.Controls; -using Files.App.Storage.Storables; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media.Imaging; @@ -116,15 +115,27 @@ public bool ShowDriveDetails private DriveType type; public DriveType Type { - get => type; set + get => type; + set { type = value; if (value is DriveType.Network or DriveType.CloudDrive) ToolTip = Text; + + OnPropertyChanged(nameof(TypeText)); } } + public string TypeText => string.Format("DriveType{0}", Type).GetLocalizedResource(); + + private string filesystem = string.Empty; + public string Filesystem + { + get => filesystem; + set => SetProperty(ref filesystem, value); + } + private string text; public string Text { @@ -267,7 +278,7 @@ public async Task UpdatePropertiesAsync() { try { - var properties = await Root.Properties.RetrievePropertiesAsync(["System.FreeSpace", "System.Capacity"]) + var properties = await Root.Properties.RetrievePropertiesAsync(["System.FreeSpace", "System.Capacity", "System.Volume.FileSystem"]) .AsTask().WithTimeoutAsync(TimeSpan.FromSeconds(5)); if (properties is not null && properties["System.Capacity"] is not null && properties["System.FreeSpace"] is not null) @@ -287,12 +298,18 @@ public async Task UpdatePropertiesAsync() MaxSpace = SpaceUsed = FreeSpace = ByteSize.FromBytes(0); } + if (properties is not null && properties["System.Volume.FileSystem"] is not null) + Filesystem = (string)properties["System.Volume.FileSystem"]; + else + Filesystem = string.Empty; + OnPropertyChanged(nameof(ShowDriveDetails)); } catch (Exception) { SpaceText = "Unknown".GetLocalizedResource(); MaxSpace = SpaceUsed = FreeSpace = ByteSize.FromBytes(0); + Filesystem = string.Empty; OnPropertyChanged(nameof(ShowDriveDetails)); } diff --git a/src/Files.App/UserControls/Pane/InfoPane.xaml b/src/Files.App/UserControls/Pane/InfoPane.xaml index b06eee2debbd..972b7b542807 100644 --- a/src/Files.App/UserControls/Pane/InfoPane.xaml +++ b/src/Files.App/UserControls/Pane/InfoPane.xaml @@ -238,6 +238,112 @@ TextAlignment="Center" TextWrapping="Wrap" Visibility="Collapsed" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs b/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs index 22f93fe1a699..d2a802a1b5ff 100644 --- a/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs @@ -14,8 +14,8 @@ namespace Files.App.ViewModels.UserControls public sealed class InfoPaneViewModel : ObservableObject, IDisposable { private IInfoPaneSettingsService infoPaneSettingsService { get; } = Ioc.Default.GetRequiredService(); - private IGeneralSettingsService generalSettingsService { get; } = Ioc.Default.GetRequiredService(); private IContentPageContext contentPageContext { get; } = Ioc.Default.GetRequiredService(); + private DrivesViewModel drivesViewModel { get; } = Ioc.Default.GetRequiredService(); private CancellationTokenSource loadCancellationTokenSource; @@ -50,6 +50,7 @@ public ListedItem? SelectedItem if (SetProperty(ref selectedItem, value)) { UpdateTagsItems(); + SetDriveItem(); OnPropertyChanged(nameof(LoadTagsList)); if (value is not null) @@ -58,6 +59,19 @@ public ListedItem? SelectedItem } } + /// + /// Current selected drive if any. + /// + private DriveItem? selectedDriveItem; + public DriveItem? SelectedDriveItem + { + get => selectedDriveItem; + set + { + SetProperty(ref selectedDriveItem, value); + } + } + /// /// Enum indicating whether to show the details or preview tab /// @@ -177,7 +191,7 @@ private async Task LoadPreviewControlAsync(CancellationToken token, bool downloa if (control is not null) { PreviewPaneContent = control; - PreviewPaneState = PreviewPaneStates.PreviewAndDetailsAvailable; + PreviewPaneState = SelectedItem.IsDriveRoot ? PreviewPaneStates.DrivePreviewAndDetailsAvailable : PreviewPaneStates.PreviewAndDetailsAvailable; return; } @@ -190,7 +204,7 @@ private async Task LoadPreviewControlAsync(CancellationToken token, bool downloa return; PreviewPaneContent = control; - PreviewPaneState = PreviewPaneStates.PreviewAndDetailsAvailable; + PreviewPaneState = SelectedItem.IsDriveRoot ? PreviewPaneStates.DrivePreviewAndDetailsAvailable : PreviewPaneStates.PreviewAndDetailsAvailable; } private async Task GetBuiltInPreviewControlAsync(ListedItem item, bool downloadItem) @@ -449,7 +463,7 @@ private async Task LoadBasicPreviewAsync() await basicModel.LoadAsync(); PreviewPaneContent = new BasicPreview(basicModel); - PreviewPaneState = PreviewPaneStates.PreviewAndDetailsAvailable; + PreviewPaneState = SelectedItem.IsDriveRoot ? PreviewPaneStates.DrivePreviewAndDetailsAvailable : PreviewPaneStates.PreviewAndDetailsAvailable; } catch (Exception ex) { @@ -474,6 +488,17 @@ private void UpdateTagsItems() Items.Add(new FlyoutItem(new Files.App.UserControls.Menus.FileTagsContextMenu(new List() { SelectedItem }))); } + private void SetDriveItem() + { + if (!(selectedItem?.IsDriveRoot ?? false)) + { + selectedDriveItem = null; + return; + } + + SelectedDriveItem = drivesViewModel.Drives.FirstOrDefault(drive => drive.Path == selectedItem.ItemPath) as DriveItem; + } + public void Dispose() { diff --git a/src/Files.App/ViewModels/UserControls/Previews/FolderPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/FolderPreviewViewModel.cs index f826df056e35..2d23dc5d98e9 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/FolderPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/FolderPreviewViewModel.cs @@ -4,14 +4,11 @@ using Files.App.ViewModels.Properties; using Microsoft.UI.Xaml.Media.Imaging; using System.IO; -using Windows.Storage.FileProperties; namespace Files.App.ViewModels.Previews { public sealed class FolderPreviewViewModel { - private static readonly IDateTimeFormatter dateTimeFormatter = Ioc.Default.GetRequiredService(); - public ListedItem Item { get; } public BitmapImage Thumbnail { get; set; } = new(); @@ -39,6 +36,9 @@ private async Task LoadPreviewAndDetailsAsync() if (result is not null) Thumbnail = await result.ToBitmapAsync(); + if (Item.IsDriveRoot) + return; + var info = await Folder.GetBasicPropertiesAsync(); Item.FileDetails = From a95085eaa2ea2794b6c99b62e7a28a5231615e7e Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 24 Nov 2024 10:39:25 -0500 Subject: [PATCH 02/11] Fix font weight --- src/Files.App/UserControls/Pane/InfoPane.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/UserControls/Pane/InfoPane.xaml b/src/Files.App/UserControls/Pane/InfoPane.xaml index 972b7b542807..89c28caa777f 100644 --- a/src/Files.App/UserControls/Pane/InfoPane.xaml +++ b/src/Files.App/UserControls/Pane/InfoPane.xaml @@ -314,6 +314,7 @@ x:Name="TotalDriveSpaceTextBox" Grid.Column="2" FontSize="14" + FontWeight="Bold" IsTextSelectionEnabled="True" Style="{StaticResource Local.FileDetailsHeaderTextBlockStyle}" Text="{x:Bind ViewModel.SelectedDriveItem.MaxSpaceText, Mode=OneWay}" @@ -325,7 +326,6 @@ HorizontalAlignment="Left" FontFamily="{ThemeResource ContentControlThemeFontFamily}" FontSize="14" - FontWeight="Bold" IsTextSelectionEnabled="True" Text="Available" TextAlignment="Left" From ffd8d65b9e6047026d0f398af692873d319f5156 Mon Sep 17 00:00:00 2001 From: Filippo Ferrario <102259289+ferrariofilippo@users.noreply.github.com> Date: Sun, 24 Nov 2024 17:14:41 +0100 Subject: [PATCH 03/11] Naming & Comments --- src/Files.App/Data/Enums/PreviewPaneStates.cs | 2 +- src/Files.App/UserControls/Pane/InfoPane.xaml | 4 ++-- src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs | 4 ++-- .../UserControls/Previews/FolderPreviewViewModel.cs | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Files.App/Data/Enums/PreviewPaneStates.cs b/src/Files.App/Data/Enums/PreviewPaneStates.cs index f17a85256a12..35d9c8cc1aef 100644 --- a/src/Files.App/Data/Enums/PreviewPaneStates.cs +++ b/src/Files.App/Data/Enums/PreviewPaneStates.cs @@ -36,6 +36,6 @@ public enum PreviewPaneStates /// /// Drive preview and details available status. /// - DrivePreviewAndDetailsAvailable, + DriveStorageDetailsAvailable, } } diff --git a/src/Files.App/UserControls/Pane/InfoPane.xaml b/src/Files.App/UserControls/Pane/InfoPane.xaml index 89c28caa777f..981752c0f345 100644 --- a/src/Files.App/UserControls/Pane/InfoPane.xaml +++ b/src/Files.App/UserControls/Pane/InfoPane.xaml @@ -302,7 +302,7 @@ - + diff --git a/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs b/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs index d2a802a1b5ff..8e683fa1d8b9 100644 --- a/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs @@ -191,7 +191,7 @@ private async Task LoadPreviewControlAsync(CancellationToken token, bool downloa if (control is not null) { PreviewPaneContent = control; - PreviewPaneState = SelectedItem.IsDriveRoot ? PreviewPaneStates.DrivePreviewAndDetailsAvailable : PreviewPaneStates.PreviewAndDetailsAvailable; + PreviewPaneState = SelectedItem.IsDriveRoot ? PreviewPaneStates.DriveStorageDetailsAvailable : PreviewPaneStates.PreviewAndDetailsAvailable; return; } @@ -204,7 +204,7 @@ private async Task LoadPreviewControlAsync(CancellationToken token, bool downloa return; PreviewPaneContent = control; - PreviewPaneState = SelectedItem.IsDriveRoot ? PreviewPaneStates.DrivePreviewAndDetailsAvailable : PreviewPaneStates.PreviewAndDetailsAvailable; + PreviewPaneState = SelectedItem.IsDriveRoot ? PreviewPaneStates.DriveStorageDetailsAvailable : PreviewPaneStates.PreviewAndDetailsAvailable; } private async Task GetBuiltInPreviewControlAsync(ListedItem item, bool downloadItem) diff --git a/src/Files.App/ViewModels/UserControls/Previews/FolderPreviewViewModel.cs b/src/Files.App/ViewModels/UserControls/Previews/FolderPreviewViewModel.cs index 2d23dc5d98e9..45f9421308d7 100644 --- a/src/Files.App/ViewModels/UserControls/Previews/FolderPreviewViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/Previews/FolderPreviewViewModel.cs @@ -36,6 +36,9 @@ private async Task LoadPreviewAndDetailsAsync() if (result is not null) Thumbnail = await result.ToBitmapAsync(); + // If the selected item is the root of a drive (e.g. "C:\") + // we do not need to load the properties below, since they will not be shown. + // Drive properties will be obtained through the DrivesViewModel service. if (Item.IsDriveRoot) return; From 6ba3b4bf5e928f3137f62106ff505cf6adabc285 Mon Sep 17 00:00:00 2001 From: Filippo Ferrario <102259289+ferrariofilippo@users.noreply.github.com> Date: Sun, 24 Nov 2024 21:36:57 +0100 Subject: [PATCH 04/11] Use single TextBlock --- src/Files.App/UserControls/Pane/InfoPane.xaml | 37 ++++++------------- .../UserControls/InfoPaneViewModel.cs | 2 +- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/Files.App/UserControls/Pane/InfoPane.xaml b/src/Files.App/UserControls/Pane/InfoPane.xaml index 981752c0f345..a123727a53bd 100644 --- a/src/Files.App/UserControls/Pane/InfoPane.xaml +++ b/src/Files.App/UserControls/Pane/InfoPane.xaml @@ -240,33 +240,20 @@ Visibility="Collapsed" /> - - - - + + + + - + diff --git a/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs b/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs index 8e683fa1d8b9..8dfbc9490970 100644 --- a/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/InfoPaneViewModel.cs @@ -463,7 +463,7 @@ private async Task LoadBasicPreviewAsync() await basicModel.LoadAsync(); PreviewPaneContent = new BasicPreview(basicModel); - PreviewPaneState = SelectedItem.IsDriveRoot ? PreviewPaneStates.DrivePreviewAndDetailsAvailable : PreviewPaneStates.PreviewAndDetailsAvailable; + PreviewPaneState = SelectedItem.IsDriveRoot ? PreviewPaneStates.DriveStorageDetailsAvailable : PreviewPaneStates.PreviewAndDetailsAvailable; } catch (Exception ex) { From c7b400dd1712c007e6549042e17fc8dec7f62863 Mon Sep 17 00:00:00 2001 From: Filippo Ferrario <102259289+ferrariofilippo@users.noreply.github.com> Date: Mon, 25 Nov 2024 09:49:48 +0100 Subject: [PATCH 05/11] Names --- src/Files.App/UserControls/Pane/InfoPane.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Files.App/UserControls/Pane/InfoPane.xaml b/src/Files.App/UserControls/Pane/InfoPane.xaml index a123727a53bd..52163b4e51f9 100644 --- a/src/Files.App/UserControls/Pane/InfoPane.xaml +++ b/src/Files.App/UserControls/Pane/InfoPane.xaml @@ -256,7 +256,7 @@ Date: Mon, 25 Nov 2024 09:54:30 +0100 Subject: [PATCH 06/11] Missing name --- src/Files.App/UserControls/Pane/InfoPane.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/UserControls/Pane/InfoPane.xaml b/src/Files.App/UserControls/Pane/InfoPane.xaml index 52163b4e51f9..f2e4ce536ef9 100644 --- a/src/Files.App/UserControls/Pane/InfoPane.xaml +++ b/src/Files.App/UserControls/Pane/InfoPane.xaml @@ -572,7 +572,7 @@ - + From 7a664f86ab78f529a009b54bab40b2b4e1b367a0 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:15:25 -0500 Subject: [PATCH 07/11] Use StorageBar --- src/Files.App.Controls/Storage/StorageBar/StorageBar.xaml | 1 - src/Files.App/UserControls/Pane/InfoPane.xaml | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Files.App.Controls/Storage/StorageBar/StorageBar.xaml b/src/Files.App.Controls/Storage/StorageBar/StorageBar.xaml index 2ec064794152..2b870e823380 100644 --- a/src/Files.App.Controls/Storage/StorageBar/StorageBar.xaml +++ b/src/Files.App.Controls/Storage/StorageBar/StorageBar.xaml @@ -16,7 +16,6 @@ - diff --git a/src/Files.App/UserControls/Pane/InfoPane.xaml b/src/Files.App/UserControls/Pane/InfoPane.xaml index f2e4ce536ef9..2f492270f523 100644 --- a/src/Files.App/UserControls/Pane/InfoPane.xaml +++ b/src/Files.App/UserControls/Pane/InfoPane.xaml @@ -267,10 +267,11 @@ TextAlignment="Center" TextWrapping="Wrap" Visibility="Collapsed" /> - Date: Mon, 25 Nov 2024 14:04:42 -0500 Subject: [PATCH 08/11] Remove run --- src/Files.App/UserControls/Pane/InfoPane.xaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Files.App/UserControls/Pane/InfoPane.xaml b/src/Files.App/UserControls/Pane/InfoPane.xaml index 2f492270f523..b1bbd45c7fed 100644 --- a/src/Files.App/UserControls/Pane/InfoPane.xaml +++ b/src/Files.App/UserControls/Pane/InfoPane.xaml @@ -251,7 +251,6 @@ TextWrapping="Wrap" Visibility="Collapsed"> - @@ -271,7 +270,7 @@ x:Name="DriveSpaceProgressBar" Margin="8,8,8,8" HorizontalAlignment="Stretch" - TrackBarHeight="6" + TrackBarHeight="4" Visibility="Collapsed" Value="{x:Bind ViewModel.SelectedDriveItem.PercentageUsed, Mode=OneWay}" /> Date: Tue, 26 Nov 2024 11:18:10 -0500 Subject: [PATCH 09/11] Increase ValueBarHeight --- src/Files.App/UserControls/Pane/InfoPane.xaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Files.App/UserControls/Pane/InfoPane.xaml b/src/Files.App/UserControls/Pane/InfoPane.xaml index b1bbd45c7fed..6d09e9ba15d3 100644 --- a/src/Files.App/UserControls/Pane/InfoPane.xaml +++ b/src/Files.App/UserControls/Pane/InfoPane.xaml @@ -271,6 +271,7 @@ Margin="8,8,8,8" HorizontalAlignment="Stretch" TrackBarHeight="4" + ValueBarHeight="8" Visibility="Collapsed" Value="{x:Bind ViewModel.SelectedDriveItem.PercentageUsed, Mode=OneWay}" /> Date: Tue, 26 Nov 2024 20:52:44 +0100 Subject: [PATCH 10/11] Use styles & strings --- src/Files.App/Strings/en-US/Resources.resw | 6 +++++ src/Files.App/UserControls/Pane/InfoPane.xaml | 24 +++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw index f4ddb611460d..47eaba2151d1 100644 --- a/src/Files.App/Strings/en-US/Resources.resw +++ b/src/Files.App/Strings/en-US/Resources.resw @@ -4004,4 +4004,10 @@ Manage tags + + Available + + + Total + \ No newline at end of file diff --git a/src/Files.App/UserControls/Pane/InfoPane.xaml b/src/Files.App/UserControls/Pane/InfoPane.xaml index 6d09e9ba15d3..0fd7ff657489 100644 --- a/src/Files.App/UserControls/Pane/InfoPane.xaml +++ b/src/Files.App/UserControls/Pane/InfoPane.xaml @@ -244,9 +244,8 @@ x:Name="DriveFormatAndTypeTextBlock" Margin="12,12,12,24" HorizontalAlignment="Center" - FontFamily="{ThemeResource ContentControlThemeFontFamily}" - FontSize="14" IsTextSelectionEnabled="True" + Style="{ThemeResource BodyTextBlockStyle}" TextAlignment="Center" TextWrapping="Wrap" Visibility="Collapsed"> @@ -257,11 +256,9 @@ @@ -312,10 +308,9 @@ x:Name="AvailableSpaceLabel" Grid.Row="1" HorizontalAlignment="Left" - FontFamily="{ThemeResource ContentControlThemeFontFamily}" - FontSize="14" IsTextSelectionEnabled="True" - Text="Available" + Style="{ThemeResource BodyTextBlockStyle}" + Text="{helpers:ResourceString Name=Available}" TextAlignment="Left" TextWrapping="Wrap" /> From 97c797f8503843ab1c7227179f81e6da8cf31288 Mon Sep 17 00:00:00 2001 From: Filippo Ferrario <102259289+ferrariofilippo@users.noreply.github.com> Date: Tue, 26 Nov 2024 21:20:11 +0100 Subject: [PATCH 11/11] Remove text selection --- src/Files.App/UserControls/Pane/InfoPane.xaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Files.App/UserControls/Pane/InfoPane.xaml b/src/Files.App/UserControls/Pane/InfoPane.xaml index 0fd7ff657489..84210302b8a6 100644 --- a/src/Files.App/UserControls/Pane/InfoPane.xaml +++ b/src/Files.App/UserControls/Pane/InfoPane.xaml @@ -308,7 +308,6 @@ x:Name="AvailableSpaceLabel" Grid.Row="1" HorizontalAlignment="Left" - IsTextSelectionEnabled="True" Style="{ThemeResource BodyTextBlockStyle}" Text="{helpers:ResourceString Name=Available}" TextAlignment="Left" @@ -319,7 +318,6 @@ Grid.Column="2" HorizontalAlignment="Right" Foreground="{ThemeResource TextFillColorTertiaryBrush}" - IsTextSelectionEnabled="True" Style="{ThemeResource BodyTextBlockStyle}" Text="{helpers:ResourceString Name=Total}" TextAlignment="Right"