Skip to content

Feature: Show folder details when no item is selected #12549

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
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
107004b
LoadPreview now on argument instead of property
QuaintMako Jun 4, 2023
60c3287
Now displaying the folder we're in when no idea selected
QuaintMako Jun 4, 2023
071cd4c
Revert "LoadPreview now on argument instead of property"
QuaintMako Jun 4, 2023
a1d3af7
Now displaying folder when entering in new folder
QuaintMako Jun 5, 2023
293c44f
Correctly loading the current folder when opening a tab for the first…
QuaintMako Jun 5, 2023
0ac2df6
Injecting ContentPageContextService
QuaintMako Jun 6, 2023
42dd50d
Merge branch 'main' into 6724_ShowFolderWhenNoSelectionPreview
QuaintMako Jun 6, 2023
f6359bd
Update src/Files.App/Views/LayoutModes/BaseLayout.cs
QuaintMako Jun 6, 2023
cbd4eb8
Update src/Files.App/Views/LayoutModes/BaseLayout.cs
yaira2 Jun 8, 2023
97e384e
Update src/Files.App/Views/LayoutModes/BaseLayout.cs
yaira2 Jun 8, 2023
2d52e59
Merge branch 'main' into 6724_ShowFolderWhenNoSelectionPreview
yaira2 Jun 8, 2023
adbc7b3
Update src/Files.App/Views/LayoutModes/BaseLayout.cs
yaira2 Jun 8, 2023
28825ac
Update src/Files.App/Views/LayoutModes/BaseLayout.cs
yaira2 Jun 8, 2023
aeabf74
Merge branch 'main' into 6724_ShowFolderWhenNoSelectionPreview
QuaintMako Jun 8, 2023
929a1c2
Merge branch 'main' into 6724_ShowFolderWhenNoSelectionPreview
yaira2 Jun 8, 2023
fd1e7e8
Merge branch 'main' into 6724_ShowFolderWhenNoSelectionPreview
QuaintMako Jun 9, 2023
4d192a4
Now works for root drives
QuaintMako Jun 9, 2023
d5e7dee
Merge branch 'main' into 6724_ShowFolderWhenNoSelectionPreview
QuaintMako Jun 9, 2023
100dd4c
Now correctly preview the first element when opening new blade
QuaintMako Jun 11, 2023
71b8ade
Merge branch '6724_ShowFolderWhenNoSelectionPreview' of https://githu…
QuaintMako Jun 11, 2023
c77c77d
Merge branch 'main' into 6724_ShowFolderWhenNoSelectionPreview
QuaintMako Jun 11, 2023
0e11c9a
Now correctly display the selected items when using backward navigation
QuaintMako Jun 13, 2023
f2b6390
Merge branch 'main' into 6724_ShowFolderWhenNoSelectionPreview
QuaintMako Jun 13, 2023
2de0a72
Merge branch 'main' into 6724_ShowFolderWhenNoSelectionPreview
QuaintMako Jun 14, 2023
f1464e8
Preview works in column view clicking
QuaintMako Jun 16, 2023
374e5bc
Merge branch '6724_ShowFolderWhenNoSelectionPreview' of https://githu…
QuaintMako Jun 16, 2023
6201603
Update src/Files.App/Views/LayoutModes/BaseLayout.cs
QuaintMako Jun 16, 2023
928cdc2
Merge branch 'main' into 6724_ShowFolderWhenNoSelectionPreview
QuaintMako Jun 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Files.App/Data/Models/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,8 +1340,6 @@ private async Task RapidAddItemsToCollection(string? path, LibraryItem? library
var stopwatch = new Stopwatch();
stopwatch.Start();

await GetDefaultItemIcons(folderSettings.GetIconSize());

if (FtpHelpers.IsFtpPath(path))
{
// Recycle bin and network are enumerated by the fulltrust process
Expand Down Expand Up @@ -1387,6 +1385,8 @@ private async Task RapidAddItemsToCollection(string? path, LibraryItem? library
}
}

await GetDefaultItemIcons(folderSettings.GetIconSize());

if (addFilesCTS.IsCancellationRequested)
{
addFilesCTS = new CancellationTokenSource();
Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ public async Task LoadCardThumbnailAsync()
public sealed partial class DrivesWidget : HomePageWidget, IWidgetItemModel, INotifyPropertyChanged
{
public IUserSettingsService userSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();

private DrivesViewModel drivesViewModel = Ioc.Default.GetRequiredService<DrivesViewModel>();

private NetworkDrivesViewModel networkDrivesViewModel = Ioc.Default.GetRequiredService<NetworkDrivesViewModel>();

public delegate void DrivesWidgetInvokedEventHandler(object sender, DrivesWidgetInvokedEventArgs e);

public event DrivesWidgetInvokedEventHandler DrivesWidgetInvoked;
Expand Down
35 changes: 32 additions & 3 deletions src/Files.App/ViewModels/UserControls/PreviewPaneViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.Contexts;
using Files.App.UserControls.FilePreviews;
using Files.App.ViewModels.Previews;
using Files.Backend.Helpers;
Expand All @@ -19,6 +20,8 @@ public class PreviewPaneViewModel : ObservableObject, IDisposable

private readonly IPreviewPaneSettingsService previewSettingsService;

private readonly IContentPageContext contentPageContextService;

private CancellationTokenSource loadCancellationTokenSource;

private bool isEnabled;
Expand Down Expand Up @@ -68,7 +71,7 @@ public UIElement PreviewPaneContent
set => SetProperty(ref previewPaneContent, value);
}

public PreviewPaneViewModel(IUserSettingsService userSettings, IPreviewPaneSettingsService previewSettings)
public PreviewPaneViewModel(IUserSettingsService userSettings, IPreviewPaneSettingsService previewSettings, IContentPageContext contentPageContextService = null)
{
userSettingsService = userSettings;
previewSettingsService = previewSettings;
Expand All @@ -79,6 +82,8 @@ public PreviewPaneViewModel(IUserSettingsService userSettings, IPreviewPaneSetti

userSettingsService.OnSettingChangedEvent += UserSettingsService_OnSettingChangedEvent;
previewSettingsService.PropertyChanged += PreviewSettingsService_OnPropertyChangedEvent;

this.contentPageContextService = contentPageContextService ?? Ioc.Default.GetRequiredService<IContentPageContext>();
}

private async Task LoadPreviewControlAsync(CancellationToken token, bool downloadItem)
Expand Down Expand Up @@ -279,8 +284,32 @@ public async Task UpdateSelectedItemPreview(bool downloadItem = false)
}
else
{
PreviewPaneContent = null;
PreviewPaneState = PreviewPaneStates.NoItemSelected;
SelectedItem?.FileDetails?.Clear();
var currentFolder = contentPageContextService.Folder;

if (currentFolder is null)
{
PreviewPaneContent = null;
PreviewPaneState = PreviewPaneStates.NoItemSelected;
return;
}

try
{
PreviewPaneState = PreviewPaneStates.LoadingPreview;
loadCancellationTokenSource = new CancellationTokenSource();

SelectedItem = currentFolder;
await LoadPreviewControlAsync(loadCancellationTokenSource.Token, downloadItem);
}
catch (Exception e)
{
Debug.WriteLine(e);
loadCancellationTokenSource?.Cancel();

PreviewPaneContent = null;
PreviewPaneState = PreviewPaneStates.NoPreviewOrDetailsAvailable;
}
}
}

Expand Down
40 changes: 23 additions & 17 deletions src/Files.App/Views/LayoutModes/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,7 @@ internal set
//if (!(value?.All(x => selectedItems?.Contains(x) ?? false) ?? value == selectedItems))
if (value != selectedItems)
{
if (value?.FirstOrDefault() != PreviewPaneViewModel.SelectedItem)
{
// Update preview pane properties
PreviewPaneViewModel.IsItemSelected = value?.Count > 0;
PreviewPaneViewModel.SelectedItem = value?.Count == 1 ? value.First() : null;

// Check if the preview pane is open before updating the model
if (PreviewPaneViewModel.IsEnabled)
{
var isPaneEnabled = ((App.Window.Content as Frame)?.Content as MainPage)?.ShouldPreviewPaneBeActive ?? false;
if (isPaneEnabled)
PreviewPaneViewModel.UpdateSelectedItemPreview();
}
}
UpdatePreviewPaneSelection(value);

selectedItems = value;

Expand Down Expand Up @@ -483,16 +470,17 @@ public void SetSelectedItemsOnNavigation()
navigationArguments.SelectItems is not null &&
navigationArguments.SelectItems.Any())
{
List<ListedItem> liItemsToSelect = new();
List<ListedItem> listedItemsToSelect = new();
foreach (string item in navigationArguments.SelectItems)
liItemsToSelect.Add(ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.Where((li) => li.ItemNameRaw == item).First());
listedtemsToSelect.Add(ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders.Where((li) => li.ItemNameRaw == item).First());

ItemManipulationModel.SetSelectedItems(liItemsToSelect);
ItemManipulationModel.SetSelectedItems(listedtemsToSelect);
ItemManipulationModel.FocusSelectedItems();
}
else if (navigationArguments is not null && navigationArguments.FocusOnNavigation)
{
// Set focus on layout specific file list control
UpdatePreviewPaneSelection(null);
ItemManipulationModel.FocusFileList();
}
}
Expand Down Expand Up @@ -1371,6 +1359,24 @@ await DispatcherQueue.EnqueueOrInvokeAsync(() =>
}
}

protected virtual void UpdatePreviewPaneSelection(List<ListedItem>? value)
{
if (value?.FirstOrDefault() != PreviewPaneViewModel.SelectedItem)
{
// Update preview pane properties
PreviewPaneViewModel.IsItemSelected = value?.Count > 0;
PreviewPaneViewModel.SelectedItem = value?.Count == 1 ? value.First() : null;

// Check if the preview pane is open before updating the model
if (PreviewPaneViewModel.IsEnabled)
{
var isPaneEnabled = ((App.Window.Content as Frame)?.Content as MainPage)?.ShouldPreviewPaneBeActive ?? false;
if (isPaneEnabled)
_ = PreviewPaneViewModel.UpdateSelectedItemPreview();
}
}
}

public class ContextMenuExtensions : DependencyObject
{
public static ItemsControl GetItemsControl(DependencyObject obj)
Expand Down