Skip to content

Commit 027b87d

Browse files
authored
Fix dialog-related issues (#1349)
1 parent c16cb7a commit 027b87d

File tree

9 files changed

+59
-38
lines changed

9 files changed

+59
-38
lines changed

Files.Launcher/Program.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,6 @@ private static async Task parseRecycleBinAction(AppServiceRequestReceivedEventAr
276276
var binSize = queryBinInfo.i64Size;
277277
responseQuery.Add("NumItems", numItems);
278278
responseQuery.Add("BinSize", binSize);
279-
responseQuery.Add("FileOwner", (string)recycler.Properties[Vanara.PInvoke.Ole32.PROPERTYKEY.System.FileOwner]);
280-
if (watchers.Any())
281-
{
282-
var info = new DirectoryInfo(watchers.First().Path);
283-
responseQuery.Add("DateAccessed", info.LastAccessTime.ToBinary());
284-
responseQuery.Add("DateCreated", info.CreationTime.ToBinary());
285-
}
286279
await args.Request.SendResponseAsync(responseQuery);
287280
}
288281
break;

Files/Dialogs/ConfirmDeleteDialog.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
x:Name="chkPermanentlyDelete"
3232
x:Uid="ConfirmDeleteDialogPermanentlyDeleteCheckBox"
3333
Content="Permanently delete"
34-
IsChecked="{x:Bind local1:App.InteractionViewModel.PermanentlyDelete, Mode=TwoWay, Converter={StaticResource StorageDeleteOptionToBooleanConverter}}" />
34+
IsChecked="{x:Bind PermanentlyDelete, Mode=TwoWay, Converter={StaticResource StorageDeleteOptionToBooleanConverter}}" />
3535
</StackPanel>
3636

3737
<StackPanel

Files/Dialogs/ConfirmDeleteDialog.xaml.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Windows.UI.Xaml;
1+
using Windows.Storage;
2+
using Windows.UI.Xaml;
23
using Windows.UI.Xaml.Controls;
34

45
// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -7,6 +8,7 @@ namespace Files.Dialogs
78
{
89
public sealed partial class ConfirmDeleteDialog : ContentDialog
910
{
11+
public StorageDeleteOption PermanentlyDelete { get; set; }
1012
public MyResult Result { get; set; }
1113

1214
public enum MyResult
@@ -16,11 +18,12 @@ public enum MyResult
1618
Nothing
1719
}
1820

19-
public ConfirmDeleteDialog(bool deleteFromRecycleBin = false)
21+
public ConfirmDeleteDialog(bool deleteFromRecycleBin, StorageDeleteOption deleteOption)
2022
{
2123
this.InitializeComponent();
2224

2325
this.Result = MyResult.Nothing; //clear the result in case the value is set from last time
26+
this.PermanentlyDelete = deleteOption;
2427

2528
// If deleting from recycle bin disable "permanently delete" option
2629
this.chkPermanentlyDelete.IsEnabled = !deleteFromRecycleBin;

Files/Interacts/Interaction.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -593,25 +593,30 @@ private async void Manager_DataRequested(DataTransferManager sender, DataRequest
593593
dataRequestDeferral.Complete();
594594
}
595595

596-
public async void DeleteItem_Click(object sender, RoutedEventArgs e)
596+
public void DeleteItem_Click(object sender, RoutedEventArgs e)
597+
{
598+
DeleteItem(StorageDeleteOption.Default);
599+
}
600+
601+
public async void DeleteItem(StorageDeleteOption deleteOption)
597602
{
598603
var deleteFromRecycleBin = CurrentInstance.FilesystemViewModel.WorkingDirectory.StartsWith(AppSettings.RecycleBinPath);
599604
if (deleteFromRecycleBin)
600605
{
601606
// Permanently delete if deleting from recycle bin
602-
App.InteractionViewModel.PermanentlyDelete = StorageDeleteOption.PermanentDelete;
607+
deleteOption = StorageDeleteOption.PermanentDelete;
603608
}
604609

605610
if (AppSettings.ShowConfirmDeleteDialog == true) //check if the setting to show a confirmation dialog is on
606611
{
607-
var dialog = new ConfirmDeleteDialog(deleteFromRecycleBin);
612+
var dialog = new ConfirmDeleteDialog(deleteFromRecycleBin, deleteOption);
608613
await dialog.ShowAsync();
609614

610615
if (dialog.Result != MyResult.Delete) //delete selected item(s) if the result is yes
611616
{
612-
App.InteractionViewModel.PermanentlyDelete = StorageDeleteOption.Default; //reset PermanentlyDelete flag
613617
return; //return if the result isn't delete
614618
}
619+
deleteOption = dialog.PermanentlyDelete;
615620
}
616621
StatusBanner banner = null;
617622
try
@@ -654,7 +659,7 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
654659
item = await ItemViewModel.GetFolderFromPathAsync(storItem.ItemPath);
655660
}
656661

657-
await item.DeleteAsync(App.InteractionViewModel.PermanentlyDelete);
662+
await item.DeleteAsync(deleteOption);
658663
}
659664
catch (FileLoadException)
660665
{
@@ -668,7 +673,7 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
668673
item = await ItemViewModel.GetFolderFromPathAsync(storItem.ItemPath);
669674
}
670675

671-
await item.DeleteAsync(App.InteractionViewModel.PermanentlyDelete);
676+
await item.DeleteAsync(deleteOption);
672677
}
673678

674679
if (deleteFromRecycleBin)
@@ -701,11 +706,10 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
701706
ResourceController.GetTranslation("FileInUseDeleteDialog/PrimaryButtonText"),
702707
ResourceController.GetTranslation("FileInUseDeleteDialog/SecondaryButtonText")))
703708
{
704-
DeleteItem_Click(null, null);
709+
DeleteItem(deleteOption);
705710
}
706711
}
707712
App.CurrentInstance.StatusBarControl.OngoingTasksControl.RemoveBanner(banner);
708-
App.InteractionViewModel.PermanentlyDelete = StorageDeleteOption.Default; //reset PermanentlyDelete flag
709713
}
710714

711715
public void RenameItem_Click(object sender, RoutedEventArgs e)

Files/View Models/InteractionViewModel.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@ public bool LeftMarginLoaded
3131
set => Set(ref _LeftMarginLoaded, value);
3232
}
3333

34-
private StorageDeleteOption _PermanentlyDelete = StorageDeleteOption.Default;
35-
36-
public StorageDeleteOption PermanentlyDelete
37-
{
38-
get => _PermanentlyDelete;
39-
set => Set(ref _PermanentlyDelete, value);
40-
}
41-
4234
private bool _IsSelectedItemImage = false;
4335

4436
public bool IsSelectedItemImage

Files/View Models/Properties/FolderProperties.cs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,31 @@ public async override void GetSpecialProperties()
6666
var response = await App.Connection.SendMessageAsync(value);
6767
if (response.Status == Windows.ApplicationModel.AppService.AppServiceResponseStatus.Success)
6868
{
69-
ViewModel.ItemCreatedTimestamp = ListedItem.GetFriendlyDate(DateTime.FromBinary((long)response.Message["DateCreated"]));
70-
ViewModel.ItemSizeBytes = (long)response.Message["BinSize"];
71-
ViewModel.ItemSize = ByteSize.FromBytes((long)response.Message["BinSize"]).ToString();
72-
ViewModel.FilesCount = (int)(long)response.Message["NumItems"];
73-
SetItemsCountString();
74-
ViewModel.ItemAccessedTimestamp = ListedItem.GetFriendlyDate(DateTime.FromBinary((long)response.Message["DateAccessed"]));
69+
if (response.Message.TryGetValue("BinSize", out var binSize))
70+
{
71+
ViewModel.ItemSizeBytes = (long)binSize;
72+
ViewModel.ItemSize = ByteSize.FromBytes((long)binSize).ToString();
73+
ViewModel.ItemSizeVisibility = Visibility.Visible;
74+
}
75+
else
76+
{
77+
ViewModel.ItemSizeVisibility = Visibility.Collapsed;
78+
}
79+
if (response.Message.TryGetValue("NumItems", out var numItems))
80+
{
81+
ViewModel.FilesCount = (int)(long)numItems;
82+
SetItemsCountString();
83+
ViewModel.FilesAndFoldersCountVisibility = Visibility.Visible;
84+
}
85+
else
86+
{
87+
ViewModel.FilesAndFoldersCountVisibility = Visibility.Collapsed;
88+
}
89+
ViewModel.ItemCreatedTimestampVisibiity = Visibility.Collapsed;
90+
ViewModel.ItemAccessedTimestampVisibility = Visibility.Collapsed;
91+
ViewModel.ItemModifiedTimestampVisibility = Visibility.Collapsed;
7592
ViewModel.ItemFileOwnerVisibility = Visibility.Collapsed;
76-
ViewModel.ItemSizeVisibility = Visibility.Visible;
93+
ViewModel.LastSeparatorVisibility = Visibility.Collapsed;
7794
}
7895
}
7996
}

Files/Views/LayoutModes/GenericFileBrowser.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ protected override void Page_CharacterReceived(CoreWindow sender, CharacterRecei
398398
if (App.CurrentInstance.CurrentPageType == typeof(GenericFileBrowser))
399399
{
400400
var focusedElement = FocusManager.GetFocusedElement(XamlRoot) as FrameworkElement;
401-
if (focusedElement is TextBox || focusedElement is PasswordBox)
401+
if (focusedElement is TextBox || focusedElement is PasswordBox ||
402+
Interacts.Interaction.FindParent<ContentDialog>(focusedElement) != null)
402403
{
403404
return;
404405
}

Files/Views/LayoutModes/GridViewBrowser.xaml.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,17 @@ private void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
291291
{
292292
AssociatedInteractions.ShowPropertiesButton_Click(null, null);
293293
}
294+
else if (e.Key == VirtualKey.Space)
295+
{
296+
if (!isRenamingItem && !App.CurrentInstance.NavigationToolbar.IsEditModeEnabled)
297+
{
298+
if ((App.CurrentInstance.ContentPage).IsQuickLookEnabled)
299+
{
300+
App.CurrentInstance.InteractionOperations.ToggleQuickLook();
301+
}
302+
e.Handled = true;
303+
}
304+
}
294305
}
295306

296307
protected override void Page_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)
@@ -300,7 +311,8 @@ protected override void Page_CharacterReceived(CoreWindow sender, CharacterRecei
300311
if (App.CurrentInstance.CurrentPageType == typeof(GridViewBrowser) && !isRenamingItem)
301312
{
302313
var focusedElement = FocusManager.GetFocusedElement(XamlRoot) as FrameworkElement;
303-
if (focusedElement is TextBox || focusedElement is PasswordBox)
314+
if (focusedElement is TextBox || focusedElement is PasswordBox ||
315+
Interacts.Interaction.FindParent<ContentDialog>(focusedElement) != null)
304316
{
305317
return;
306318
}

Files/Views/ModernShellPage.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo
210210

211211
case (false, true, false, true, VirtualKey.Delete): // shift + delete, PermanentDelete
212212
if (!App.CurrentInstance.NavigationToolbar.IsEditModeEnabled)
213-
App.InteractionViewModel.PermanentlyDelete = StorageDeleteOption.PermanentDelete;
214-
App.CurrentInstance.InteractionOperations.DeleteItem_Click(null, null);
213+
App.CurrentInstance.InteractionOperations.DeleteItem(StorageDeleteOption.PermanentDelete);
215214
break;
216215

217216
case (true, false, false, true, VirtualKey.C): // ctrl + c, copy
@@ -260,7 +259,7 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo
260259

261260
case (false, false, false, true, VirtualKey.Delete): // delete, delete item
262261
if (App.CurrentInstance.ContentPage.IsItemSelected && !App.CurrentInstance.ContentPage.isRenamingItem)
263-
App.CurrentInstance.InteractionOperations.DeleteItem_Click(null, null);
262+
App.CurrentInstance.InteractionOperations.DeleteItem(StorageDeleteOption.Default);
264263
break;
265264

266265
case (false, false, false, true, VirtualKey.Space): // space, quick look

0 commit comments

Comments
 (0)