Skip to content

Commit 339288b

Browse files
committed
Fix: Requested changes
1 parent 5894538 commit 339288b

File tree

12 files changed

+88
-47
lines changed

12 files changed

+88
-47
lines changed

src/Files.App/Helpers/FilePropertiesHelpers.cs

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using CommunityToolkit.Mvvm.DependencyInjection;
22
using Files.App.DataModels;
3-
using Files.App.Dialogs;
43
using Files.App.Extensions;
54
using Files.App.ViewModels;
65
using Microsoft.UI;
@@ -11,55 +10,84 @@
1110
using Microsoft.Windows.ApplicationModel.Resources;
1211
using System;
1312
using System.IO;
14-
using System.Threading.Tasks;
1513
using Windows.ApplicationModel;
16-
using Windows.Foundation.Metadata;
1714
using Windows.Graphics;
1815

1916
namespace Files.App.Helpers
2017
{
18+
/// <summary>
19+
/// Represents a helper class that helps users open and handle item properties window
20+
/// </summary>
2121
public static class FilePropertiesHelpers
2222
{
23+
/// <summary>
24+
/// Whether LayoutDirection (FlowDirection) is set to right-to-left (RTL)
25+
/// </summary>
2326
public static readonly bool FlowDirectionSettingIsRightToLeft =
2427
new ResourceManager().CreateResourceContext().QualifierValues["LayoutDirection"] == "RTL";
2528

26-
private static readonly Lazy<string> logoPath = new(GetFilesLogoPath);
27-
29+
/// <summary>
30+
/// App logo location to use as window popup icon and title bar icon
31+
/// </summary>
2832
public static string LogoPath
29-
=> logoPath.Value;
33+
=> Path.Combine(Package.Current.InstalledLocation.Path, App.LogoPath);
3034

35+
/// <summary>
36+
/// Get window handle (hWnd) of the given properties window instance
37+
/// </summary>
38+
/// <param name="w">Window instance</param>
39+
/// <returns></returns>
3140
public static nint GetWindowHandle(Window w)
3241
=> WinRT.Interop.WindowNative.GetWindowHandle(w);
3342

34-
public static void ShowProperties(IShellPage associatedInstance)
43+
/// <summary>
44+
/// Open properties window
45+
/// </summary>
46+
/// <param name="associatedInstance">Associated main window instance</param>
47+
public static void OpenPropertiesWindow(IShellPage associatedInstance)
3548
{
36-
var item = GetItem(associatedInstance);
37-
OpenPropertiesWindowAsync(item, associatedInstance);
49+
object item;
3850

39-
static object GetItem(IShellPage instance)
40-
{
41-
var page = instance.SlimContentPage;
42-
if (page.IsItemSelected)
43-
{
44-
return page.SelectedItems?.Count is 1
45-
? page.SelectedItem!
46-
: page.SelectedItems!;
47-
}
51+
var page = associatedInstance.SlimContentPage;
4852

49-
var folder = instance.FilesystemViewModel.CurrentFolder;
53+
// Item(s) selected
54+
if (page.IsItemSelected)
55+
{
56+
// Selected item(s)
57+
item = page.SelectedItems?.Count is 1
58+
? page.SelectedItem!
59+
: page.SelectedItems!;
60+
}
61+
// No items selected
62+
else
63+
{
64+
// Instance's current folder
65+
var folder = associatedInstance.FilesystemViewModel.CurrentFolder;
66+
item = folder;
5067

5168
var drivesViewModel = Ioc.Default.GetRequiredService<DrivesViewModel>();
52-
5369
var drives = drivesViewModel.Drives;
5470
foreach (var drive in drives)
71+
{
72+
// Current folder is drive
5573
if (drive.Path.Equals(folder.ItemPath))
56-
return drive;
57-
58-
return folder;
74+
{
75+
item = drive;
76+
break;
77+
}
78+
}
5979
}
80+
81+
// Open properties window
82+
OpenPropertiesWindow(item, associatedInstance);
6083
}
6184

62-
public static void OpenPropertiesWindowAsync(object item, IShellPage associatedInstance)
85+
/// <summary>
86+
/// Open properties window with an explicitly specified item
87+
/// </summary>
88+
/// <param name="item">An item to view properties</param>
89+
/// <param name="associatedInstance">Associated main window instance</param>
90+
public static void OpenPropertiesWindow(object item, IShellPage associatedInstance)
6391
{
6492
if (item is null)
6593
return;
@@ -115,8 +143,5 @@ public static void OpenPropertiesWindowAsync(object item, IShellPage associatedI
115143

116144
appWindow.Move(appWindowPos);
117145
}
118-
119-
private static string GetFilesLogoPath()
120-
=> Path.Combine(Package.Current.InstalledLocation.Path, App.LogoPath);
121146
}
122147
}

src/Files.App/Interacts/BaseLayoutCommandImplementationModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,19 @@ public virtual void ShowProperties(RoutedEventArgs e)
8282
else if (SlimContentPage.BaseContextMenuFlyout.IsOpen)
8383
SlimContentPage.BaseContextMenuFlyout.Closed += OpenPropertiesFromBaseContextMenuFlyout;
8484
else
85-
FilePropertiesHelpers.ShowProperties(associatedInstance);
85+
FilePropertiesHelpers.OpenPropertiesWindow(associatedInstance);
8686
}
8787

8888
private void OpenPropertiesFromItemContextMenuFlyout(object sender, object e)
8989
{
9090
SlimContentPage.ItemContextMenuFlyout.Closed -= OpenPropertiesFromItemContextMenuFlyout;
91-
FilePropertiesHelpers.ShowProperties(associatedInstance);
91+
FilePropertiesHelpers.OpenPropertiesWindow(associatedInstance);
9292
}
9393

9494
private void OpenPropertiesFromBaseContextMenuFlyout(object sender, object e)
9595
{
9696
SlimContentPage.BaseContextMenuFlyout.Closed -= OpenPropertiesFromBaseContextMenuFlyout;
97-
FilePropertiesHelpers.ShowProperties(associatedInstance);
97+
FilePropertiesHelpers.OpenPropertiesWindow(associatedInstance);
9898
}
9999

100100
public virtual async void OpenFileLocation(RoutedEventArgs e)

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,4 +3181,7 @@
31813181
<data name="ShowCheckboxesWhenSelectingItems" xml:space="preserve">
31823182
<value>Show checkboxes when selecting items</value>
31833183
</data>
3184+
<data name="SecurityNoAccessControlEntriesText" xml:space="preserve">
3185+
<value>No groups or users have permission to access this object. However, the owner of this object can assign permissions.</value>
3186+
</data>
31843187
</root>

src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private void OpenProperties(DriveCardItem item)
292292
flyoutClosed = async (s, e) =>
293293
{
294294
ItemContextMenuFlyout.Closed -= flyoutClosed;
295-
FilePropertiesHelpers.OpenPropertiesWindowAsync(item.Item, associatedInstance);
295+
FilePropertiesHelpers.OpenPropertiesWindow(item.Item, associatedInstance);
296296
};
297297
ItemContextMenuFlyout.Closed += flyoutClosed;
298298
}

src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private void OpenProperties(WidgetCardItem? item)
8787
PrimaryItemAttribute = StorageItemTypes.Folder,
8888
ItemType = "Folder".GetLocalizedResource(),
8989
};
90-
FilePropertiesHelpers.OpenPropertiesWindowAsync(listedItem, AppInstance);
90+
FilePropertiesHelpers.OpenPropertiesWindow(listedItem, AppInstance);
9191
};
9292
ItemContextMenuFlyout.Closed += flyoutClosed;
9393
}

src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private void OpenProperties(RecentItem item)
235235
{
236236
ItemContextMenuFlyout.Closed -= flyoutClosed;
237237
var listedItem = await UniversalStorageEnumerator.AddFileAsync(await BaseStorageFile.GetFileFromPathAsync(item.Path), null, default);
238-
FilePropertiesHelpers.OpenPropertiesWindowAsync(listedItem, associatedInstance);
238+
FilePropertiesHelpers.OpenPropertiesWindow(listedItem, associatedInstance);
239239
};
240240
ItemContextMenuFlyout.Closed += flyoutClosed;
241241
}

src/Files.App/Views/HomePage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private async void QuickAccessWidget_CardPropertiesInvoked(object sender, QuickA
201201
ItemType = "Folder".GetLocalizedResource(),
202202
};
203203

204-
FilePropertiesHelpers.OpenPropertiesWindowAsync(listedItem, AppInstance);
204+
FilePropertiesHelpers.OpenPropertiesWindow(listedItem, AppInstance);
205205
}
206206

207207
private void DrivesWidget_DrivesWidgetNewPaneInvoked(object sender, DrivesWidget.DrivesWidgetInvokedEventArgs e)

src/Files.App/Views/LayoutModes/ColumnViewBase.xaml.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Windows.System;
2121
using Windows.UI.Core;
2222
using static Files.App.Constants;
23+
using DispatcherQueueTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer;
2324

2425
namespace Files.App.Views.LayoutModes
2526
{
@@ -40,6 +41,7 @@ public ColumnViewBase() : base()
4041
InitializeComponent();
4142
var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged);
4243
selectionRectangle.SelectionEnded += SelectionRectangle_SelectionEnded;
44+
tapDebounceTimer = DispatcherQueue.CreateTimer();
4345
ItemInvoked += ColumnViewBase_ItemInvoked;
4446
GotFocus += ColumnViewBase_GotFocus;
4547
}
@@ -230,11 +232,22 @@ private void HandleRightClick(object sender, RightTappedRoutedEventArgs e)
230232
HandleRightClick(e.OriginalSource);
231233
}
232234

235+
private readonly DispatcherQueueTimer tapDebounceTimer;
236+
233237
private void FileList_PreviewKeyUp(object sender, KeyRoutedEventArgs e)
234238
{
235239
// Open selected directory
236-
if (IsItemSelected && SelectedItem?.PrimaryItemAttribute == StorageItemTypes.Folder)
237-
ItemInvoked?.Invoke(new ColumnParam { NavPathParam = (SelectedItem is ShortcutItem sht ? sht.TargetPath : SelectedItem.ItemPath), ListView = FileList }, EventArgs.Empty);
240+
tapDebounceTimer.Stop();
241+
if (IsItemSelected && SelectedItem.PrimaryItemAttribute == StorageItemTypes.Folder)
242+
{
243+
var currItem = SelectedItem;
244+
tapDebounceTimer.Debounce(() =>
245+
{
246+
if (currItem == SelectedItem)
247+
ItemInvoked?.Invoke(new ColumnParam { NavPathParam = (SelectedItem is ShortcutItem sht ? sht.TargetPath : SelectedItem.ItemPath), ListView = FileList }, EventArgs.Empty);
248+
tapDebounceTimer.Stop();
249+
}, TimeSpan.FromMilliseconds(200));
250+
}
238251
}
239252

240253
protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
@@ -263,7 +276,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
263276
}
264277
else if (e.Key == VirtualKey.Enter && e.KeyStatus.IsMenuKeyDown)
265278
{
266-
FilePropertiesHelpers.ShowProperties(ParentShellPageInstance);
279+
FilePropertiesHelpers.OpenPropertiesWindow(ParentShellPageInstance);
267280
e.Handled = true;
268281
}
269282
else if (e.Key == VirtualKey.Space)

src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
335335
}
336336
else if (e.Key == VirtualKey.Enter && e.KeyStatus.IsMenuKeyDown)
337337
{
338-
FilePropertiesHelpers.ShowProperties(ParentShellPageInstance);
338+
FilePropertiesHelpers.OpenPropertiesWindow(ParentShellPageInstance);
339339
e.Handled = true;
340340
}
341341
else if (e.Key == VirtualKey.Space)

src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
293293
}
294294
else if (e.Key == VirtualKey.Enter && e.KeyStatus.IsMenuKeyDown)
295295
{
296-
FilePropertiesHelpers.ShowProperties(ParentShellPageInstance);
296+
FilePropertiesHelpers.OpenPropertiesWindow(ParentShellPageInstance);
297297
e.Handled = true;
298298
}
299299
else if (e.Key == VirtualKey.Space)

src/Files.App/Views/MainPage.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ private async void SidebarControl_SidebarItemDropped(object sender, SidebarItemD
282282
private async void SidebarControl_SidebarItemPropertiesInvoked(object sender, SidebarItemPropertiesInvokedEventArgs e)
283283
{
284284
if (e.InvokedItemDataContext is DriveItem)
285-
FilePropertiesHelpers.OpenPropertiesWindowAsync(e.InvokedItemDataContext, SidebarAdaptiveViewModel.PaneHolder.ActivePane);
285+
FilePropertiesHelpers.OpenPropertiesWindow(e.InvokedItemDataContext, SidebarAdaptiveViewModel.PaneHolder.ActivePane);
286286
else if (e.InvokedItemDataContext is LibraryLocationItem library)
287-
FilePropertiesHelpers.OpenPropertiesWindowAsync(new LibraryItem(library), SidebarAdaptiveViewModel.PaneHolder.ActivePane);
287+
FilePropertiesHelpers.OpenPropertiesWindow(new LibraryItem(library), SidebarAdaptiveViewModel.PaneHolder.ActivePane);
288288
else if (e.InvokedItemDataContext is LocationItem locationItem)
289289
{
290290
ListedItem listedItem = new ListedItem(null!)
@@ -295,7 +295,7 @@ private async void SidebarControl_SidebarItemPropertiesInvoked(object sender, Si
295295
ItemType = "Folder".GetLocalizedResource(),
296296
};
297297

298-
FilePropertiesHelpers.OpenPropertiesWindowAsync(listedItem, SidebarAdaptiveViewModel.PaneHolder.ActivePane);
298+
FilePropertiesHelpers.OpenPropertiesWindow(listedItem, SidebarAdaptiveViewModel.PaneHolder.ActivePane);
299299
}
300300
}
301301

src/Files.App/Views/Properties/SecurityPage.xaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<RowDefinition Height="Auto" />
3535
</Grid.RowDefinitions>
3636

37-
<!-- Principal List -->
37+
<!-- Access Control Entries -->
3838
<Grid
3939
x:Name="PrincipalListGrid"
4040
Grid.Row="0"
@@ -93,7 +93,7 @@
9393
Height="1"
9494
Background="{ThemeResource DividerStrokeColorDefault}" />
9595

96-
<!-- Principal List -->
96+
<!-- Access Control Entries List -->
9797
<ScrollViewer Grid.Row="2" MaxHeight="160">
9898
<ListView
9999
x:Name="AccessControlListListView"
@@ -144,16 +144,16 @@
144144
</ListView>
145145
</ScrollViewer>
146146

147-
<!-- No ACEs -->
147+
<!-- No Access Control Entries Message -->
148148
<TextBlock
149149
x:Name="NoAccessControlEntriesTextBlock"
150150
Margin="12,8,12,8"
151151
x:Load="{x:Bind SecurityViewModel.AccessControlList.AccessControlEntries, Converter={StaticResource EmptyCollectionToBoolConverter}, Mode=OneWay}"
152-
Text="No groups or users have permission to access this object. However, the owner of this object can assign permissions." />
152+
Text="{helpers:ResourceString Name=SecurityNoAccessControlEntriesText}" />
153153

154154
</Grid>
155155

156-
<!-- Permissions of Selected Principal -->
156+
<!-- Permissions of Selected ACE -->
157157
<Grid
158158
Grid.Row="1"
159159
Padding="12"

0 commit comments

Comments
 (0)