Skip to content

Commit 9ac9c59

Browse files
gave92gave92
authored andcommitted
Merge branch 'main' of https://github.com/files-community/Files into terminal
2 parents 092560e + 008bb50 commit 9ac9c59

File tree

12 files changed

+50
-25
lines changed

12 files changed

+50
-25
lines changed

src/Files.App/Data/Models/ItemManipulationModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public sealed class ItemManipulationModel
2323

2424
public event EventHandler<ListedItem> ScrollIntoViewInvoked;
2525

26+
public event EventHandler ScrollToTopInvoked;
27+
2628
public event EventHandler SetDragModeForItemsInvoked;
2729

2830
public event EventHandler RefreshItemsOpacityInvoked;
@@ -104,6 +106,11 @@ public void ScrollIntoView(ListedItem item)
104106
ScrollIntoViewInvoked?.Invoke(this, item);
105107
}
106108

109+
public void ScrollToTop()
110+
{
111+
ScrollToTopInvoked?.Invoke(this, EventArgs.Empty);
112+
}
113+
107114
public void SetDragModeForItems()
108115
{
109116
SetDragModeForItemsInvoked?.Invoke(this, EventArgs.Empty);

src/Files.App/MainWindow.xaml.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// Copyright (c) 2024 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using Files.App.UserControls.TabBar;
54
using Microsoft.UI;
65
using Microsoft.UI.Windowing;
7-
using Microsoft.UI.Xaml;
86
using Microsoft.UI.Xaml.Controls;
97
using Microsoft.UI.Xaml.Media.Animation;
108
using Microsoft.UI.Xaml.Navigation;
11-
using System.IO;
12-
using Windows.ApplicationModel;
139
using Windows.ApplicationModel.Activation;
1410
using Windows.Storage;
1511
using WinUIEx;
@@ -207,6 +203,9 @@ public async Task InitializeApplicationAsync(object activatedEventArgs)
207203
AppWindow.Show();
208204
Activate();
209205
}
206+
207+
if (Windows.Win32.PInvoke.IsIconic(new(WindowHandle)))
208+
Instance.Restore(); // Restore window if minimized
210209
}
211210

212211
public Frame EnsureWindowIsInitialized()

src/Files.App/NativeMethods.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ AttachThreadInput
4040
SetWindowPos
4141
SetFocus
4242
SetActiveWindow
43+
IsIconic
4344
CopyFileFromApp
4445
MoveFileFromApp
4546
DeleteFileFromApp

src/Files.App/Services/QuickAccessService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ namespace Files.App.Services
88
{
99
internal sealed class QuickAccessService : IQuickAccessService
1010
{
11-
private readonly static string guid = "::{679f85cb-0220-4080-b29b-5540cc05aab6}";
11+
// Quick access shell folder (::{679f85cb-0220-4080-b29b-5540cc05aab6}) contains recent files
12+
// which are unnecessary for getting pinned folders, so we use frequent places shell folder instead.
13+
private readonly static string guid = "::{3936e9e4-d92c-4eee-a85a-bc16d5ea0819}";
1214

1315
public async Task<IEnumerable<ShellFileItem>> GetPinnedFoldersAsync()
1416
{

src/Files.App/Utils/RecentItem/RecentItems.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ public async Task UpdateRecentFoldersAsync()
109109
/// </summary>
110110
public async Task<List<RecentItem>> ListRecentFilesAsync()
111111
{
112-
return (await Win32Helper.GetShellFolderAsync(QuickAccessGuid, false, true, 0, int.MaxValue)).Enumerate
112+
// Since the maximum number of recent files is 20, we set the count to 20 to avoid loading of unnecessary shell items.
113+
return (await Win32Helper.GetShellFolderAsync(QuickAccessGuid, false, true, 0, 20)).Enumerate
113114
.Where(link => !link.IsFolder)
114115
.Select(link => new RecentItem(link, ShowFileExtensions)).ToList();
115116
}

src/Files.App/Utils/RecentItem/RecentItemsManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public sealed class RecentItemsManager
1111
private static readonly string recentItemsPath = Environment.GetFolderPath(Environment.SpecialFolder.Recent);
1212
private static readonly string automaticDestinationsPath = Path.Combine(recentItemsPath, "AutomaticDestinations");
1313
private const string QuickAccessJumpListFileName = "5f7b5f1e01b83767.automaticDestinations-ms";
14-
private const string QuickAccessGuid = "::{679f85cb-0220-4080-b29b-5540cc05aab6}";
1514
private DateTime quickAccessLastReadTime = DateTime.MinValue;
1615
private FileSystemWatcher? quickAccessJumpListWatcher;
1716

src/Files.App/Utils/Shell/LaunchHelper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ private static async Task<bool> HandleApplicationLaunch(string application, stri
129129

130130
return true;
131131
}
132+
catch (Win32Exception ex) when (ex.NativeErrorCode == 50)
133+
{
134+
// ShellExecute return code 50 (ERROR_NOT_SUPPORTED) for some exes (#15179)
135+
return Win32Helper.RunPowershellCommand($"\"{application}\"", false);
136+
}
132137
catch (Win32Exception)
133138
{
134139
try

src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public BaseGroupableLayoutPage() : base()
4747
protected abstract void ItemManipulationModel_RemoveSelectedItemInvoked(object? sender, ListedItem e);
4848
protected abstract void ItemManipulationModel_FocusSelectedItemsInvoked(object? sender, EventArgs e);
4949
protected abstract void ItemManipulationModel_ScrollIntoViewInvoked(object? sender, ListedItem e);
50+
protected abstract void ItemManipulationModel_ScrollToTopInvoked(object? sender, EventArgs e);
5051
protected abstract void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e);
5152
protected abstract void EndRename(TextBox textBox);
5253

@@ -70,6 +71,7 @@ protected override void HookEvents()
7071
ItemManipulationModel.FocusSelectedItemsInvoked += ItemManipulationModel_FocusSelectedItemsInvoked;
7172
ItemManipulationModel.StartRenameItemInvoked += ItemManipulationModel_StartRenameItemInvoked;
7273
ItemManipulationModel.ScrollIntoViewInvoked += ItemManipulationModel_ScrollIntoViewInvoked;
74+
ItemManipulationModel.ScrollToTopInvoked += ItemManipulationModel_ScrollToTopInvoked;
7375
ItemManipulationModel.RefreshItemThumbnailInvoked += ItemManipulationModel_RefreshItemThumbnail;
7476
ItemManipulationModel.RefreshItemsThumbnailInvoked += ItemManipulationModel_RefreshItemsThumbnail;
7577
}
@@ -88,6 +90,7 @@ protected override void UnhookEvents()
8890
ItemManipulationModel.FocusSelectedItemsInvoked -= ItemManipulationModel_FocusSelectedItemsInvoked;
8991
ItemManipulationModel.StartRenameItemInvoked -= ItemManipulationModel_StartRenameItemInvoked;
9092
ItemManipulationModel.ScrollIntoViewInvoked -= ItemManipulationModel_ScrollIntoViewInvoked;
93+
ItemManipulationModel.ScrollToTopInvoked -= ItemManipulationModel_ScrollToTopInvoked;
9194
ItemManipulationModel.RefreshItemThumbnailInvoked -= ItemManipulationModel_RefreshItemThumbnail;
9295
ItemManipulationModel.RefreshItemsThumbnailInvoked -= ItemManipulationModel_RefreshItemsThumbnail;
9396
}

src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ protected override void ItemManipulationModel_ScrollIntoViewInvoked(object? send
109109
}
110110
}
111111

112+
protected override void ItemManipulationModel_ScrollToTopInvoked(object? sender, EventArgs e)
113+
{
114+
ContentScroller?.ChangeView(null, 0, null, true);
115+
}
116+
112117
protected override void ItemManipulationModel_FocusSelectedItemsInvoked(object? sender, EventArgs e)
113118
{
114119
if (SelectedItems?.Any() ?? false)
@@ -483,18 +488,7 @@ private async void FileList_ItemTapped(object sender, TappedRoutedEventArgs e)
483488
await CommitRenameAsync(textBox);
484489
}
485490

486-
if (isItemFolder && UserSettingsService.FoldersSettingsService.ColumnLayoutOpenFoldersWithOneClick)
487-
{
488-
ItemInvoked?.Invoke(
489-
new ColumnParam
490-
{
491-
Source = this,
492-
NavPathParam = (item is ShortcutItem sht ? sht.TargetPath : item!.ItemPath),
493-
ListView = FileList
494-
},
495-
EventArgs.Empty);
496-
}
497-
else if (!IsRenamingItem && isItemFile)
491+
if (!IsRenamingItem && isItemFile)
498492
{
499493
CheckDoubleClick(item!);
500494
}

src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ protected override void ItemManipulationModel_ScrollIntoViewInvoked(object? send
9898
ContentScroller?.ChangeView(null, FileList.Items.IndexOf(e) * RowHeight, null, true); // Scroll to index * item height
9999
}
100100

101+
protected override void ItemManipulationModel_ScrollToTopInvoked(object? sender, EventArgs e)
102+
{
103+
ContentScroller?.ChangeView(null, 0, null, true);
104+
}
105+
101106
protected override void ItemManipulationModel_FocusSelectedItemsInvoked(object? sender, EventArgs e)
102107
{
103108
if (SelectedItems?.Any() ?? false)

0 commit comments

Comments
 (0)